Skip to content

Commit

Permalink
fix(@angular/cli): fix test typings
Browse files Browse the repository at this point in the history
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.

Fix angular#5332
Fix angular#5351

BREAKING CHANGE:

The top level `files` and `include` options of `src/tsconfig.spec.json` should be removed.

The `src/typings.d.ts` file should be modified to contain the following:
```
/* SystemJS module definition */
declare var module: NodeModule;
interface NodeModule {
  id: string;
}
```

Projects using TypeScript 2.0 or TypeScript 4.0 while NOT using tsconfig inheritance need to update the following files:

- `src/tsconfig.app.json`
- `src/tsconfig.spec.json`
- `e2e/tsconfig.e2e.json`

By adding the following entry to `compilerOptions`:

```
   "typeRoots": [
      "../node_modules/@types"
    ],
```
  • Loading branch information
filipesilva committed Mar 18, 2017
1 parent dbaa04f commit ad58c18
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"lib": [
"es2016",
"dom"
],
"typeRoots": [
"../node_modules/@types"
],<% } %>
"outDir": "<%= relativeRootPath %>/out-tsc/app",
"module": "es2015",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"experimentalDecorators": true,
"lib": [
"es2016"
],
"typeRoots": [
"../node_modules/@types"
],<% } %>
"outDir": "<%= relativeRootPath %>/out-tsc/spec",
"module": "commonjs",
Expand All @@ -18,11 +21,5 @@
"jasmine",
"node"
]
},
"files": [
"test.ts"
],
"include": [
"**/*.spec.ts"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* SystemJS module definition */
declare var module: {
declare var module: NodeModule;
interface NodeModule {
id: string;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"experimentalDecorators": true,
"lib": [
"es2016"
],
"typeRoots": [
"../node_modules/@types"
],<% } %>
"outDir": "../out-tsc/e2e",
"module": "commonjs",
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/models/webpack-test-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class WebpackTestConfig extends NgCliWebpackConfig {
];

this.config = webpackMerge(webpackConfigs);
delete this.config.entry;

// Remove any instance of CommonsChunkPlugin, not needed with karma-webpack.
this.config.plugins = this.config.plugins.filter((plugin: any) =>
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/tests/lint/lint-with-exclude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default function () {

return Promise.resolve()
.then(() => ng('set', 'lint.0.exclude', '"**/foo.ts"'))
.then(() => ng('set', 'lint.1.exclude', '"**/foo.ts"'))
.then(() => writeFile(fileName, 'const foo = "";\n'))
.then(() => ng('lint'))
.then(({ stdout }) => {
Expand Down

0 comments on commit ad58c18

Please sign in to comment.