test: update Ivy tests as per new workspace settings

This commit is contained in:
Alan 2019-08-13 08:04:58 +02:00 committed by Keen Yee Liau
parent beb7070ac8
commit e8e6f8a6df
12 changed files with 43 additions and 30 deletions

View File

@ -10,8 +10,5 @@
],
"include": [
"**/*.d.ts"
],
"angularCompilerOptions": {
"enableIvy": true
}
]
}

View File

@ -10,7 +10,6 @@
"main.server.ts"
],
"angularCompilerOptions": {
"entryModule": "app/app.server.module#AppServerModule",
"enableIvy": true
"entryModule": "app/app.server.module#AppServerModule"
}
}

View File

@ -14,8 +14,5 @@
"include": [
"**/*.spec.ts",
"**/*.d.ts"
],
"angularCompilerOptions": {
"enableIvy": true
}
]
}

View File

@ -17,5 +17,8 @@
"es2017",
"dom"
]
},
"angularCompilerOptions": {
"enableIvy": true
}
}

View File

@ -17,5 +17,8 @@
"es2017",
"dom"
]
},
"angularCompilerOptions": {
"enableIvy": false
}
}

View File

@ -16,5 +16,8 @@
"es2017",
"dom"
]
},
"angularCompilerOptions": {
"enableIvy": false
}
}

View File

@ -3,7 +3,7 @@ import { getGlobalVariable } from '../utils/env';
import { expectFileToExist } from '../utils/fs';
import { gitClean } from '../utils/git';
import { ng } from '../utils/process';
import { prepareProjectForE2e } from '../utils/project';
import { prepareProjectForE2e, updateJsonFile } from '../utils/project';
export default async function() {
const argv = getGlobalVariable('argv');
@ -18,13 +18,20 @@ export default async function() {
} else {
const extraArgs = [];
if (argv['ivy']) {
extraArgs.push('--enable-ivy');
}
await ng('new', 'test-project', '--skip-install', ...extraArgs);
await expectFileToExist(join(process.cwd(), 'test-project'));
process.chdir('./test-project');
if (!argv['ivy']) {
await updateJsonFile('tsconfig.json', config => {
config.angularCompilerOptions.enableIvy = false;
});
// In VE non prod builds are non AOT by default
await updateJsonFile('angular.json', config => {
config.projects['test-project'].architect.build.options.aot = false;
});
}
}
await prepareProjectForE2e('test-project');

View File

@ -9,11 +9,8 @@ import { getGlobalVariable } from '../../utils/env';
import { appendToFile, prependToFile, readFile, replaceInFile, writeFile } from '../../utils/fs';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
export default async function () {
const argv = getGlobalVariable('argv');
const ivyProject = argv['ivy'];
const projectName = 'test-project';
const appRoutingModulePath = 'src/app/app-routing.module.ts';

View File

@ -3,8 +3,6 @@ import { ng } from '../../../utils/process';
export default async function () {
await ng('generate', 'library', 'my-lib');
await ng('build', 'my-lib');
await writeFile('./src/app/app.module.ts', `
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
@ -69,6 +67,18 @@ export default async function () {
});
`);
await runLibraryTests();
await runLibraryTests(true);
}
async function runLibraryTests(prodMode = false): Promise<void> {
const args = ['build', 'my-lib'];
if (prodMode) {
args.push('--prod');
}
await ng(...args);
// Check that the tests succeeds both with named project, unnammed (should test app), and prod.
await ng('e2e');
await ng('e2e', 'test-project', '--devServerTarget=test-project:serve:production');

View File

@ -5,19 +5,20 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { replaceInFile } from '../../utils/fs';
import { request } from '../../utils/http';
import { killAllProcesses, ng } from '../../utils/process';
import { createProject, ngServe } from '../../utils/project';
import { createProject, ngServe, updateJsonFile } from '../../utils/project';
export default async function() {
try {
await createProject('ivy-project-opt-out', '--enable-ivy');
await createProject('ivy-project-opt-out');
// trigger an Ivy builds to process packages with NGCC
await ng('e2e', '--prod');
// View Engine (NGC) compilation should work after running NGCC from Webpack
await replaceInFile('tsconfig.app.json', '"enableIvy": true', '"enableIvy": false');
await updateJsonFile('tsconfig.json', config => {
config.angularCompilerOptions.enableIvy = false;
});
// verify that VE compilation works during runtime
await ng('e2e', '--prod');

View File

@ -4,7 +4,7 @@ import { createProject } from '../../utils/project';
export default async function() {
// Create a new project to avoid polluting node modules for other tests
await createProject('ivy-project-ngcc', '--enable-ivy');
await createProject('ivy-project-ngcc');
const { stderr, stdout } = await ng('build', '--prod');

View File

@ -33,16 +33,12 @@ export function ngServe(...args: string[]) {
export async function createProject(name: string, ...args: string[]) {
const argv: string[] = getGlobalVariable('argv');
const extraArgs = [];
if (argv['ivy']) {
extraArgs.push('--enableIvy');
}
process.chdir(getGlobalVariable('tmp-root'));
await ng('new', name, '--skip-install', ...extraArgs, ...args);
process.chdir(name);
await prepareProjectForE2e(name);
}