Skip to content

Commit

Permalink
test: re-enable build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed Mar 26, 2018
1 parent d1b22d0 commit 2bf6838
Show file tree
Hide file tree
Showing 24 changed files with 158 additions and 186 deletions.
84 changes: 41 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
},
"homepage": "https://github.com/angular/angular-cli",
"dependencies": {
"@angular-devkit/architect": "angular/angular-devkit-architect-builds#caf9a5e",
"@angular-devkit/build-webpack": "angular/angular-devkit-build-webpack-builds#caf9a5e",
"@angular-devkit/core": "angular/angular-devkit-core-builds#caf9a5e",
"@angular-devkit/schematics": "angular/angular-devkit-schematics-builds#caf9a5e",
"@schematics/angular": "angular/schematics-angular-builds#caf9a5e",
"@schematics/package-update": "angular/schematics-package-update-builds#caf9a5e",
"@angular-devkit/architect": "angular/angular-devkit-architect-builds#da7fe5e",
"@angular-devkit/build-webpack": "angular/angular-devkit-build-webpack-builds#da7fe5e",
"@angular-devkit/core": "angular/angular-devkit-core-builds#da7fe5e",
"@angular-devkit/schematics": "angular/angular-devkit-schematics-builds#da7fe5e",
"@schematics/angular": "angular/schematics-angular-builds#da7fe5e",
"@schematics/package-update": "angular/schematics-package-update-builds#da7fe5e",
"ajv": "^6.1.1",
"chalk": "~2.2.0",
"common-tags": "^1.3.1",
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class BuildCommand extends ArchitectCommand {

const overrides = { ...options };
delete overrides.project;
delete overrides.configuration;
delete overrides.prod;

return this.runArchitectTarget({
Expand Down
3 changes: 2 additions & 1 deletion packages/@angular/cli/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ export default class ServeCommand extends ArchitectCommand {

public async run(options: Options) {
let configuration = options.configuration;
if (options.prod) {
if (!configuration && options.prod) {
configuration = 'production';
}

const overrides = { ...options };
delete overrides.project;
delete overrides.configuration;
delete overrides.prod;

return this.runArchitectTarget({
Expand Down
11 changes: 10 additions & 1 deletion packages/@angular/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ArchitectCommand } from '../models/architect-command';
export interface Options {
project?: string;
configuration?: string;
prod: boolean;
}

export default class TestCommand extends ArchitectCommand {
Expand All @@ -18,12 +19,20 @@ export default class TestCommand extends ArchitectCommand {
];

public async run(options: Options) {
let configuration = options.configuration;
if (!configuration && options.prod) {
configuration = 'production';
}

const overrides = { ...options };
delete overrides.project;
delete overrides.configuration;
delete overrides.prod;

return this.runArchitectTarget({
project: options.project,
target: this.target,
configuration: options.configuration,
configuration,
overrides
});
}
Expand Down
12 changes: 6 additions & 6 deletions packages/@angular/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
},
"homepage": "https://github.com/angular/angular-cli",
"dependencies": {
"@angular-devkit/architect": "angular/angular-devkit-architect-builds#caf9a5e",
"@angular-devkit/build-webpack": "angular/angular-devkit-build-webpack-builds#caf9a5e",
"@angular-devkit/core": "angular/angular-devkit-core-builds#caf9a5e",
"@angular-devkit/schematics": "angular/angular-devkit-schematics-builds#caf9a5e",
"@angular-devkit/architect": "angular/angular-devkit-architect-builds#da7fe5e",
"@angular-devkit/build-webpack": "angular/angular-devkit-build-webpack-builds#da7fe5e",
"@angular-devkit/core": "angular/angular-devkit-core-builds#da7fe5e",
"@angular-devkit/schematics": "angular/angular-devkit-schematics-builds#da7fe5e",
"@ngtools/json-schema": "1.2.0",
"@schematics/angular": "angular/schematics-angular-builds#caf9a5e",
"@schematics/package-update": "angular/schematics-package-update-builds#caf9a5e",
"@schematics/angular": "angular/schematics-angular-builds#da7fe5e",
"@schematics/package-update": "angular/schematics-package-update-builds#da7fe5e",
"ajv": "^6.1.1",
"chalk": "~2.2.0",
"common-tags": "^1.3.1",
Expand Down
35 changes: 19 additions & 16 deletions tests/e2e/tests/basic/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,34 @@ export default function () {
// These should work.
.then(() => ng('e2e', 'test-project-e2e'))
.then(() => ng('e2e', 'test-project-e2e', '--devServerTarget=test-project:serve:production'))
// TODO(architect): disabled until arg coercion is added.
// Should use port in baseUrl
// .then(() => ng('e2e', 'test-project-e2e', '--port', '4400'))
// Should accept different config file
.then(() => moveFile('./protractor.conf.js', './renamed-protractor.conf.js'))
.then(() => ng('e2e', 'test-project-e2e', '--protractorConfig=renamed-protractor.conf.js'))
.then(() => moveFile('./renamed-protractor.conf.js', './protractor.conf.js'))
// TODO(architect): disabled until arg coercion is added.
.then(() => moveFile('./projects/test-project-e2e/protractor.conf.js',
'./projects/test-project-e2e/renamed-protractor.conf.js'))
.then(() => ng('e2e', 'test-project-e2e',
'--protractorConfig=projects/test-project-e2e/renamed-protractor.conf.js'))
.then(() => moveFile('./projects/test-project-e2e/renamed-protractor.conf.js', './projects/test-project-e2e/protractor.conf.js'))
// Should accept different multiple spec files
// .then(() => moveFile('./e2e/app.e2e-spec.ts', './e2e/renamed-app.e2e-spec.ts'))
// .then(() => copyFile('./e2e/renamed-app.e2e-spec.ts', './e2e/another-app.e2e-spec.ts'))
// .then(() => ng('e2e', 'test-project-e2e', '--specs', './e2e/renamed-app.e2e-spec.ts',
// '--specs', './e2e/another-app.e2e-spec.ts'))
.then(() => moveFile('./projects/test-project-e2e/src/app.e2e-spec.ts',
'./projects/test-project-e2e/src/renamed-app.e2e-spec.ts'))
.then(() => copyFile('./projects/test-project-e2e/src/renamed-app.e2e-spec.ts',
'./projects/test-project-e2e/src/another-app.e2e-spec.ts'))
.then(() => ng('e2e', 'test-project-e2e', '--specs', './e2e/renamed-app.e2e-spec.ts',
'--specs', './e2e/another-app.e2e-spec.ts'))
// Rename the spec back to how it was.
.then(() => moveFile('./projects/test-project-e2e/src/renamed-app.e2e-spec.ts',
'./projects/test-project-e2e/src/app.e2e-spec.ts'))
// Suites block need to be added in the protractor.conf.js file to test suites
.then(() => replaceInFile('protractor.conf.js', `allScriptsTimeout: 11000,`,
.then(() => replaceInFile('projects/test-project-e2e/protractor.conf.js', `allScriptsTimeout: 11000,`,
`allScriptsTimeout: 11000,
suites: {
app: './e2e/app.e2e-spec.ts'
app: './projects/test-project-e2e/src/app.e2e-spec.ts'
},
`))
.then(() => ng('e2e', 'test-project-e2e', '--suite=app'))
// remove suites block from protractor.conf.js file after testing suites
.then(() => replaceInFile('projects/test/project-e2e/protractor.conf.js', `allScriptsTimeout: 11000,
// Remove suites block from protractor.conf.js file after testing suites
.then(() => replaceInFile('projects/test-project-e2e/protractor.conf.js', `allScriptsTimeout: 11000,
suites: {
app: './e2e/app.e2e-spec.ts'
app: './projects/test-project-e2e/src/app.e2e-spec.ts'
},
`, `allScriptsTimeout: 11000,`
))
Expand Down
8 changes: 3 additions & 5 deletions tests/e2e/tests/build/css-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ const imgSvg = `
`;

export default function () {
// TODO(architect): Delete this test. It is now in devkit/build-webpack.

return Promise.resolve()
// Verify absolute/relative paths in global/component css.
.then(() => writeMultipleFiles({
Expand All @@ -32,11 +30,11 @@ export default function () {
'projects/test-project/src/assets/component-img-absolute.svg': imgSvg
}))
// use image with file size >10KB to prevent inlining
.then(() => copyProjectAsset('images/spectrum.png', './projects/test-project/assets/global-img-relative.png'))
.then(() => copyProjectAsset('images/spectrum.png', './projects/test-project/assets/component-img-relative.png'))
.then(() => copyProjectAsset('images/spectrum.png', './projects/test-project/src/assets/global-img-relative.png'))
.then(() => copyProjectAsset('images/spectrum.png', './projects/test-project/src/assets/component-img-relative.png'))
.then(() => ng('build', '--extract-css', '--aot'))
// Check paths are correctly generated.
.then(() => expectFileToMatch('dist/test-project/styles.css', 'projects/test-project/assets/global-img-absolute.svg'))
.then(() => expectFileToMatch('dist/test-project/styles.css', 'assets/global-img-absolute.svg'))
.then(() => expectFileToMatch('dist/test-project/styles.css',
/url\('\/assets\/global-img-absolute\.svg'\)/))
.then(() => expectFileToMatch('dist/test-project/styles.css',
Expand Down
6 changes: 2 additions & 4 deletions tests/e2e/tests/build/deploy-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import { getGlobalVariable } from '../../utils/env';


export default function () {
// TODO(architect): Delete this test. It is now in devkit/build-webpack.

return Promise.resolve()
.then(() => writeMultipleFiles({
'projects/test-project/src/styles.css': 'div { background: url("./assets/more.png"); }',
}))
// use image with file size >10KB to prevent inlining
.then(() => copyProjectAsset('images/spectrum.png', './assets/more.png'))
.then(() => copyProjectAsset('images/spectrum.png', './projects/test-project/src/assets/more.png'))
.then(() => ng('build', '--deploy-url=deployUrl/', '--extract-css'))
.then(() => expectFileToMatch('dist/test-project/index.html', 'deployUrl/main.js'))
// verify --deploy-url isn't applied to extracted css urls
Expand All @@ -23,7 +21,7 @@ export default function () {
.then(() => expectFileToMatch('dist/test-project/index.html', 'http://example.com/some/path/main.js'))
// verify --deploy-url is applied to non-extracted css urls
.then(() => ng('build', '--deploy-url=deployUrl/', '--extract-css=false'))
.then(() => expectFileToMatch('dist/test-project/tyles.js',
.then(() => expectFileToMatch('dist/test-project/styles.js',
/\(['"]?deployUrl\/more\.png['"]?\)/))
.then(() => expectFileToMatch('dist/test-project/runtime.js',
/__webpack_require__\.p = "deployUrl\/";/));
Expand Down
31 changes: 15 additions & 16 deletions tests/e2e/tests/build/environment.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import {ng} from '../../utils/process';
import {expectFileToMatch} from '../../utils/fs';
import {expectGitToBeClean} from '../../utils/git';
import {expectToFail} from '../../utils/utils';
import {getGlobalVariable} from '../../utils/env';
import { updateJsonFile } from '../../utils/project';


export default function() {
// Disable parts of it in webpack tests.
const ejected = getGlobalVariable('argv').eject;

// Try a prod build.
return ng('build', '--environment=prod')
.then(() => expectFileToMatch('dist/test-project/main.js', 'production: true'))
// If this is an ejected test, the eject will create files so git will not be clean.
.then(() => !ejected && expectGitToBeClean())

// Build fails on invalid build target
.then(() => expectToFail(() => ng('build', '--target=potato')))

// This is a valid target.
.then(() => ng('build', '--target=production'));
return Promise.resolve()
.then(() => updateJsonFile('angular.json', configJson => {
const appArchitect = configJson.projects['test-project'].architect;
appArchitect.build.configurations['prod-env'] = {
fileReplacements: [
{
from: 'projects/test-project/src/environments/environment.ts',
to: 'projects/test-project/src/environments/environment.prod.ts'
}
],
};
}))
.then(() => ng('build', '--configuration=prod-env'))
.then(() => expectFileToMatch('dist/test-project/main.js', 'production: true'));
}

0 comments on commit 2bf6838

Please sign in to comment.