Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(only-changed): exit successfully if there were no changes (#32197)
Simon Knott5368fd7ca7fd
diff --git a/packages/playwright/src/runner/tasks.ts b/packages/playwright/src/runner/tasks.tsindex 73eb31f1e7..0a1e001a91 100644--- a/packages/playwright/src/runner/tasks.ts+++ b/packages/playwright/src/runner/tasks.ts@@ -239,7 +239,7 @@ function createLoadTask(mode: 'out-of-process' | 'in-process', options: { filtertestRun.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.`,diff --git a/tests/playwright-test/only-changed.spec.ts b/tests/playwright-test/only-changed.spec.tsindex 901ec7511c..6fe915f702 100644--- a/tests/playwright-test/only-changed.spec.ts+++ b/tests/playwright-test/only-changed.spec.ts@@ -256,10 +256,9 @@ test('should suppport component tests', async ({ runInlineTest, git, writeFilesconst 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);+});+