-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix e2e to rely on the bootstrapping call instead of the method…
… to be present in the bundle
- Loading branch information
Showing
1 changed file
with
29 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,37 @@ | ||
import {join} from 'path'; | ||
import {readdirSync} from 'fs'; | ||
import {expectFileToExist, expectFileToMatch} from '../../utils/fs'; | ||
import {ng} from '../../utils/process'; | ||
import {expectGitToBeClean} from '../../utils/git'; | ||
import { readdirSync } from 'fs'; | ||
import { join } from 'path'; | ||
import { getGlobalVariable } from '../../utils/env'; | ||
import { expectFileToExist, expectFileToMatch } from '../../utils/fs'; | ||
import { expectGitToBeClean } from '../../utils/git'; | ||
import { ng } from '../../utils/process'; | ||
|
||
|
||
export default function() { | ||
export default async function () { | ||
// TODO(architect): Delete this test. It is now in devkit/build-angular. | ||
|
||
// Can't use the `ng` helper because somewhere the environment gets | ||
// stuck to the first build done | ||
return ng('build', '--prod') | ||
.then(() => expectFileToExist(join(process.cwd(), 'dist'))) | ||
// Check for cache busting hash script src | ||
.then(() => expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/)) | ||
.then(() => expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/)) | ||
.then(() => expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.css/)) | ||
.then(() => expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/)) | ||
// Defaults to AoT | ||
.then(() => { | ||
const mainES5 = readdirSync('./dist/test-project').find(name => !!name.match(/main-es5.[a-z0-9]+\.js/)); | ||
expectFileToMatch(`dist/test-project/${mainES5}`, /bootstrapModuleFactory\(/); | ||
const argv = getGlobalVariable('argv'); | ||
const ivyProject = argv['ivy']; | ||
const bootstrapRegExp = ivyProject | ||
? /bootstrapModule\([a-zA-Z]+\)\./ | ||
: /bootstrapModuleFactory\([a-zA-Z]+\)\./; | ||
|
||
const mainES2015 = readdirSync('./dist/test-project').find(name => !!name.match(/main-es2015.[a-z0-9]+\.js/)); | ||
expectFileToMatch(`dist/test-project/${mainES5}`, /bootstrapModuleFactory\(/); | ||
}) | ||
// Check that the process didn't change local files. | ||
.then(() => expectGitToBeClean()); | ||
await ng('build', '--prod'); | ||
await expectFileToExist(join(process.cwd(), 'dist')); | ||
// Check for cache busting hash script src | ||
await expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/); | ||
await expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/); | ||
await expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.css/); | ||
await expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/); | ||
|
||
const dirContents = readdirSync('./dist/test-project'); | ||
const mainES5 = dirContents.find(name => /main-es5.[a-z0-9]+\.js/.test(name)); | ||
await expectFileToMatch(`dist/test-project/${mainES5}`, bootstrapRegExp); | ||
|
||
const mainES2015 = dirContents.find(name => /main-es2015.[a-z0-9]+\.js/.test(name)); | ||
await expectFileToMatch(`dist/test-project/${mainES2015}`, bootstrapRegExp); | ||
|
||
// Check that the process didn't change local files. | ||
await expectGitToBeClean(); | ||
} |