[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix(typecheck): fix `ignoreSourceErrors` in run mode (#5044)

authored by

Hiroshi Ogawa and committed by
GitHub
(Jan 26, 2024, 11:26 AM +0100) 6dae3feb cf5641a9

+57 -2
+2 -1
test/typescript/tsconfig.json
··· 1 1 { 2 2 "extends": "../../tsconfig.base.json", 3 3 "exclude": [ 4 - "**/dist/**" 4 + "**/dist/**", 5 + "**/fixtures/**" 5 6 ] 6 7 }
+27
test/typescript/test/runner.test.ts
··· 97 97 expect(stderr.replace(resolve(__dirname, '..'), '<root>')).toMatchSnapshot() 98 98 }) 99 99 }) 100 + 101 + describe('ignoreSourceErrors', () => { 102 + it('disabled', async () => { 103 + const vitest = await runVitestCli( 104 + { 105 + cwd: resolve(__dirname, '../fixtures/source-error'), 106 + }, 107 + '--run', 108 + ) 109 + expect(vitest.stdout).toContain('Unhandled Errors') 110 + expect(vitest.stderr).toContain('Unhandled Source Error') 111 + expect(vitest.stderr).toContain('TypeCheckError: Cannot find name \'thisIsSourceError\'') 112 + }) 113 + 114 + it('enabled', async () => { 115 + const vitest = await runVitestCli( 116 + { 117 + cwd: resolve(__dirname, '../fixtures/source-error'), 118 + }, 119 + '--run', 120 + '--typecheck.ignoreSourceErrors', 121 + ) 122 + expect(vitest.stdout).not.toContain('Unhandled Errors') 123 + expect(vitest.stderr).not.toContain('Unhandled Source Error') 124 + expect(vitest.stderr).not.toContain('TypeCheckError: Cannot find name \'thisIsSourceError\'') 125 + }) 126 + })
+12
test/typescript/fixtures/source-error/tsconfig.json
··· 1 + { 2 + "compilerOptions": { 3 + "noEmit": true, 4 + "target": "es2020", 5 + "module": "ESNext", 6 + "moduleResolution": "Bundler", 7 + "strict": true, 8 + "verbatimModuleSyntax": true 9 + }, 10 + "include": ["src", "test"], 11 + "exclude": ["node_modules"] 12 + }
+9
test/typescript/fixtures/source-error/vite.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({ 4 + test: { 5 + typecheck: { 6 + enabled: true, 7 + }, 8 + }, 9 + })
+1 -1
packages/vitest/src/node/pools/typecheck.ts
··· 20 20 if (!project.config.typecheck.ignoreSourceErrors) 21 21 sourceErrors.forEach(error => ctx.state.catchError(error, 'Unhandled Source Error')) 22 22 23 - const processError = !hasFailed(files) && checker.getExitCode() 23 + const processError = !hasFailed(files) && !sourceErrors.length && checker.getExitCode() 24 24 if (processError) { 25 25 const error = new Error(checker.getOutput()) 26 26 error.stack = ''
+1
test/typescript/fixtures/source-error/src/not-ok.ts
··· 1 + thisIsSourceError
+5
test/typescript/fixtures/source-error/test/ok.test-d.ts
··· 1 + import { expectTypeOf, test } from 'vitest' 2 + 3 + test('ok', () => { 4 + expectTypeOf(1).toEqualTypeOf(2) 5 + })