Skip to content

Commit

Permalink
test: use base url option at cofiguration file
Browse files Browse the repository at this point in the history
  • Loading branch information
shootermv committed Jul 31, 2024
1 parent 80a66a7 commit 9cd3dd6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion e2e/can-finish-quiz.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";

test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:3000/#/quizzes");
await page.goto("/#/quizzes");

await page.getByRole("button", { name: "HTML" }).click();

Expand All @@ -13,6 +13,9 @@ test("after answer all the questions user should see 'results' page", async ({
}) => {
// loop through all the questions.
for (let i = 1; i <= 10; i++) {
// Url should contain number of question
await expect(page.url()).toContain(`${i}/of/10`);

// Select the first option (no matter if it right or worng)
await page.getByRole("button").nth(0).click();

Expand Down
2 changes: 1 addition & 1 deletion e2e/can-run-quiz.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const CATEGORIES = [
] as const;

test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:3000/#/quizzes");
await page.goto("/#/quizzes");
});

test("select category page has full list of categories", async ({ page }) => {
Expand Down
6 changes: 3 additions & 3 deletions e2e/sanity.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { test, expect } from "@playwright/test";

test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:3000/");
await page.goto("/");
});

test("has title", async ({ page }) => {
test("site has 'Developer Quiz' title", async ({ page }) => {
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Developer Quiz/);
});

test("pressing get started link should lead to select categories page", async ({
test("pressing 'get started' link should lead to 'select categories' page", async ({
page
}) => {
// Click the get started link.
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
baseURL: "http://127.0.0.1:3000",

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry"
Expand Down

0 comments on commit 9cd3dd6

Please sign in to comment.