Skip to content

Commit 40eddb3

Browse files
dgp1130alan-agius4
authored andcommitted
test: add initial e2e tests of Web Test Runner builder
1 parent bdd4f2c commit 40eddb3

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}

0 commit comments

Comments
 (0)