1
+ import assert from 'node:assert' ;
2
+ import { getGlobalVariable } from '../../utils/env' ;
1
3
import { writeFile } from '../../utils/fs' ;
2
4
import { ng } from '../../utils/process' ;
5
+ import { assertIsError } from '../../utils/utils' ;
3
6
4
7
export default async function ( ) {
8
+ if ( getGlobalVariable ( 'argv' ) [ 'esbuild' ] ) {
9
+ // TODO: enable once this is fixed when using the esbuild builder.
10
+ return ;
11
+ }
12
+
5
13
await writeFile (
6
14
'src/app/app.component.spec.ts' ,
7
15
`
8
- it('show fail', () => {
16
+ it('should fail', () => {
9
17
expect(undefined).toBeTruthy();
10
18
});
11
19
` ,
@@ -16,18 +24,17 @@ export default async function () {
16
24
await ng ( 'test' , '--no-watch' , '--source-map' ) ;
17
25
throw new Error ( 'ng test should have failed.' ) ;
18
26
} catch ( error ) {
19
- if ( ! ( error instanceof Error && error . message . includes ( 'app.component.spec.ts' ) ) ) {
20
- throw error ;
21
- }
27
+ assertIsError ( error ) ;
28
+ assert . match ( error . message , / s r c \/ a p p \/ a p p \. c o m p o n e n t \. s p e c \. t s / ) ;
29
+ assert . doesNotMatch ( error . message , / _ k a r m a _ w e b p a c k _ / ) ;
22
30
}
23
31
24
32
// when sourcemaps are 'off' the stacktrace won't point to the spec.ts file.
25
33
try {
26
34
await ng ( 'test' , '--no-watch' , '--no-source-map' ) ;
27
35
throw new Error ( 'ng test should have failed.' ) ;
28
36
} catch ( error ) {
29
- if ( ! ( error instanceof Error && error . message . includes ( 'main.js' ) ) ) {
30
- throw error ;
31
- }
37
+ assertIsError ( error ) ;
38
+ assert . match ( error . message , / m a i n \. j s / ) ;
32
39
}
33
40
}
0 commit comments