-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb5c6fa
commit 36b9c94
Showing
7 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,6 @@ yarn-error.log* | |
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
cypress/videos | ||
cypress/videos | ||
|
||
/test-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { devices, PlaywrightTestConfig } from "@playwright/test"; | ||
import path from "path"; | ||
|
||
// Use process.env.PORT by default and fallback to port 3000 | ||
const PORT = process.env.PORT || 3000; | ||
|
||
// Set webServer.url and use.baseURL with the location of the WebServer respecting the correct set port | ||
const baseURL = `http://localhost:${PORT}`; | ||
|
||
// Reference: https://playwright.dev/docs/test-configuration | ||
const config: PlaywrightTestConfig = { | ||
// Timeout per test | ||
timeout: 30 * 1000, | ||
// Test directory | ||
testDir: path.join(__dirname, "playwright"), | ||
// If a test fails, retry it additional 2 times | ||
retries: 2, | ||
// Artifacts folder where screenshots, videos, and traces are stored. | ||
outputDir: "test-results/", | ||
|
||
// Run your local dev server before starting the tests: | ||
// https://playwright.dev/docs/test-advanced#launching-a-development-web-server-during-the-tests | ||
webServer: { | ||
command: "npm run dev", | ||
url: baseURL, | ||
timeout: 120 * 1000, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
|
||
use: { | ||
// Use baseURL so to make navigations relative. | ||
// More information: https://playwright.dev/docs/api/class-testoptions#test-options-base-url | ||
baseURL, | ||
|
||
// Retry a test if its failing with enabled tracing. This allows you to analyse the DOM, console logs, network traffic etc. | ||
// More information: https://playwright.dev/docs/trace-viewer | ||
trace: "retry-with-trace", | ||
|
||
// All available context options: https://playwright.dev/docs/api/class-browser#browser-new-context | ||
// contextOptions: { | ||
// ignoreHTTPSErrors: true, | ||
// }, | ||
}, | ||
|
||
projects: [ | ||
{ | ||
name: "Desktop Chrome", | ||
use: { | ||
...devices["Desktop Chrome"], | ||
}, | ||
}, | ||
// { | ||
// name: 'Desktop Firefox', | ||
// use: { | ||
// ...devices['Desktop Firefox'], | ||
// }, | ||
// }, | ||
// { | ||
// name: 'Desktop Safari', | ||
// use: { | ||
// ...devices['Desktop Safari'], | ||
// }, | ||
// }, | ||
// Test against mobile viewports. | ||
{ | ||
name: "Mobile Chrome", | ||
use: { | ||
...devices["Pixel 5"], | ||
}, | ||
}, | ||
{ | ||
name: "Mobile Safari", | ||
use: devices["iPhone 12"], | ||
}, | ||
], | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test("when initiated should render the generations page", async ({ page }) => { | ||
await page.goto("/"); | ||
await expect(page.locator("h1")).toContainText("PokeSearch"); | ||
await expect(page.locator("a")).toHaveCount(9); | ||
}); | ||
|
||
test("when tried to access an invalid route should display an error message", async ({ page }) => { | ||
await page.goto("/test"); | ||
await expect(page.locator("text=Page Not Found")).toBeDefined(); | ||
}); | ||
|
||
test("when clicked in a generation link should redirect to generation page", async ({ page }) => { | ||
await page.goto("/"); | ||
|
||
await page.getByRole("link", { name: "Generation I", exact: true }).click(); | ||
|
||
await expect(page).toHaveURL(/.*\/generation\/1/); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters