Skip to content

Commit e368f00

Browse files
committed
Run tests on older browsers as well
1 parent cad34bd commit e368f00

File tree

4 files changed

+92
-22
lines changed

4 files changed

+92
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/demo/view-transitions-mock.js
44
/demo/view-transitions-mock.js.map
55
/test-results
6+
/custom-browsers

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
"prepack": "npm run require-license-headers && npm run require-pristine-tree && npm run test",
2222
"prepublish": "npm run build",
2323
"type-check": "tsc --noEmit",
24-
"pretest": "npm run build && npx playwright install --with-deps",
24+
"pretest": "npm run build && npx playwright install --with-deps && npm run pretest:install-old-browsers",
25+
"pretest:install-old-browsers": "npm run pretest:install-old-chromium && npm run pretest:install-old-firefox && npm run pretest:install-old-webkit",
26+
"pretest:install-old-chromium": "PLAYWRIGHT_BROWSERS_PATH=./custom-browsers npx --yes playwright@1.30 install chromium",
27+
"pretest:install-old-firefox": "PLAYWRIGHT_BROWSERS_PATH=./custom-browsers npx --yes playwright@1.56 install firefox",
28+
"pretest:install-old-webkit": "PLAYWRIGHT_BROWSERS_PATH=./custom-browsers npx --yes playwright@1.45 install webkit",
2529
"test": "playwright test",
2630
"preversion": "npm run require-license-headers && npm run require-pristine-tree && npm run test",
2731
"prepare": "husky install",

playwright.config.ts

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,77 @@
55

66
import { defineConfig, devices } from '@playwright/test';
77

