mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(only-changed): exit successfully if there were no changes (#32197)
Closes https://github.com/microsoft/playwright/issues/32180 I was briefly wondering if we should output a log line a la "no tests found", but my understanding is that that's the reporters job - so I didn't change anything in that regard.
This commit is contained in:
parent
7758b330b1
commit
5368fd7ca7
@ -239,7 +239,7 @@ function createLoadTask(mode: 'out-of-process' | 'in-process', options: { filter
|
||||
testRun.rootSuite = await createRootSuite(testRun, options.failOnLoadErrors ? errors : softErrors, !!options.filterOnly, cliOnlyChangedMatcher);
|
||||
testRun.failureTracker.onRootSuite(testRun.rootSuite);
|
||||
// Fail when no tests.
|
||||
if (options.failOnLoadErrors && !testRun.rootSuite.allTests().length && !testRun.config.cliPassWithNoTests && !testRun.config.config.shard) {
|
||||
if (options.failOnLoadErrors && !testRun.rootSuite.allTests().length && !testRun.config.cliPassWithNoTests && !testRun.config.config.shard && !testRun.config.cliOnlyChanged) {
|
||||
if (testRun.config.cliArgs.length) {
|
||||
throw new Error([
|
||||
`No tests found.`,
|
||||
|
@ -256,10 +256,9 @@ test('should suppport component tests', async ({ runInlineTest, git, writeFiles
|
||||
|
||||
const result = await runInlineTest({}, { 'workers': 1, 'only-changed': true });
|
||||
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.passed).toBe(0);
|
||||
expect(result.failed).toBe(0);
|
||||
expect(result.output).toContain('No tests found');
|
||||
|
||||
const result2 = await runInlineTest({
|
||||
'src/button2.test.tsx': `
|
||||
@ -437,3 +436,20 @@ test('should work with list mode', async ({ runInlineTest, git, writeFiles }) =>
|
||||
expect(result.output).toContain('b.spec.ts');
|
||||
expect(result.output).not.toContain('a.spec.ts');
|
||||
});
|
||||
|
||||
test('exits successfully if there are no changes', async ({ runInlineTest, git, writeFiles }) => {
|
||||
await writeFiles({
|
||||
'a.spec.ts': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
test('fails', () => { expect(1).toBe(2); });
|
||||
`,
|
||||
});
|
||||
|
||||
git(`add .`);
|
||||
git(`commit -m init`);
|
||||
|
||||
const result = await runInlineTest({}, { 'only-changed': true });
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user