Skip to content

Commit f3c678f

Browse files
committed
refactor: move test dir to jest e2e config
1 parent ad7f481 commit f3c678f

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

test/e2e/browser.test.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
/// <reference types="jest-playwright-preset" />
22

3-
beforeAll(async () => {
4-
await page.goto("https://whatismybrowser.com/")
5-
})
3+
// This test is for nothing more than to make sure
4+
// tests are running in multiple browsers
5+
describe("Browser gutcheck", () => {
6+
beforeEach(async () => {
7+
await jestPlaywright.resetBrowser()
8+
})
9+
10+
test("should display correct browser", async () => {
11+
const displayNames = {
12+
chromium: "Chrome",
13+
firefox: "Firefox",
14+
webkit: "Safari",
15+
}
16+
const userAgent = await page.evaluate("navigator.userAgent")
617

7-
test("should display correct browser", async () => {
8-
const browser = await page.$eval(".string-major", (el) => el.innerHTML)
18+
if (browserName === "firefox") {
19+
expect(userAgent).toContain(displayNames[browserName])
20+
}
921

10-
const displayNames = {
11-
chromium: "Chrome",
12-
firefox: "Firefox",
13-
webkit: "Safari",
14-
}
15-
expect(browser).toContain(displayNames[browserName])
22+
if (browserName === "chromium") {
23+
expect(userAgent).toContain(displayNames[browserName])
24+
}
25+
})
1626
})

test/e2e/logout.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { chromium, Page, Browser, BrowserContext } from "playwright"
2-
import { CODE_SERVER_ADDRESS, PASSWORD, E2E_VIDEO_DIR } from "../utils/constants"
2+
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
33

44
describe("logout", () => {
55
let browser: Browser
@@ -8,9 +8,7 @@ describe("logout", () => {
88

99
beforeAll(async () => {
1010
browser = await chromium.launch()
11-
context = await browser.newContext({
12-
recordVideo: { dir: E2E_VIDEO_DIR },
13-
})
11+
context = await browser.newContext()
1412
})
1513

1614
afterAll(async () => {

test/e2e/openHelpAbout.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { chromium, Page, Browser, BrowserContext, Cookie } from "playwright"
22
import { hash } from "../../src/node/util"
3-
import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE, E2E_VIDEO_DIR } from "../utils/constants"
3+
import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE } from "../utils/constants"
44
import { createCookieIfDoesntExist } from "../utils/helpers"
55

66
describe("Open Help > About", () => {
@@ -45,7 +45,6 @@ describe("Open Help > About", () => {
4545

4646
context = await browser.newContext({
4747
storageState: { cookies: maybeUpdatedCookies },
48-
recordVideo: { dir: E2E_VIDEO_DIR },
4948
})
5049
})
5150

test/jest.e2e.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ const config: Config.InitialOptions = {
1212
// TODO enable on webkit as well
1313
// waiting on https://github.com/playwright-community/jest-playwright/issues/659
1414
browsers: ["chromium", "firefox"],
15+
// If there's a page error, we don't exit
16+
// i.e. something logged in the console
17+
exitOnPageError: false,
18+
contextOptions: {
19+
recordVideo: {
20+
dir: "./test/e2e/videos",
21+
},
22+
},
1523
},
1624
},
1725
testPathIgnorePatterns: ["/node_modules/", "/lib/", "/out/", "test/unit"],

test/utils/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export const CODE_SERVER_ADDRESS = process.env.CODE_SERVER_ADDRESS || "http://localhost:8080"
22
export const PASSWORD = process.env.PASSWORD || "e45432jklfdsab"
33
export const STORAGE = process.env.STORAGE || ""
4-
export const E2E_VIDEO_DIR = "./test/e2e/videos"

0 commit comments

Comments
 (0)