Skip to content

Commit a8b0337

Browse files
Alan Agiusalexeagle
Alan Agius
authored andcommitted
test: fix e2e to rely on the bootstrapping call instead of the method to be present in the bundle
1 parent 8219380 commit a8b0337

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed
+29-22
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
import {join} from 'path';
2-
import {readdirSync} from 'fs';
3-
import {expectFileToExist, expectFileToMatch} from '../../utils/fs';
4-
import {ng} from '../../utils/process';
5-
import {expectGitToBeClean} from '../../utils/git';
1+
import { readdirSync } from 'fs';
2+
import { join } from 'path';
3+
import { getGlobalVariable } from '../../utils/env';
4+
import { expectFileToExist, expectFileToMatch } from '../../utils/fs';
5+
import { expectGitToBeClean } from '../../utils/git';
6+
import { ng } from '../../utils/process';
67

78

8-
export default function() {
9+
export default async function () {
910
// TODO(architect): Delete this test. It is now in devkit/build-angular.
1011

1112
// Can't use the `ng` helper because somewhere the environment gets
1213
// stuck to the first build done
13-
return ng('build', '--prod')
14-
.then(() => expectFileToExist(join(process.cwd(), 'dist')))
15-
// Check for cache busting hash script src
16-
.then(() => expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/))
17-
.then(() => expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/))
18-
.then(() => expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.css/))
19-
.then(() => expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/))
20-
// Defaults to AoT
21-
.then(() => {
22-
const mainES5 = readdirSync('./dist/test-project').find(name => !!name.match(/main-es5.[a-z0-9]+\.js/));
23-
expectFileToMatch(`dist/test-project/${mainES5}`, /bootstrapModuleFactory\(/);
14+
const argv = getGlobalVariable('argv');
15+
const ivyProject = argv['ivy'];
16+
const bootstrapRegExp = ivyProject
17+
? /bootstrapModule\([a-zA-Z]+\)\./
18+
: /bootstrapModuleFactory\([a-zA-Z]+\)\./;
2419

25-
const mainES2015 = readdirSync('./dist/test-project').find(name => !!name.match(/main-es2015.[a-z0-9]+\.js/));
26-
expectFileToMatch(`dist/test-project/${mainES5}`, /bootstrapModuleFactory\(/);
27-
})
28-
// Check that the process didn't change local files.
29-
.then(() => expectGitToBeClean());
20+
await ng('build', '--prod');
21+
await expectFileToExist(join(process.cwd(), 'dist'));
22+
// Check for cache busting hash script src
23+
await expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/);
24+
await expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/);
25+
await expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.css/);
26+
await expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/);
27+
28+
const dirContents = readdirSync('./dist/test-project');
29+
const mainES5 = dirContents.find(name => /main-es5.[a-z0-9]+\.js/.test(name));
30+
await expectFileToMatch(`dist/test-project/${mainES5}`, bootstrapRegExp);
31+
32+
const mainES2015 = dirContents.find(name => /main-es2015.[a-z0-9]+\.js/.test(name));
33+
await expectFileToMatch(`dist/test-project/${mainES2015}`, bootstrapRegExp);
34+
35+
// Check that the process didn't change local files.
36+
await expectGitToBeClean();
3037
}

0 commit comments

Comments
 (0)