mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
test: remove all references to eject from CLI E2E tests
This commit is contained in:
parent
f58a7ded00
commit
31abb81482
@ -8,7 +8,6 @@ import {
|
|||||||
import { ng } from '../../utils/process';
|
import { ng } from '../../utils/process';
|
||||||
import { updateJsonFile } from '../../utils/project';
|
import { updateJsonFile } from '../../utils/project';
|
||||||
import { expectToFail } from '../../utils/utils';
|
import { expectToFail } from '../../utils/utils';
|
||||||
import {getGlobalVariable} from '../../utils/env';
|
|
||||||
|
|
||||||
|
|
||||||
// const temp = require('temp');
|
// const temp = require('temp');
|
||||||
@ -17,7 +16,6 @@ import {getGlobalVariable} from '../../utils/env';
|
|||||||
// tslint:disable:max-line-length
|
// tslint:disable:max-line-length
|
||||||
export default function () {
|
export default function () {
|
||||||
// Disable parts of it in webpack tests.
|
// Disable parts of it in webpack tests.
|
||||||
const ejected = getGlobalVariable('argv').eject;
|
|
||||||
|
|
||||||
// TODO: update test
|
// TODO: update test
|
||||||
return;
|
return;
|
||||||
@ -110,7 +108,7 @@ export default function () {
|
|||||||
// .gitkeep shouldn't be copied.
|
// .gitkeep shouldn't be copied.
|
||||||
.then(() => expectToFail(() => expectFileToExist('dist/assets/.gitkeep')))
|
.then(() => expectToFail(() => expectFileToExist('dist/assets/.gitkeep')))
|
||||||
// Update app to test assets are present.
|
// Update app to test assets are present.
|
||||||
.then(_ => !ejected && writeMultipleFiles({
|
.then(_ => writeMultipleFiles({
|
||||||
'src/app/app.module.ts': `
|
'src/app/app.module.ts': `
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
@ -191,6 +189,6 @@ export default function () {
|
|||||||
});
|
});
|
||||||
});`,
|
});`,
|
||||||
}))
|
}))
|
||||||
.then(() => !ejected && ng('test', '--watch=false'))
|
.then(() => ng('test', '--watch=false'))
|
||||||
.then(() => !ejected && ng('e2e', 'test-project-e2e'));
|
.then(() => ng('e2e', 'test-project-e2e'));
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import {
|
|||||||
import {writeFile, writeMultipleFiles} from '../../utils/fs';
|
import {writeFile, writeMultipleFiles} from '../../utils/fs';
|
||||||
import {wait} from '../../utils/utils';
|
import {wait} from '../../utils/utils';
|
||||||
import {request} from '../../utils/http';
|
import {request} from '../../utils/http';
|
||||||
import {getGlobalVariable} from '../../utils/env';
|
|
||||||
|
|
||||||
const validBundleRegEx = /: Compiled successfully./;
|
const validBundleRegEx = /: Compiled successfully./;
|
||||||
|
|
||||||
@ -15,10 +14,6 @@ export default function() {
|
|||||||
if (process.platform.startsWith('win')) {
|
if (process.platform.startsWith('win')) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const lazyChunkRegExp = /lazy-module\.js/g;
|
const lazyChunkRegExp = /lazy-module\.js/g;
|
||||||
|
|
||||||
|
@ -7,11 +7,6 @@ import { readNgVersion } from '../../utils/version';
|
|||||||
|
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip this test in Angular 2/4.
|
// Skip this test in Angular 2/4.
|
||||||
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
@ -8,11 +8,6 @@ import { stripIndent } from 'common-tags';
|
|||||||
|
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip this test in Angular 2/4.
|
// Skip this test in Angular 2/4.
|
||||||
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
@ -19,11 +19,6 @@ export default function () {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip this test in Angular 2/4.
|
// Skip this test in Angular 2/4.
|
||||||
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
@ -6,11 +6,6 @@ import {getGlobalVariable} from '../../utils/env';
|
|||||||
export default function() {
|
export default function() {
|
||||||
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
||||||
|
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ng('build')
|
return ng('build')
|
||||||
// This is supposed to fail since there's a missing file
|
// This is supposed to fail since there's a missing file
|
||||||
.then(() => deleteFile('src/app/app.component.ts'))
|
.then(() => deleteFile('src/app/app.component.ts'))
|
||||||
|
@ -27,8 +27,6 @@ export default function () {
|
|||||||
/__webpack_require__\.p = "deployUrl\/";/));
|
/__webpack_require__\.p = "deployUrl\/";/));
|
||||||
// // verify slash is appended to the end of --deploy-url if missing
|
// // verify slash is appended to the end of --deploy-url if missing
|
||||||
// .then(() => ng('build', '--deploy-url=deployUrl', '--extract-css=false'))
|
// .then(() => ng('build', '--deploy-url=deployUrl', '--extract-css=false'))
|
||||||
// // skip this in ejected tests
|
// .then(() =>
|
||||||
// .then(() => getGlobalVariable('argv').eject
|
// expectFileToMatch('dist/test-project/untime.js', /__webpack_require__\.p = "deployUrl\/";/));
|
||||||
// ? Promise.resolve()
|
|
||||||
// : expectFileToMatch('dist/test-project/untime.js', /__webpack_require__\.p = "deployUrl\/";/));
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
import {execAndWaitForOutputToMatch, killAllProcesses} from '../../utils/process';
|
import {execAndWaitForOutputToMatch, killAllProcesses} from '../../utils/process';
|
||||||
import {getGlobalVariable} from '../../utils/env';
|
|
||||||
|
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
// TODO(architect): Dev-server does not yet do this. Fix, reenable, validate, then delete this test.
|
// TODO(architect): Dev-server does not yet do this. Fix, reenable, validate, then delete this test.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
// Check that ng serve has eval sourcemaps by default.
|
// Check that ng serve has eval sourcemaps by default.
|
||||||
.then(() => execAndWaitForOutputToMatch('ng', ['serve'], /: Compiled successfully/))
|
.then(() => execAndWaitForOutputToMatch('ng', ['serve'], /: Compiled successfully/))
|
||||||
|
@ -7,11 +7,6 @@ import {getGlobalVariable} from '../../utils/env';
|
|||||||
export default function() {
|
export default function() {
|
||||||
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
||||||
|
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ng('build', '--stats-json')
|
return ng('build', '--stats-json')
|
||||||
.then(() => expectFileToExist('./dist/test-project/stats.json'))
|
.then(() => expectFileToExist('./dist/test-project/stats.json'))
|
||||||
.then(() => expectGitToBeClean());
|
.then(() => expectGitToBeClean());
|
||||||
|
@ -9,11 +9,6 @@ import {expectToFail} from '../../utils/utils';
|
|||||||
export default function() {
|
export default function() {
|
||||||
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
||||||
|
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ng('build', '--output-path', 'build-output')
|
return ng('build', '--output-path', 'build-output')
|
||||||
.then(() => expectFileToExist('./build-output/index.html'))
|
.then(() => expectFileToExist('./build-output/index.html'))
|
||||||
.then(() => expectFileToExist('./build-output/main.js'))
|
.then(() => expectFileToExist('./build-output/main.js'))
|
||||||
|
@ -14,11 +14,6 @@ import { readNgVersion } from '../../utils/version';
|
|||||||
import { expectToFail } from '../../utils/utils';
|
import { expectToFail } from '../../utils/utils';
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
// Skip this for ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
let platformServerVersion = readNgVersion();
|
let platformServerVersion = readNgVersion();
|
||||||
let httpVersion = readNgVersion();
|
let httpVersion = readNgVersion();
|
||||||
|
|
||||||
|
@ -9,9 +9,6 @@ import {getGlobalVariable} from '../../utils/env';
|
|||||||
export default function() {
|
export default function() {
|
||||||
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
||||||
|
|
||||||
// Skip this in ejected tests.
|
|
||||||
const ejected = getGlobalVariable('argv').eject;
|
|
||||||
|
|
||||||
// Can't use the `ng` helper because somewhere the environment gets
|
// Can't use the `ng` helper because somewhere the environment gets
|
||||||
// stuck to the first build done
|
// stuck to the first build done
|
||||||
return ng('build', '--prod')
|
return ng('build', '--prod')
|
||||||
@ -26,5 +23,5 @@ export default function() {
|
|||||||
expectFileToMatch(`dist/test-project/${main}`, /bootstrapModuleFactory\(/);
|
expectFileToMatch(`dist/test-project/${main}`, /bootstrapModuleFactory\(/);
|
||||||
})
|
})
|
||||||
// Check that the process didn't change local files.
|
// Check that the process didn't change local files.
|
||||||
.then(() => !ejected && expectGitToBeClean());
|
.then(() => expectGitToBeClean());
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,6 @@ export default function() {
|
|||||||
if (process.platform.startsWith('win')) {
|
if (process.platform.startsWith('win')) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return execAndWaitForOutputToMatch('ng', ['serve'], webpackGoodRegEx)
|
return execAndWaitForOutputToMatch('ng', ['serve'], webpackGoodRegEx)
|
||||||
// Should trigger a rebuild.
|
// Should trigger a rebuild.
|
||||||
|
@ -18,10 +18,6 @@ export default function() {
|
|||||||
if (process.platform.startsWith('win')) {
|
if (process.platform.startsWith('win')) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
// Create and import files.
|
// Create and import files.
|
||||||
|
@ -25,10 +25,6 @@ export default function () {
|
|||||||
if (process.platform.startsWith('win')) {
|
if (process.platform.startsWith('win')) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip this test in Angular 2/4.
|
// Skip this test in Angular 2/4.
|
||||||
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
||||||
|
@ -16,10 +16,6 @@ export default function () {
|
|||||||
if (process.platform.startsWith('win')) {
|
if (process.platform.startsWith('win')) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip this test in Angular 2/4.
|
// Skip this test in Angular 2/4.
|
||||||
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
if (getGlobalVariable('argv').ng2 || getGlobalVariable('argv').ng4) {
|
||||||
|
@ -15,10 +15,6 @@ export default async function() {
|
|||||||
if (process.platform.startsWith('win')) {
|
if (process.platform.startsWith('win')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await writeFile('src/app/type.ts', `export type MyType = number;`);
|
await writeFile('src/app/type.ts', `export type MyType = number;`);
|
||||||
await prependToFile('src/app/app.component.ts', 'import { MyType } from "./type";\n');
|
await prependToFile('src/app/app.component.ts', 'import { MyType } from "./type";\n');
|
||||||
|
@ -23,11 +23,6 @@ const MANIFEST = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
// Skip this in ejected tests.
|
|
||||||
if (getGlobalVariable('argv').eject) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can't use the `ng` helper because somewhere the environment gets
|
// Can't use the `ng` helper because somewhere the environment gets
|
||||||
// stuck to the first build done
|
// stuck to the first build done
|
||||||
return silentNpm('remove', '@angular/service-worker')
|
return silentNpm('remove', '@angular/service-worker')
|
||||||
@ -46,12 +41,4 @@ export default function() {
|
|||||||
.then(() => ng('build', '--optimization'))
|
.then(() => ng('build', '--optimization'))
|
||||||
.then(() => expectFileToExist('dist/test-project/safety-worker.js'))
|
.then(() => expectFileToExist('dist/test-project/safety-worker.js'))
|
||||||
.then(() => expectFileToExist('dist/test-project/worker-basic.min.js'));
|
.then(() => expectFileToExist('dist/test-project/worker-basic.min.js'));
|
||||||
// WEBPACK4_DISABLED - eject temporarily disabled for webpack 4 integration
|
|
||||||
// .then(() => ng('eject', '--prod'))
|
|
||||||
// .then(() => silentNpm('install'))
|
|
||||||
// .then(() => npm('run', 'build'))
|
|
||||||
// .then(() => expectFileToMatch('package.json', /"sw-config"/))
|
|
||||||
// .then(() => expectFileToExist(join(process.cwd(), 'dist/ngsw-worker.js')))
|
|
||||||
// .then(() => expectFileToExist(join(process.cwd(), 'dist/ngsw.json')))
|
|
||||||
// .then(() => ng('set', 'apps.0.serviceWorker=false'));
|
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,6 @@ import { getGlobalVariable } from '../../../utils/env';
|
|||||||
export default function () {
|
export default function () {
|
||||||
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
||||||
|
|
||||||
// Disable parts of it in webpack tests.
|
|
||||||
const ejected = getGlobalVariable('argv').eject;
|
|
||||||
|
|
||||||
const extensions = ['css', 'scss', 'less', 'styl'];
|
const extensions = ['css', 'scss', 'less', 'styl'];
|
||||||
let promise = Promise.resolve();
|
let promise = Promise.resolve();
|
||||||
|
|
||||||
@ -64,7 +61,7 @@ export default function () {
|
|||||||
.then(() => expectFileToMatch('dist/test-project/main.js',
|
.then(() => expectFileToMatch('dist/test-project/main.js',
|
||||||
/h1.*background:\s*#000+/))
|
/h1.*background:\s*#000+/))
|
||||||
// Also check imports work on ng test
|
// Also check imports work on ng test
|
||||||
.then(() => !ejected && ng('test', '--watch=false'))
|
.then(() => ng('test', '--watch=false'))
|
||||||
.then(() => updateJsonFile('angular.json', workspaceJson => {
|
.then(() => updateJsonFile('angular.json', workspaceJson => {
|
||||||
const appArchitect = workspaceJson.projects['test-project'].architect;
|
const appArchitect = workspaceJson.projects['test-project'].architect;
|
||||||
appArchitect.build.options.styles = [
|
appArchitect.build.options.styles = [
|
||||||
|
@ -12,6 +12,5 @@ export default function() {
|
|||||||
appArchitect.build.options.outputPath = './';
|
appArchitect.build.options.outputPath = './';
|
||||||
}))
|
}))
|
||||||
.then(() => expectToFail(() => ng('build')))
|
.then(() => expectToFail(() => ng('build')))
|
||||||
.then(() => expectToFail(() => ng('serve')))
|
.then(() => expectToFail(() => ng('serve')));
|
||||||
.then(() => expectToFail(() => ng('eject')));
|
|
||||||
}
|
}
|
||||||
|
@ -181,24 +181,11 @@ export function execAndWaitForOutputToMatch(cmd: string, args: string[], match:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let npmInstalledEject = false;
|
|
||||||
export function ng(...args: string[]) {
|
export function ng(...args: string[]) {
|
||||||
const argv = getGlobalVariable('argv');
|
const argv = getGlobalVariable('argv');
|
||||||
const maybeSilentNg = argv['nosilent'] ? noSilentNg : silentNg;
|
const maybeSilentNg = argv['nosilent'] ? noSilentNg : silentNg;
|
||||||
if (['build', 'serve', 'test', 'e2e', 'xi18n'].indexOf(args[0]) != -1) {
|
if (['build', 'serve', 'test', 'e2e', 'xi18n'].indexOf(args[0]) != -1) {
|
||||||
// If we have the --eject, use webpack for the test.
|
if (args[0] == 'e2e') {
|
||||||
if (args[0] == 'build' && argv.eject) {
|
|
||||||
return maybeSilentNg('eject', ...args.slice(1), '--force')
|
|
||||||
.then(() => {
|
|
||||||
if (!npmInstalledEject) {
|
|
||||||
npmInstalledEject = true;
|
|
||||||
// We need to delete node_modules, then run npm install on the first eject.
|
|
||||||
return rimraf('node_modules').then(() => silentNpm('install'));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(() => rimraf('dist'))
|
|
||||||
.then(() => _exec({silent: true}, 'node_modules/.bin/webpack', []));
|
|
||||||
} else if (args[0] == 'e2e') {
|
|
||||||
// Wait 1 second before running any end-to-end test.
|
// Wait 1 second before running any end-to-end test.
|
||||||
return new Promise(resolve => setTimeout(resolve, 1000))
|
return new Promise(resolve => setTimeout(resolve, 1000))
|
||||||
.then(() => maybeSilentNg(...args));
|
.then(() => maybeSilentNg(...args));
|
||||||
|
@ -46,7 +46,6 @@ const argv = minimist(process.argv.slice(2), {
|
|||||||
'boolean': [
|
'boolean': [
|
||||||
'appveyor',
|
'appveyor',
|
||||||
'debug',
|
'debug',
|
||||||
'eject',
|
|
||||||
'ng-snapshots',
|
'ng-snapshots',
|
||||||
'noglobal',
|
'noglobal',
|
||||||
'nosilent',
|
'nosilent',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user