Skip to content

Commit 152750e

Browse files
authored
fix: don't print typecheck warning more than once (#10461)
1 parent a303fec commit 152750e

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎packages/vitest/src/node/config/resolveConfig.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ function resolveInlineWorkerOption(value: string | number): number {
146146
}
147147
}
148148

149+
// warn only once, check one PER PROCESS, not per instance,
150+
// that's why it's on a module-level
151+
let warnedTypeCheck = false
152+
149153
export function resolveConfig(
150154
vitest: Vitest,
151155
options: UserConfig,
@@ -820,7 +824,8 @@ export function resolveConfig(
820824
resolved.typecheck ??= {} as any
821825
resolved.typecheck.enabled ??= false
822826

823-
if (resolved.typecheck.enabled) {
827+
if (resolved.typecheck.enabled && !warnedTypeCheck) {
828+
warnedTypeCheck = true
824829
logger.console.warn(
825830
c.yellow(
826831
'Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest\'s version when using it.',

‎test/typescript/test/__snapshots__/runner.test.ts.snap‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ TypeCheckError: Type 'string' does not satisfy the constraint '"Expected string,
100100
`;
101101
102102
exports[`should fail > typechecks empty "include" but with tests 1`] = `
103-
"Testing types with tsc and vue-tsc is an experimental feature.
104-
Breaking changes might not follow SemVer, please pin Vitest's version when using it.
105-
⎯⎯ Unhandled Errors ⎯⎯
103+
"⎯⎯ Unhandled Errors ⎯⎯
106104
107105
Vitest caught 1 unhandled error during the test run.
108106
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

‎test/typescript/test/runner.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('should fail', async () => {
8585

8686
const message = removeLines(stderr.replace(resolve(import.meta.dirname, '..'), '<root>'))
8787

88-
expect(message).toMatchSnapshot()
88+
expect(message.replace('Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest\'s version when using it.\n', '')).toMatchSnapshot()
8989
})
9090
})
9191

0 commit comments

Comments
 (0)