8+
type BrowserPathConfig = Record<string, string>;
9+
type BrowserPathConfigs = Record<string, BrowserPathConfig>;
10+
11+
const browserPaths: BrowserPathConfigs = {
12+
// Chromium 110.0.5481.38 (bundled with Playwright 1.30, as chromium-1045)
13+
"chromium-110-nosupport": {
14+
darwin: './custom-browsers/chromium-1045/chrome-mac/Chromium.app/Contents/MacOS/Chromium',
15+
linux: './custom-browsers/chromium-1045/chrome-linux/chrome',
16+
win32: './custom-browsers/chromium-1045/chrome-win/chrome.exe',
17+
},
18+
// Firefox 142.0.1 (bundled with Playwright 1.56, as firefox-1495)
19+
"firefox-142-nosupport": {
20+
darwin: './custom-browsers/firefox-1495/firefox/Nightly.app/Contents/MacOS/firefox',
21+
linux: './custom-browsers/firefox-1495/firefox/firefox-bin',
22+
win32: './custom-browsers/firefox-1495/firefox/firefox.exe',
23+
},
24+
// Safari 17.4 (bundled with Playwright 1.45, as webkit-2035)
25+
"webkit-17.4-nosupport": {
26+
darwin: './custom-browsers/webkit-2035/pw_run.sh',
27+
linux: './custom-browsers/webkit-2035/pw_run.sh',
28+
win32: './custom-browsers/webkit-2035/webkit-win64/Playwright.exe',
29+
},
30+
};
31+
832
export default defineConfig({
933
testDir: './tests',
1034
tsconfig: './tsconfig.json',
1135
workers: 3,
1236
fullyParallel: true,
1337
projects: [
1438
{
15-
name: 'chromium',
39+
name: 'chromium-latest',
1640
use: { ...devices['Desktop Chrome'] },
1741
},
1842
{
19-
name: 'firefox',
43+
name: 'firefox-latest',
2044
use: { ...devices['Desktop Firefox'] },
2145
},
2246
{
23-
name: 'webkit',
47+
name: 'webkit-latest',
2448
use: { ...devices['Desktop Safari'] },
2549
},
50+
{
51+
name: 'firefox-142-nosupport',
52+
use: {
53+
...devices['Desktop Firefox'],
54+
launchOptions: {
55+
executablePath: browserPaths['firefox-142-nosupport'][process.platform],
56+
},
57+
},
58+
},
59+
{
60+
name: 'chromium-110-nosupport',
61+
use: {
62+
...devices['Desktop Chrome'],
63+
launchOptions: {
64+
executablePath: browserPaths['chromium-110-nosupport'][process.platform],
65+
},
66+
},
67+
},
68+
// // Disabled, because of this error:
69+
// // “Error: browserContext.newPage: Protocol error (Page.overrideSetting): Unknown setting: FixedBackgroundsPaintRelativeToDocument”
70+
// {
71+
// name: 'webkit-17.4-nosupport',
72+
// use: {
73+
// ...devices['Desktop Safari'],
74+
// launchOptions: {
75+
// executablePath: browserPaths['webkit-17.4-nosupport'][process.platform],
76+
// },
77+
// },
78+
// },
2679
],
2780
webServer: {
2881
command: 'npx esbuild --serve=7357 --servedir=. --log-level=silent',

tests/promisesorder.pw.test.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test.beforeEach(async ({ page }) => {
3737
test.describe("Promises Order", () => {
3838
test("It should resolve promises in the correct order (normal flow)", async ({
3939
page,
40-
}) => {
40+
}, testInfo) => {
4141
const startVTAndReturnLoggedMessages = async () => {
4242
const order: string[] = [];
4343
const transition = (window as any).startAndWatchViewTransition(order);
@@ -49,8 +49,10 @@ test.describe("Promises Order", () => {
4949
const expectedResult = ["updateCallbackDone", "ready", "finished"];
5050

5151
// Native result
52-
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
53-
expect(nativeResult).toEqual(expectedResult);
52+
if (!testInfo.project.name.endsWith("-nosupport")) {
53+
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
54+
expect(nativeResult).toEqual(expectedResult);
55+
}
5456

5557
// Force register the mock
5658
await page.evaluate(() => {
@@ -64,7 +66,7 @@ test.describe("Promises Order", () => {
6466

6567
test("It should resolve promises in the correct order (normal flow, no callback)", async ({
6668
page,
67-
}) => {
69+
}, testInfo) => {
6870
const startVTAndReturnLoggedMessages = async () => {
6971
const order: string[] = [];
7072
const transition = (window as any).startAndWatchViewTransition(
@@ -79,8 +81,10 @@ test.describe("Promises Order", () => {
7981
const expectedResult = ["updateCallbackDone", "ready", "finished"];
8082

8183
// Native result
82-
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
83-
expect(nativeResult).toEqual(expectedResult);
84+
if (!testInfo.project.name.endsWith("-nosupport")) {
85+
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
86+
expect(nativeResult).toEqual(expectedResult);
87+
}
8488

8589
// Force register the mock
8690
await page.evaluate(() => {
@@ -94,7 +98,7 @@ test.describe("Promises Order", () => {
9498

9599
test("It should resolve promises in the correct order (skip immediately)", async ({
96100
page,
97-
}) => {
101+
}, testInfo) => {
98102
const startVTAndReturnLoggedMessages = async () => {
99103
const order: string[] = [];
100104
const transition = (window as any).startAndWatchViewTransition(order);
@@ -107,8 +111,10 @@ test.describe("Promises Order", () => {
107111
const expectedResult = ["readyCatch", "updateCallbackDone", "finished"];
108112

109113
// Native result
110-
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
111-
expect(nativeResult).toEqual(expectedResult);
114+
if (!testInfo.project.name.endsWith("-nosupport")) {
115+
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
116+
expect(nativeResult).toEqual(expectedResult);
117+
}
112118

113119
// Force register the mock
114120
await page.evaluate(() => {
@@ -122,7 +128,7 @@ test.describe("Promises Order", () => {
122128

123129
test("It should resolve promises in the correct order (skip after ready)", async ({
124130
page,
125-
}) => {
131+
}, testInfo) => {
126132
const startVTAndReturnLoggedMessages = async () => {
127133
const order: string[] = [];
128134
const transition = (window as any).startAndWatchViewTransition(order);
@@ -137,8 +143,10 @@ test.describe("Promises Order", () => {
137143
const expectedResult = ["updateCallbackDone", "ready", "finished"];
138144

139145
// Native result
140-
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
141-
expect(nativeResult).toEqual(expectedResult);
146+
if (!testInfo.project.name.endsWith("-nosupport")) {
147+
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
148+
expect(nativeResult).toEqual(expectedResult);
149+
}
142150

143151
// Force register the mock
144152
await page.evaluate(() => {
@@ -152,7 +160,7 @@ test.describe("Promises Order", () => {
152160

153161
test("It should resolve promises in the correct order (skip after updateCallbackDone)", async ({
154162
page,
155-
}) => {
163+
}, testInfo) => {
156164
const startVTAndReturnLoggedMessages = async () => {
157165
const order: string[] = [];
158166
const transition = (window as any).startAndWatchViewTransition(order);
@@ -167,8 +175,10 @@ test.describe("Promises Order", () => {
167175
const expectedResult = ["updateCallbackDone", "ready", "finished"];
168176

169177
// Native result
170-
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
171-
expect(nativeResult).toEqual(expectedResult);
178+
if (!testInfo.project.name.endsWith("-nosupport")) {
179+
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
180+
expect(nativeResult).toEqual(expectedResult);
181+
}
172182

173183
// Force register the mock
174184
await page.evaluate(() => {
@@ -182,7 +192,7 @@ test.describe("Promises Order", () => {
182192

183193
test("It should resolve promises in the correct order (skip after finished)", async ({
184194
page,
185-
}) => {
195+
}, testInfo) => {
186196
const startVTAndReturnLoggedMessages = async () => {
187197
const order: string[] = [];
188198
const transition = (window as any).startAndWatchViewTransition(order);
@@ -196,8 +206,10 @@ test.describe("Promises Order", () => {
196206
const expectedResult = ["updateCallbackDone", "ready", "finished"];
197207

198208
// Native result
199-
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
200-
expect(nativeResult).toEqual(expectedResult);
209+
if (!testInfo.project.name.endsWith("-nosupport")) {
210+
const nativeResult = await page.evaluate(startVTAndReturnLoggedMessages);
211+
expect(nativeResult).toEqual(expectedResult);
212+
}
201213

202214
// Force register the mock
203215
await page.evaluate(() => {

0 commit comments

Comments
 (0)