parent
5b17ca9d56
commit
2e4167027b
|
|
@ -302,12 +302,7 @@ export class Runner {
|
||||||
if (!total)
|
if (!total)
|
||||||
fatalErrors.push(createNoTestsError());
|
fatalErrors.push(createNoTestsError());
|
||||||
|
|
||||||
// 8. Fail when output fails.
|
// 8. Compute shards.
|
||||||
await Promise.all(Array.from(outputDirs).map(outputDir => removeFolderAsync(outputDir).catch(e => {
|
|
||||||
fatalErrors.push(serializeError(e));
|
|
||||||
})));
|
|
||||||
|
|
||||||
// 9. Compute shards.
|
|
||||||
let testGroups = createTestGroups(rootSuite);
|
let testGroups = createTestGroups(rootSuite);
|
||||||
|
|
||||||
const shard = config.shard;
|
const shard = config.shard;
|
||||||
|
|
@ -341,20 +336,27 @@ export class Runner {
|
||||||
}
|
}
|
||||||
(config as any).__testGroupsCount = testGroups.length;
|
(config as any).__testGroupsCount = testGroups.length;
|
||||||
|
|
||||||
// 10. Report begin
|
// 9. Report begin
|
||||||
this._reporter.onBegin?.(config, rootSuite);
|
this._reporter.onBegin?.(config, rootSuite);
|
||||||
|
|
||||||
// 11. Bail out on errors prior to running global setup.
|
// 10. Bail out on errors prior to running global setup.
|
||||||
if (fatalErrors.length) {
|
if (fatalErrors.length) {
|
||||||
for (const error of fatalErrors)
|
for (const error of fatalErrors)
|
||||||
this._reporter.onError?.(error);
|
this._reporter.onError?.(error);
|
||||||
return { status: 'failed' };
|
return { status: 'failed' };
|
||||||
}
|
}
|
||||||
|
|
||||||
// 12. Bail out if list mode only, don't do any work.
|
// 11. Bail out if list mode only, don't do any work.
|
||||||
if (list)
|
if (list)
|
||||||
return { status: 'passed' };
|
return { status: 'passed' };
|
||||||
|
|
||||||
|
// 12. Remove output directores.
|
||||||
|
try {
|
||||||
|
await Promise.all(Array.from(outputDirs).map(outputDir => removeFolderAsync(outputDir)));
|
||||||
|
} catch (e) {
|
||||||
|
this._reporter.onError?.(serializeError(e));
|
||||||
|
return { status: 'failed' };
|
||||||
|
}
|
||||||
|
|
||||||
// 13. Run Global setup.
|
// 13. Run Global setup.
|
||||||
let globalTearDown: (() => Promise<void>) | undefined;
|
let globalTearDown: (() => Promise<void>) | undefined;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { test, expect } from './playwright-test-fixtures';
|
import { test, expect } from './playwright-test-fixtures';
|
||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
test('should list tests', async ({ runInlineTest }) => {
|
test('should list tests', async ({ runInlineTest }) => {
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
|
|
@ -105,3 +107,36 @@ test('globalSetup and globalTeardown should not run', async ({ runInlineTest })
|
||||||
`Total: 2 tests in 2 files`,
|
`Total: 2 tests in 2 files`,
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('outputDir should not be removed', async ({ runInlineTest }, testInfo) => {
|
||||||
|
const outputDir = testInfo.outputPath('dummy-output-dir');
|
||||||
|
|
||||||
|
const result1 = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
module.exports = { outputDir: ${JSON.stringify(outputDir)} };
|
||||||
|
`,
|
||||||
|
'a.test.js': `
|
||||||
|
const { test } = pwt;
|
||||||
|
test('my test', async ({}, testInfo) => {
|
||||||
|
console.log(testInfo.outputDir);
|
||||||
|
require('fs').writeFileSync(testInfo.outputPath('myfile.txt'), 'hello');
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, {}, {}, { usesCustomOutputDir: true });
|
||||||
|
expect(result1.exitCode).toBe(0);
|
||||||
|
expect(fs.existsSync(path.join(outputDir, 'a-my-test', 'myfile.txt'))).toBe(true);
|
||||||
|
|
||||||
|
const result2 = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
module.exports = { outputDir: ${JSON.stringify(outputDir)} };
|
||||||
|
`,
|
||||||
|
'a.test.js': `
|
||||||
|
const { test } = pwt;
|
||||||
|
test('my test', async ({}, testInfo) => {
|
||||||
|
console.log(testInfo.outputDir);
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, { list: true }, {}, { usesCustomOutputDir: true });
|
||||||
|
expect(result2.exitCode).toBe(0);
|
||||||
|
expect(fs.existsSync(path.join(outputDir, 'a-my-test', 'myfile.txt'))).toBe(true);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue