mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-05 19:04:43 +03:00
feat: --pass-with-no-tests option (#16902)
This commit is contained in:
parent
84888737e2
commit
11dfd31dd9
@ -50,6 +50,7 @@ function addTestCommand(program: Command) {
|
||||
command.option('--list', `Collect all the tests and report them, but do not run`);
|
||||
command.option('--max-failures <N>', `Stop after the first N failures`);
|
||||
command.option('--output <dir>', `Folder for output artifacts (default: "test-results")`);
|
||||
command.option('--pass-with-no-tests', `Makes test run succeed even if no tests were found`);
|
||||
command.option('--quiet', `Suppress stdio`);
|
||||
command.option('--repeat-each <N>', `Run each test N times (default: 1)`);
|
||||
command.option('--reporter <reporter>', `Reporter to use, comma-separated, can be ${builtInReporters.map(name => `"${name}"`).join(', ')} (default: "${baseFullConfig.reporter[0]}")`);
|
||||
@ -165,6 +166,7 @@ async function runTests(args: string[], opts: { [key: string]: any }) {
|
||||
testFileFilters,
|
||||
projectFilter: opts.project || undefined,
|
||||
watchMode: !!process.env.PW_TEST_WATCH,
|
||||
passWithNoTests: opts.passWithNoTests,
|
||||
});
|
||||
await stopProfiling(undefined);
|
||||
|
||||
|
@ -56,6 +56,7 @@ type RunOptions = {
|
||||
testFileFilters?: TestFileFilter[];
|
||||
projectFilter?: string[];
|
||||
watchMode?: boolean;
|
||||
passWithNoTests?: boolean;
|
||||
};
|
||||
|
||||
export type ConfigCLIOverrides = {
|
||||
@ -337,7 +338,7 @@ export class Runner {
|
||||
|
||||
// 7. Fail when no tests.
|
||||
let total = rootSuite.allTests().length;
|
||||
if (!total)
|
||||
if (!total && !options.passWithNoTests)
|
||||
fatalErrors.push(createNoTestsError());
|
||||
|
||||
// 8. Compute shards.
|
||||
|
@ -156,6 +156,16 @@ test('should exit with code 1 if passed a file name', async ({ runInlineTest })
|
||||
expect(result.output).toContain(`no tests found.`);
|
||||
});
|
||||
|
||||
test('should exit with code 0 with --pass-with-no-tests', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'playwright.config.ts': `
|
||||
module.exports = { testDir: 'unknown' };
|
||||
`,
|
||||
}, undefined, undefined, { additionalArgs: ['--pass-with-no-tests'] });
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.output).toContain(`Running 0 tests using 0 workers`);
|
||||
});
|
||||
|
||||
test('should exit with code 1 when config is not found', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({ 'my.config.js': '' }, { 'config': 'foo.config.js' });
|
||||
expect(result.exitCode).toBe(1);
|
||||
|
Loading…
Reference in New Issue
Block a user