Skip to content

Commit 59225c7

Browse files
committed
bugfixes
1 parent 0176828 commit 59225c7

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

packages/@angular/cli/blueprints/ng2/files/angular-cli.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
"test": {
4747
"karma": {
4848
"config": "./karma.conf.js"
49-
}
49+
},
50+
"include": [
51+
"**/*.spec.ts",
52+
"test.ts"
53+
]
5054
},
5155
"defaults": {
5256
"styleExt": "<%= styleExt %>",

packages/@angular/cli/models/webpack-configs/typescript.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ function _createAotPlugin(wco: WebpackConfigOptions, options: any = {}) {
1919
const { appConfig, projectRoot, buildOptions } = wco;
2020

2121
// Exclude test files by default.
22-
options.exclude = CliConfig.fromProject().config.test.include;
22+
const testConfig = CliConfig.fromProject().config.test;
23+
options.exclude = (testConfig && testConfig.include) || [
24+
'**/*.spec.ts',
25+
'test.ts'
26+
];
2327

2428
// Read the environment, and set it in the compiler host.
2529
let hostReplacementPaths: any = {};

packages/@ngtools/webpack/src/plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class AotPlugin implements Tapable {
116116

117117
// Default excludes to **/*.spec.ts files.
118118
if (!options.hasOwnProperty('exclude')) {
119-
options.exclude = ['**/*.spec.ts'];
119+
options['exclude'] = ['**/*.spec.ts'];
120120
}
121121
tsConfigJson.exclude = (tsConfigJson.exclude || []).concat(options.exclude);
122122

tests/e2e/tests/build/aot/aot.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import {ng} from '../../../utils/process';
2-
import {expectFileToMatch, writeFile, createDir} from '../../../utils/fs';
2+
import {expectFileToMatch} from '../../../utils/fs';
33

44
export default function() {
55
return ng('build', '--aot')
66
.then(() => expectFileToMatch('dist/main.bundle.js',
7-
/bootstrapModuleFactory.*\/\* AppModuleNgFactory \*\//))
8-
// Check if **/*.spec.ts files are excluded by default. This import will cause aot to fail.
9-
.then(() => createDir('./src/much/deep/folder'))
10-
.then(() => writeFile('./src/much/deep/folder/unit-test.spec.ts', `
11-
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
12-
`))
13-
.then(() => ng('build', '--aot'));
7+
/bootstrapModuleFactory.*\/\* AppModuleNgFactory \*\//));;
148
}

tests/e2e/tests/build/aot/exclude.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { ng } from '../../../utils/process';
2+
import { writeFile } from '../../../utils/fs';
3+
import { updateJsonFile } from '../../../utils/project';
4+
5+
export default function () {
6+
// Check if **/*.spec.ts files are excluded by default.
7+
return Promise.resolve()
8+
.then(() => updateJsonFile('.angular-cli.json', configJson => {
9+
const test = configJson['test'];
10+
delete test['include'];
11+
}))
12+
// This import would cause aot to fail.
13+
.then(() => writeFile('src/app.component.spec.ts', `
14+
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
15+
`))
16+
.then(() => ng('build', '--aot'));
17+
}

0 commit comments

Comments
 (0)