Skip to content

Commit adabd88

Browse files
committed
fix(@angular/cli): fix test typings
Blocked by angular#5500 (fix is included in this PR so that CI will run). Our unit test webpack config was erroneously sending in entry points to karma-webpack, who should receive no entry points. This in turn was hiding errors related to typeRoots lookups. It was also causing unit tests compilation to behave weirdly: unit test errors would not stop compilation, because other entries would still compile. This might also have contributed to the overall slowness of unit tests in angular#5423. Related to TypeStrong/ts-node#283 Fix angular#3911 Fix angular#5332 Fix angular#5351
1 parent 7087195 commit adabd88

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"emitDecoratorMetadata": true,
99
"experimentalDecorators": true,
1010
"lib": [
11-
"es2016"
11+
"es2016",
12+
"dom"
1213
],<% } %>
1314
"outDir": "<%= relativeRootPath %>/out-tsc/spec",
1415
"module": "commonjs",
@@ -23,6 +24,7 @@
2324
"test.ts"
2425
],
2526
"include": [
26-
"**/*.spec.ts"
27+
"**/*.spec.ts",
28+
"**/*.d.ts"
2729
]
2830
}

packages/@angular/cli/models/webpack-test-config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class WebpackTestConfig extends NgCliWebpackConfig {
2828
];
2929

3030
this.config = webpackMerge(webpackConfigs);
31+
delete this.config.entry;
3132

3233
// Remove any instance of CommonsChunkPlugin, not needed with karma-webpack.
3334
this.config.plugins = this.config.plugins.filter((plugin: any) =>

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export class ExtractI18nPlugin implements Tapable {
4646
if (!options.hasOwnProperty('tsConfigPath')) {
4747
throw new Error('Must specify "tsConfigPath" in the configuration of @ngtools/webpack.');
4848
}
49-
this._tsConfigPath = options.tsConfigPath;
49+
// TS represents paths internally with '/' and expects the tsconfig path to be in this format
50+
this._tsConfigPath = options.tsConfigPath.replace(/\\/g, '/');
5051

5152
// Check the base path.
5253
const maybeBasePath = path.resolve(process.cwd(), this._tsConfigPath);

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class AotPlugin implements Tapable {
9696
if (!options.hasOwnProperty('tsConfigPath')) {
9797
throw new Error('Must specify "tsConfigPath" in the configuration of @ngtools/webpack.');
9898
}
99-
this._tsConfigPath = options.tsConfigPath;
99+
// TS represents paths internally with '/' and expects the tsconfig path to be in this format
100+
this._tsConfigPath = options.tsConfigPath.replace(/\\/g, '/');
100101

101102
// Check the base path.
102103
const maybeBasePath = path.resolve(process.cwd(), this._tsConfigPath);

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

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default function () {
2323
}))
2424
.then(() => updateJsonFile('src/tsconfig.json', tsconfigJson => {
2525
delete tsconfigJson['exclude'];
26+
delete tsconfigJson['compilerOptions']['types'];
2627
}))
2728
.then(() => ng('build', '--aot'))
2829
.then(() => !ejected && ng('test', '--single-run'));

0 commit comments

Comments
 (0)