1+ import assert from 'node:assert' ;
2+ import { getGlobalVariable } from '../../utils/env' ;
13import { writeFile } from '../../utils/fs' ;
24import { ng } from '../../utils/process' ;
5+ import { assertIsError } from '../../utils/utils' ;
36
47export default async function ( ) {
8+ if ( getGlobalVariable ( 'argv' ) [ 'esbuild' ] ) {
9+ // TODO: enable once this is fixed when using the esbuild builder.
10+ return ;
11+ }
12+
513 await writeFile (
614 'src/app/app.component.spec.ts' ,
715 `
8- it('show fail', () => {
16+ it('should fail', () => {
917 expect(undefined).toBeTruthy();
1018 });
1119 ` ,
@@ -16,18 +24,17 @@ export default async function () {
1624 await ng ( 'test' , '--no-watch' , '--source-map' ) ;
1725 throw new Error ( 'ng test should have failed.' ) ;
1826 } 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 _ / ) ;
2230 }
2331
2432 // when sourcemaps are 'off' the stacktrace won't point to the spec.ts file.
2533 try {
2634 await ng ( 'test' , '--no-watch' , '--no-source-map' ) ;
2735 throw new Error ( 'ng test should have failed.' ) ;
2836 } 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 / ) ;
3239 }
3340}
0 commit comments