FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: exit 1 when vitest list fails collection (fix #11145) (#11146) · vitest-dev/vitest@6108b81 · GitHub

Repository navigation

Commit 6108b81

Browse files
authored
fix: exit 1 when vitest list fails collection (fix #11145) (#11146)
1 parent 9e11669 commit 6108b81

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎packages/vitest/src/node/core.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ export class Vitest {
801801
const testModules = await this.parseSpecifications(files, {
802802
concurrency: options.staticParseConcurrency,
803803
})
804+
if (hasFailed(testModules.map(testModule => testModule.task))) {
805+
process.exitCode = 1
806+
}
804807
return { testModules, unhandledErrors: [] }
805808
}
806809

‎test/e2e/test/__snapshots__/list.test.ts.snap‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ Error: top level error
1919
"
2020
`;
2121
22+
exports[`basic output shows error with static parsing 1`] = `
23+
"Error: No test suite found in file <root>/fixtures/list/top-level-error.test.ts
24+
"
25+
`;
26+
2227
exports[`correctly outputs all tests with args: "--browser.enabled" 1`] = `
2328
"[chromium] basic.test.ts > basic suite > inner suite > some test
2429
[chromium] basic.test.ts > basic suite > inner suite > another test
@@ -104,6 +109,11 @@ Error: top level error
104109
"
105110
`;
106111
112+
exports[`json output shows error with static parsing 1`] = `
113+
"Error: No test suite found in file <root>/fixtures/list/top-level-error.test.ts
114+
"
115+
`;
116+
107117
exports[`json with a file output shows error 1`] = `
108118
"Error: describe error
109119
❯ describe-error.test.ts:4:9
@@ -122,3 +132,8 @@ Error: top level error
122132
123133
"
124134
`;
135+
136+
exports[`json with a file output shows error with static parsing 1`] = `
137+
"Error: No test suite found in file <root>/fixtures/list/top-level-error.test.ts
138+
"
139+
`;

‎test/e2e/test/list.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ test.each([
2727
expect(exitCode).toBe(1)
2828
})
2929

30+
test.each([
31+
['basic'],
32+
['json', '--json'],
33+
['json with a file', '--json=./list.json'],
34+
])('%s output shows error with static parsing', async (_, ...args) => {
35+
const { stderr, stdout, exitCode } = await runVitestCli('list', '-r=./fixtures/list', '-c=fail.config.ts', ...args)
36+
expect(stdout).toBe('')
37+
expect(relative(stderr)).toMatchSnapshot()
38+
expect(exitCode).toBe(1)
39+
})
40+
3041
test('correctly outputs json', async () => {
3142
const { stdout, exitCode } = await runVitestCli('list', '-r=./fixtures/list', '--json')
3243
expect(relative(stdout)).toMatchInlineSnapshot(`

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL