@@ -48,4 +48,46 @@ describe('should fail', async () => {
4848 }
4949 } )
5050 } , 30_000 )
51+
52+ it ( 'typecheks with custom tsconfig' , async ( ) => {
53+ const { stderr } = await execa ( 'npx' , [
54+ 'vitest' ,
55+ 'typecheck' ,
56+ '--run' ,
57+ '--dir' ,
58+ resolve ( __dirname , '..' , './failing' ) ,
59+ '--config' ,
60+ resolve ( __dirname , './vitest.custom.config.ts' ) ,
61+ ] , {
62+ cwd : root ,
63+ reject : false ,
64+ env : {
65+ ...process . env ,
66+ CI : 'true' ,
67+ NO_COLOR : 'true' ,
68+ } ,
69+ } )
70+
71+ expect ( stderr ) . toBeTruthy ( )
72+ const lines = String ( stderr ) . split ( / \n / g)
73+ const msg = lines
74+ . filter ( i => i . includes ( 'TypeCheckError: ' ) )
75+ . reverse ( )
76+ . join ( '\n' )
77+ . trim ( )
78+ . replace ( root , '<rootDir>' )
79+ expect ( stderr ) . not . toMatch ( 'files found, exiting with code' )
80+ // only one test file is failed, because only one is included in tsconfig
81+ // + file with .only modifier
82+ expect ( msg ) . toMatchSnapshot ( )
83+
84+ expect ( stderr ) . toContain ( 'FAIL fail.test-d.ts' ) // included in tsconfig
85+ expect ( stderr ) . toContain ( 'FAIL only.test-d.ts' ) // .only
86+
87+ // not included in tsconfig
88+ expect ( stderr ) . not . toContain ( 'expect-error.test-d.ts' )
89+ expect ( stderr ) . not . toContain ( 'js-fail.test-d.js' )
90+ expect ( stderr ) . not . toContain ( 'js.test-d.js' )
91+ expect ( stderr ) . not . toContain ( 'test.test-d.ts' )
92+ } , 30_000 )
5193} )
0 commit comments