fix(only-changed): exit successfully if there were no changes

This commit is contained in:
Simon Knott 2024-08-16 16:42:26 +02:00
parent e17d1c498b
commit 75f39c2d96
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 17 additions and 1 deletions

View file

@ -198,7 +198,7 @@ async function runTests(args: string[], opts: { [key: string]: any }) {
config.cliGrepInvert = opts.grepInvert as string | undefined;
config.cliListOnly = !!opts.list;
config.cliProjectFilter = opts.project || undefined;
config.cliPassWithNoTests = !!opts.passWithNoTests;
config.cliPassWithNoTests = !!(opts.passWithNoTests ?? opts.onlyChanged);
config.cliFailOnFlakyTests = !!opts.failOnFlakyTests;
const runner = new Runner(config);

View file

@ -413,4 +413,20 @@ test('should run project dependencies of changed tests', {
expect(result.passed).toBe(1);
expect(result.output).toContain('setup test is executed');
});
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);
});