Skip to content

Commit

Permalink
pokeapi test
Browse files Browse the repository at this point in the history
  • Loading branch information
PeaceGusenga committed May 15, 2023
1 parent 18a1be1 commit 312efa2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module.exports = defineConfig({
// use: { ..devices['Desktop Chrome'], channel: 'chrome' },
// },
],
// playwright.config.ts

/* Run your local dev server before starting the tests */
// webServer: {
Expand Down
26 changes: 26 additions & 0 deletions tests/API-Tests/Poke-API/PokeAPI-Test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { test, expect } = require('@playwright/test');
const fetch = require('node-fetch');

test.describe('PokeAPI Tests', () => {
test('Get Pokemon List', async () => {
const response = await fetch('https://pokeapi.co/api/v2/pokemon');
const pokemonList = await response.json();
expect(response.ok).toBe(true);
expect(pokemonList.results).toBeDefined();
expect(pokemonList.results.length).toBeGreaterThan(0);
});

test('Get Pokemon by ID', async () => {
const response = await fetch('https://pokeapi.co/api/v2/pokemon/1');
const pokemon = await response.json();
expect(response.ok).toBe(true);
expect(pokemon.name).toBe('bulbasaur');
});

test('Get Pokemon by Name', async () => {
const response = await fetch('https://pokeapi.co/api/v2/pokemon/bulbasaur');
const pokemon = await response.json();
expect(response.ok).toBe(true);
expect(pokemon.id).toBe(1);
});
});
2 changes: 1 addition & 1 deletion tests/ProjectBlaze/Test1.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('visit site', async ({ page }) => {
await page.goto('https://www.demoblaze.com');

// Click the get started link.
await page.getByRole('link',{name:'Cart'}).click();
await page.getByRole('link', { name: 'Cart'}).click();

// Expects the URL to contain intro.
await expect(page).toHaveURL(/.*cart/);
Expand Down

0 comments on commit 312efa2

Please sign in to comment.