File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ import { ng } from '../../utils/process' ;
2+ import { applyWtrBuilder } from '../../utils/web-test-runner' ;
3+
4+ export default async function ( ) {
5+ await applyWtrBuilder ( ) ;
6+
7+ const { stderr } = await ng ( 'test' ) ;
8+
9+ if ( ! stderr . includes ( 'Web Test Runner builder is currently EXPERIMENTAL' ) ) {
10+ throw new Error ( `No experimental notice in stderr.\nSTDERR:\n\n${ stderr } ` ) ;
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ import { silentNpm } from './process' ;
2+ import { updateJsonFile } from './project' ;
3+
4+ /** Updates the `test` builder in the current workspace to use Web Test Runner with the given options. */
5+ export async function applyWtrBuilder ( ) : Promise < void > {
6+ await silentNpm ( 'install' , '@web/test-runner' , '--save-dev' ) ;
7+
8+ await updateJsonFile ( 'angular.json' , ( json ) => {
9+ const projects = Object . values ( json [ 'projects' ] ) ;
10+ if ( projects . length !== 1 ) {
11+ throw new Error (
12+ `Expected exactly one project but found ${ projects . length } projects named ${ Object . keys (
13+ json [ 'projects' ] ,
14+ ) . join ( ', ' ) } `,
15+ ) ;
16+ }
17+ const project = projects [ 0 ] ! as any ;
18+
19+ // Update to Web Test Runner builder.
20+ const test = project [ 'architect' ] [ 'test' ] ;
21+ test [ 'builder' ] = '@angular-devkit/build-angular:web-test-runner' ;
22+ } ) ;
23+ }
You can’t perform that action at this time.
0 commit comments