@@ -75,28 +75,17 @@ it('prevents reassigning items in a frozen array', () => {
7575} ) ;
7676
7777it ( 'types return values to prevent mutations in typescript' , async ( ) => {
78- const result = await execa . stdout (
79- 'tsc' ,
80- [
81- '--noEmit' ,
82- '--project' ,
83- resolve ( __dirname , '__fixtures__/frozen_object_mutation.tsconfig.json' ) ,
84- ] ,
85- {
86- cwd : resolve ( __dirname , '__fixtures__' ) ,
87- reject : false ,
88- }
89- ) ;
78+ await expect (
79+ execa . stdout ( 'tsc' , [ '--noEmit' ] , {
80+ cwd : resolve ( __dirname , '__fixtures__/frozen_object_mutation' ) ,
81+ } )
82+ ) . rejects . toThrowErrorMatchingInlineSnapshot ( `
83+ "Command failed: tsc --noEmit
9084
91- const errorCodeRe = / \s e r r o r \s ( T S \d { 4 } ) : / g;
92- const errorCodes = [ ] ;
93- while ( true ) {
94- const match = errorCodeRe . exec ( result ) ;
95- if ( ! match ) {
96- break ;
97- }
98- errorCodes . push ( match [ 1 ] ) ;
99- }
100-
101- expect ( errorCodes ) . toEqual ( [ 'TS2704' , 'TS2540' , 'TS2540' , 'TS2339' ] ) ;
85+ index.ts(30,11): error TS2540: Cannot assign to 'baz' because it is a constant or a read-only property.
86+ index.ts(40,10): error TS2540: Cannot assign to 'bar' because it is a constant or a read-only property.
87+ index.ts(42,1): error TS2542: Index signature in type 'RecursiveReadonlyArray<number>' only permits reading.
88+ index.ts(50,8): error TS2339: Property 'push' does not exist on type 'RecursiveReadonlyArray<number>'.
89+ "
90+ ` ) ;
10291} ) ;
0 commit comments