refactor: move test dir to jest e2e config
This commit is contained in:
parent
6b3db06c7a
commit
bd55cb94be
|
@ -1,16 +1,26 @@
|
||||||
/// <reference types="jest-playwright-preset" />
|
/// <reference types="jest-playwright-preset" />
|
||||||
|
|
||||||
beforeAll(async () => {
|
// This test is for nothing more than to make sure
|
||||||
await page.goto("https://whatismybrowser.com/")
|
// tests are running in multiple browsers
|
||||||
})
|
describe("Browser gutcheck", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
test("should display correct browser", async () => {
|
await jestPlaywright.resetBrowser()
|
||||||
const browser = await page.$eval(".string-major", (el) => el.innerHTML)
|
})
|
||||||
|
|
||||||
|
test("should display correct browser", async () => {
|
||||||
const displayNames = {
|
const displayNames = {
|
||||||
chromium: "Chrome",
|
chromium: "Chrome",
|
||||||
firefox: "Firefox",
|
firefox: "Firefox",
|
||||||
webkit: "Safari",
|
webkit: "Safari",
|
||||||
}
|
}
|
||||||
expect(browser).toContain(displayNames[browserName])
|
const userAgent = await page.evaluate("navigator.userAgent")
|
||||||
|
|
||||||
|
if (browserName === "firefox") {
|
||||||
|
expect(userAgent).toContain(displayNames[browserName])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browserName === "chromium") {
|
||||||
|
expect(userAgent).toContain(displayNames[browserName])
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { chromium, Page, Browser, BrowserContext } from "playwright"
|
import { chromium, Page, Browser, BrowserContext } from "playwright"
|
||||||
import { CODE_SERVER_ADDRESS, PASSWORD, E2E_VIDEO_DIR } from "../utils/constants"
|
import { CODE_SERVER_ADDRESS, PASSWORD } from "../utils/constants"
|
||||||
|
|
||||||
describe("logout", () => {
|
describe("logout", () => {
|
||||||
let browser: Browser
|
let browser: Browser
|
||||||
|
@ -8,9 +8,7 @@ describe("logout", () => {
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
browser = await chromium.launch()
|
browser = await chromium.launch()
|
||||||
context = await browser.newContext({
|
context = await browser.newContext()
|
||||||
recordVideo: { dir: E2E_VIDEO_DIR },
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { chromium, Page, Browser, BrowserContext, Cookie } from "playwright"
|
import { chromium, Page, Browser, BrowserContext, Cookie } from "playwright"
|
||||||
import { hash } from "../../src/node/util"
|
import { hash } from "../../src/node/util"
|
||||||
import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE, E2E_VIDEO_DIR } from "../utils/constants"
|
import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE } from "../utils/constants"
|
||||||
import { createCookieIfDoesntExist } from "../utils/helpers"
|
import { createCookieIfDoesntExist } from "../utils/helpers"
|
||||||
|
|
||||||
describe("Open Help > About", () => {
|
describe("Open Help > About", () => {
|
||||||
|
@ -45,7 +45,6 @@ describe("Open Help > About", () => {
|
||||||
|
|
||||||
context = await browser.newContext({
|
context = await browser.newContext({
|
||||||
storageState: { cookies: maybeUpdatedCookies },
|
storageState: { cookies: maybeUpdatedCookies },
|
||||||
recordVideo: { dir: E2E_VIDEO_DIR },
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,14 @@ const config: Config.InitialOptions = {
|
||||||
// TODO enable on webkit as well
|
// TODO enable on webkit as well
|
||||||
// waiting on https://github.com/playwright-community/jest-playwright/issues/659
|
// waiting on https://github.com/playwright-community/jest-playwright/issues/659
|
||||||
browsers: ["chromium", "firefox"],
|
browsers: ["chromium", "firefox"],
|
||||||
|
// If there's a page error, we don't exit
|
||||||
|
// i.e. something logged in the console
|
||||||
|
exitOnPageError: false,
|
||||||
|
contextOptions: {
|
||||||
|
recordVideo: {
|
||||||
|
dir: "./test/e2e/videos",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
testPathIgnorePatterns: ["/node_modules/", "/lib/", "/out/", "test/unit"],
|
testPathIgnorePatterns: ["/node_modules/", "/lib/", "/out/", "test/unit"],
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
export const CODE_SERVER_ADDRESS = process.env.CODE_SERVER_ADDRESS || "http://localhost:8080"
|
export const CODE_SERVER_ADDRESS = process.env.CODE_SERVER_ADDRESS || "http://localhost:8080"
|
||||||
export const PASSWORD = process.env.PASSWORD || "e45432jklfdsab"
|
export const PASSWORD = process.env.PASSWORD || "e45432jklfdsab"
|
||||||
export const STORAGE = process.env.STORAGE || ""
|
export const STORAGE = process.env.STORAGE || ""
|
||||||
export const E2E_VIDEO_DIR = "./test/e2e/videos"
|
|
||||||
|
|
Loading…
Reference in New Issue