test: roll test runner to 0.3.20 (#3963)
This commit is contained in:
parent
1d21c1e4bd
commit
4aaf3b7596
44
package-lock.json
generated
44
package-lock.json
generated
|
|
@ -1187,9 +1187,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@playwright/test-runner": {
|
"@playwright/test-runner": {
|
||||||
"version": "0.3.18",
|
"version": "0.3.20",
|
||||||
"resolved": "https://registry.npmjs.org/@playwright/test-runner/-/test-runner-0.3.18.tgz",
|
"resolved": "https://registry.npmjs.org/@playwright/test-runner/-/test-runner-0.3.20.tgz",
|
||||||
"integrity": "sha512-QvkStde6VE6pV0oukwV/U2P1aT96sVndbaMZAmXx2w31HotOl2w/G4tWVAIV/UtKtcI3fFY2womfUB3wUAAyjw==",
|
"integrity": "sha512-G3gd5ELp2MesOq7xoFbhinnFARi5YyNiFdB3hnazAP3EjYpZUrzZBP7/BLLur6jzwiNmomq1NbEBn4SHiXUDiQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/code-frame": "^7.10.4",
|
"@babel/code-frame": "^7.10.4",
|
||||||
|
|
@ -1199,6 +1199,7 @@
|
||||||
"@babel/preset-typescript": "^7.10.4",
|
"@babel/preset-typescript": "^7.10.4",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
"commander": "^6.1.0",
|
"commander": "^6.1.0",
|
||||||
|
"debug": "^4.1.5",
|
||||||
"expect": "^26.4.2",
|
"expect": "^26.4.2",
|
||||||
"jpeg-js": "^0.4.2",
|
"jpeg-js": "^0.4.2",
|
||||||
"micromatch": "^4.0.2",
|
"micromatch": "^4.0.2",
|
||||||
|
|
@ -1211,6 +1212,17 @@
|
||||||
"stack-utils": "^2.0.2",
|
"stack-utils": "^2.0.2",
|
||||||
"terminal-link": "^2.1.1",
|
"terminal-link": "^2.1.1",
|
||||||
"text-diff": "^1.0.1"
|
"text-diff": "^1.0.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"debug": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"ms": "2.1.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@sindresorhus/is": {
|
"@sindresorhus/is": {
|
||||||
|
|
@ -1378,9 +1390,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/yargs": {
|
"@types/yargs": {
|
||||||
"version": "15.0.5",
|
"version": "15.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.7.tgz",
|
||||||
"integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==",
|
"integrity": "sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/yargs-parser": "*"
|
"@types/yargs-parser": "*"
|
||||||
|
|
@ -2183,12 +2195,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"version": "4.14.3",
|
"version": "4.14.4",
|
||||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.3.tgz",
|
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.4.tgz",
|
||||||
"integrity": "sha512-GcZPC5+YqyPO4SFnz48/B0YaCwS47Q9iPChRGi6t7HhflKBcINzFrJvRfC+jp30sRMKxF+d4EHGs27Z0XP1NaQ==",
|
"integrity": "sha512-7FOuawafVdEwa5Jv4nzeik/PepAjVte6HmVGHsjt2bC237jeL9QlcTBDF3PnHEvcC6uHwLGYPwZHNZMB7wWAnw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"caniuse-lite": "^1.0.30001131",
|
"caniuse-lite": "^1.0.30001135",
|
||||||
"electron-to-chromium": "^1.3.570",
|
"electron-to-chromium": "^1.3.570",
|
||||||
"escalade": "^3.1.0",
|
"escalade": "^3.1.0",
|
||||||
"node-releases": "^1.1.61"
|
"node-releases": "^1.1.61"
|
||||||
|
|
@ -2321,9 +2333,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"caniuse-lite": {
|
"caniuse-lite": {
|
||||||
"version": "1.0.30001133",
|
"version": "1.0.30001135",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001133.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001135.tgz",
|
||||||
"integrity": "sha512-s3XAUFaC/ntDb1O3lcw9K8MPeOW7KO3z9+GzAoBxfz1B0VdacXPMKgFUtG4KIsgmnbexmi013s9miVu4h+qMHw==",
|
"integrity": "sha512-ziNcheTGTHlu9g34EVoHQdIu5g4foc8EsxMGC7Xkokmvw0dqNtX8BS8RgCgFBaAiSp2IdjvBxNdh0ssib28eVQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"caseless": {
|
"caseless": {
|
||||||
|
|
@ -3003,9 +3015,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electron-to-chromium": {
|
"electron-to-chromium": {
|
||||||
"version": "1.3.570",
|
"version": "1.3.571",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.570.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.571.tgz",
|
||||||
"integrity": "sha512-Y6OCoVQgFQBP5py6A/06+yWxUZHDlNr/gNDGatjH8AZqXl8X0tE4LfjLJsXGz/JmWJz8a6K7bR1k+QzZ+k//fg==",
|
"integrity": "sha512-UYEQ2Gtc50kqmyOmOVtj6Oqi38lm5yRJY3pLuWt6UIot0No1L09uu6Ja6/1XKwmz/p0eJFZTUZi+khd1PV1hHA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"elliptic": {
|
"elliptic": {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
"ws": "^7.3.1"
|
"ws": "^7.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test-runner": "^0.3.18",
|
"@playwright/test-runner": "^0.3.20",
|
||||||
"@types/debug": "^4.1.5",
|
"@types/debug": "^4.1.5",
|
||||||
"@types/extract-zip": "^1.6.2",
|
"@types/extract-zip": "^1.6.2",
|
||||||
"@types/mime": "^2.0.3",
|
"@types/mime": "^2.0.3",
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ describe('lauch server', suite => {
|
||||||
await browserServer.close();
|
await browserServer.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with port', async ({browserType, defaultBrowserOptions, workerIndex}) => {
|
it('should work with port', async ({browserType, defaultBrowserOptions, testWorkerIndex}) => {
|
||||||
const browserServer = await browserType.launchServer({ ...defaultBrowserOptions, port: 8800 + workerIndex });
|
const browserServer = await browserType.launchServer({ ...defaultBrowserOptions, port: 8800 + testWorkerIndex });
|
||||||
expect(browserServer.wsEndpoint()).toContain(String(8800 + workerIndex));
|
expect(browserServer.wsEndpoint()).toContain(String(8800 + testWorkerIndex));
|
||||||
await browserServer.close();
|
await browserServer.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ type PlaywrightTestFixtures = {
|
||||||
httpsServer: TestServer;
|
httpsServer: TestServer;
|
||||||
browserServer: BrowserServer;
|
browserServer: BrowserServer;
|
||||||
testOutputDir: string;
|
testOutputDir: string;
|
||||||
|
tmpDir: string;
|
||||||
createUserDataDir: () => Promise<string>;
|
createUserDataDir: () => Promise<string>;
|
||||||
launchPersistent: (options?: Parameters<BrowserType<Browser>['launchPersistentContext']>[1]) => Promise<{context: BrowserContext, page: Page}>;
|
launchPersistent: (options?: Parameters<BrowserType<Browser>['launchPersistentContext']>[1]) => Promise<{context: BrowserContext, page: Page}>;
|
||||||
};
|
};
|
||||||
|
|
@ -97,11 +98,11 @@ export const options = {
|
||||||
TRACING: valueFromEnv('TRACING', false),
|
TRACING: valueFromEnv('TRACING', false),
|
||||||
};
|
};
|
||||||
|
|
||||||
defineWorkerFixture('httpService', async ({workerIndex}, test) => {
|
defineWorkerFixture('httpService', async ({ testWorkerIndex }, test) => {
|
||||||
const assetsPath = path.join(__dirname, 'assets');
|
const assetsPath = path.join(__dirname, 'assets');
|
||||||
const cachedPath = path.join(__dirname, 'assets', 'cached');
|
const cachedPath = path.join(__dirname, 'assets', 'cached');
|
||||||
|
|
||||||
const port = 8907 + workerIndex * 2;
|
const port = 8907 + testWorkerIndex * 2;
|
||||||
const server = await TestServer.create(assetsPath, port);
|
const server = await TestServer.create(assetsPath, port);
|
||||||
server.enableHTTPCache(cachedPath);
|
server.enableHTTPCache(cachedPath);
|
||||||
|
|
||||||
|
|
@ -126,7 +127,7 @@ const getExecutablePath = browserName => {
|
||||||
return process.env.WKPATH;
|
return process.env.WKPATH;
|
||||||
};
|
};
|
||||||
|
|
||||||
defineWorkerFixture('defaultBrowserOptions', async ({browserName}, runTest, config) => {
|
defineWorkerFixture('defaultBrowserOptions', async ({ browserName, testConfig }, runTest) => {
|
||||||
const executablePath = getExecutablePath(browserName);
|
const executablePath = getExecutablePath(browserName);
|
||||||
if (executablePath)
|
if (executablePath)
|
||||||
console.error(`Using executable at ${executablePath}`);
|
console.error(`Using executable at ${executablePath}`);
|
||||||
|
|
@ -135,11 +136,11 @@ defineWorkerFixture('defaultBrowserOptions', async ({browserName}, runTest, conf
|
||||||
slowMo: options.SLOW_MO,
|
slowMo: options.SLOW_MO,
|
||||||
headless: options.HEADLESS,
|
headless: options.HEADLESS,
|
||||||
executablePath,
|
executablePath,
|
||||||
artifactsPath: config.outputDir,
|
artifactsPath: testConfig.outputDir,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
defineWorkerFixture('playwright', async ({browserName, workerIndex, platform}, test) => {
|
defineWorkerFixture('playwright', async ({browserName, testWorkerIndex, platform}, test) => {
|
||||||
assert(platform); // Depend on platform to generate all tests.
|
assert(platform); // Depend on platform to generate all tests.
|
||||||
const {coverage, uninstall} = installCoverageHooks(browserName);
|
const {coverage, uninstall} = installCoverageHooks(browserName);
|
||||||
if (options.WIRE) {
|
if (options.WIRE) {
|
||||||
|
|
@ -172,7 +173,7 @@ defineWorkerFixture('playwright', async ({browserName, workerIndex, platform}, t
|
||||||
|
|
||||||
async function teardownCoverage() {
|
async function teardownCoverage() {
|
||||||
uninstall();
|
uninstall();
|
||||||
const coveragePath = path.join(__dirname, 'coverage-report', workerIndex + '.json');
|
const coveragePath = path.join(__dirname, 'coverage-report', testWorkerIndex + '.json');
|
||||||
const coverageJSON = [...coverage.keys()].filter(key => coverage.get(key));
|
const coverageJSON = [...coverage.keys()].filter(key => coverage.get(key));
|
||||||
await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });
|
await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });
|
||||||
await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');
|
await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');
|
||||||
|
|
@ -259,10 +260,10 @@ defineWorkerFixture('expectedSSLError', async ({browserName, platform}, runTest)
|
||||||
await runTest(expectedSSLError);
|
await runTest(expectedSSLError);
|
||||||
});
|
});
|
||||||
|
|
||||||
defineTestFixture('testOutputDir', async ({}, runTest, info) => {
|
defineTestFixture('testOutputDir', async ({ testInfo }, runTest) => {
|
||||||
const relativePath = path.relative(info.config.testDir, info.file).replace(/\.spec\.[jt]s/, '');
|
const relativePath = path.relative(testInfo.config.testDir, testInfo.file).replace(/\.spec\.[jt]s/, '');
|
||||||
const sanitizedTitle = info.title.replace(/[^\w\d]+/g, '_');
|
const sanitizedTitle = testInfo.title.replace(/[^\w\d]+/g, '_');
|
||||||
const testOutputDir = path.join(info.config.outputDir, relativePath, sanitizedTitle);
|
const testOutputDir = path.join(testInfo.config.outputDir, relativePath, sanitizedTitle);
|
||||||
await fs.promises.mkdir(testOutputDir, { recursive: true });
|
await fs.promises.mkdir(testOutputDir, { recursive: true });
|
||||||
await runTest(testOutputDir);
|
await runTest(testOutputDir);
|
||||||
const files = await fs.promises.readdir(testOutputDir);
|
const files = await fs.promises.readdir(testOutputDir);
|
||||||
|
|
@ -273,10 +274,9 @@ defineTestFixture('testOutputDir', async ({}, runTest, info) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
defineTestFixture('context', async ({browser, testOutputDir}, runTest, info) => {
|
defineTestFixture('context', async ({ browser, testOutputDir, testConfig }, runTest) => {
|
||||||
const { config } = info;
|
|
||||||
const contextOptions: BrowserContextOptions = {
|
const contextOptions: BrowserContextOptions = {
|
||||||
relativeArtifactsPath: path.relative(config.outputDir, testOutputDir),
|
relativeArtifactsPath: path.relative(testConfig.outputDir, testOutputDir),
|
||||||
recordTrace: !!options.TRACING,
|
recordTrace: !!options.TRACING,
|
||||||
// TODO: enable videos. Currently, long videos are slowly processed by Chromium
|
// TODO: enable videos. Currently, long videos are slowly processed by Chromium
|
||||||
// and (sometimes) Firefox, which causes test timeouts.
|
// and (sometimes) Firefox, which causes test timeouts.
|
||||||
|
|
@ -287,14 +287,14 @@ defineTestFixture('context', async ({browser, testOutputDir}, runTest, info) =>
|
||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
defineTestFixture('page', async ({context, testOutputDir}, runTest, info) => {
|
defineTestFixture('page', async ({ context, testOutputDir, testInfo }, runTest) => {
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
await runTest(page);
|
await runTest(page);
|
||||||
if (info.status === 'failed' || info.status === 'timedOut')
|
if (testInfo.status === 'failed' || testInfo.status === 'timedOut')
|
||||||
await page.screenshot({ timeout: 5000, path: path.join(testOutputDir, 'test-failed.png') });
|
await page.screenshot({ timeout: 5000, path: path.join(testOutputDir, 'test-failed.png') });
|
||||||
});
|
});
|
||||||
|
|
||||||
defineTestFixture('createUserDataDir', async ({testOutputDir}, runTest, info) => {
|
defineTestFixture('createUserDataDir', async ({testOutputDir}, runTest) => {
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
const dirs: string[] = [];
|
const dirs: string[] = [];
|
||||||
async function createUserDataDir() {
|
async function createUserDataDir() {
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ it('should exclude patterns', (test, parameters) => {
|
||||||
|
|
||||||
it('should use socks proxy', (test, parameters) => {
|
it('should use socks proxy', (test, parameters) => {
|
||||||
test.flaky(options.MAC(parameters) && options.WEBKIT(parameters), 'Intermittent page.goto: The network connection was lost error on bots');
|
test.flaky(options.MAC(parameters) && options.WEBKIT(parameters), 'Intermittent page.goto: The network connection was lost error on bots');
|
||||||
}, async ({ browserType, defaultBrowserOptions, workerIndex }) => {
|
}, async ({ browserType, defaultBrowserOptions, testWorkerIndex }) => {
|
||||||
const server = socks.createServer((info, accept, deny) => {
|
const server = socks.createServer((info, accept, deny) => {
|
||||||
let socket;
|
let socket;
|
||||||
if ((socket = accept(true))) {
|
if ((socket = accept(true))) {
|
||||||
|
|
@ -138,7 +138,7 @@ it('should use socks proxy', (test, parameters) => {
|
||||||
].join('\r\n'));
|
].join('\r\n'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const socksPort = 9107 + workerIndex * 2;
|
const socksPort = 9107 + testWorkerIndex * 2;
|
||||||
server.listen(socksPort, 'localhost');
|
server.listen(socksPort, 'localhost');
|
||||||
server.useAuth(socks.auth.None());
|
server.useAuth(socks.auth.None());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,11 @@ type TestState = {
|
||||||
const fixtures = playwrightFixtures.declareWorkerFixtures<WorkerState>().declareTestFixtures<TestState>();
|
const fixtures = playwrightFixtures.declareWorkerFixtures<WorkerState>().declareTestFixtures<TestState>();
|
||||||
const { it, expect, describe, defineTestFixture, defineWorkerFixture, overrideWorkerFixture } = fixtures;
|
const { it, expect, describe, defineTestFixture, defineWorkerFixture, overrideWorkerFixture } = fixtures;
|
||||||
|
|
||||||
overrideWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test, config) => {
|
overrideWorkerFixture('browser', async ({ browserType, defaultBrowserOptions, testConfig }, test) => {
|
||||||
const browser = await browserType.launch({
|
const browser = await browserType.launch({
|
||||||
...defaultBrowserOptions,
|
...defaultBrowserOptions,
|
||||||
// Make sure videos are stored on the same volume as the test output dir.
|
// Make sure videos are stored on the same volume as the test output dir.
|
||||||
artifactsPath: path.join(config.outputDir, '.screencast'),
|
artifactsPath: path.join(testConfig.outputDir, '.screencast'),
|
||||||
});
|
});
|
||||||
await test(browser);
|
await test(browser);
|
||||||
await browser.close();
|
await browser.close();
|
||||||
|
|
@ -57,14 +57,14 @@ defineTestFixture('videoPlayer', async ({videoPlayerBrowser, server}, test) => {
|
||||||
await page.close();
|
await page.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
defineTestFixture('relativeArtifactsPath', async ({browserType}, runTest, info) => {
|
defineTestFixture('relativeArtifactsPath', async ({ browserType, testInfo }, runTest) => {
|
||||||
const sanitizedTitle = info.title.replace(/[^\w\d]+/g, '_');
|
const sanitizedTitle = testInfo.title.replace(/[^\w\d]+/g, '_');
|
||||||
const relativeArtifactsPath = `${browserType.name()}-${sanitizedTitle}`;
|
const relativeArtifactsPath = `${browserType.name()}-${sanitizedTitle}`;
|
||||||
await runTest(relativeArtifactsPath);
|
await runTest(relativeArtifactsPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
defineTestFixture('videoDir', async ({relativeArtifactsPath}, runTest, info) => {
|
defineTestFixture('videoDir', async ({ relativeArtifactsPath, testConfig }, runTest) => {
|
||||||
await runTest(path.join(info.config.outputDir, '.screencast', relativeArtifactsPath));
|
await runTest(path.join(testConfig.outputDir, '.screencast', relativeArtifactsPath));
|
||||||
});
|
});
|
||||||
|
|
||||||
function almostRed(r, g, b, alpha) {
|
function almostRed(r, g, b, alpha) {
|
||||||
|
|
@ -232,7 +232,7 @@ describe('screencast', suite => {
|
||||||
expectAll(pixels, almostRed);
|
expectAll(pixels, almostRed);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should capture navigation', (test, parameters) => {
|
it('should capture navigation', test => {
|
||||||
test.flaky();
|
test.flaky();
|
||||||
}, async ({browser, server, videoPlayer, relativeArtifactsPath, videoDir}) => {
|
}, async ({browser, server, videoPlayer, relativeArtifactsPath, videoDir}) => {
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue