|
1 | | -/// <reference types="jest-playwright-preset" /> |
| 1 | +import { test, expect } from "@playwright/test" |
2 | 2 |
|
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 | | - logger: { |
9 | | - isEnabled: (name) => name === "browser", |
10 | | - log: (name, severity, message, args) => console.log(`${name} ${message}`), |
11 | | - }, |
12 | | - }) |
13 | | - }) |
| 3 | +test("should display correct browser based on userAgent", async ({ page, browserName }) => { |
| 4 | + const displayNames = { |
| 5 | + chromium: "Chrome", |
| 6 | + firefox: "Firefox", |
| 7 | + webkit: "Safari", |
| 8 | + } |
| 9 | + const userAgent = await page.evaluate("navigator.userAgent") |
14 | 10 |
|
15 | | - test("should display correct browser based on userAgent", async () => { |
16 | | - const displayNames = { |
17 | | - chromium: "Chrome", |
18 | | - firefox: "Firefox", |
19 | | - webkit: "Safari", |
20 | | - } |
21 | | - const userAgent = await page.evaluate("navigator.userAgent") |
| 11 | + if (browserName === "chromium") { |
| 12 | + expect(userAgent).toContain(displayNames[browserName]) |
| 13 | + } |
22 | 14 |
|
23 | | - if (browserName === "chromium") { |
24 | | - expect(userAgent).toContain(displayNames[browserName]) |
25 | | - } |
| 15 | + if (browserName === "firefox") { |
| 16 | + expect(userAgent).toContain(displayNames[browserName]) |
| 17 | + } |
26 | 18 |
|
27 | | - if (browserName === "firefox") { |
28 | | - expect(userAgent).toContain(displayNames[browserName]) |
29 | | - } |
30 | | - |
31 | | - if (browserName === "webkit") { |
32 | | - expect(userAgent).toContain(displayNames[browserName]) |
33 | | - } |
34 | | - }) |
| 19 | + if (browserName === "webkit") { |
| 20 | + expect(userAgent).toContain(displayNames[browserName]) |
| 21 | + } |
35 | 22 | }) |
0 commit comments