Skip to content

Commit 8ea77b0

Browse files
devoto13hansl
authored andcommitted
fix(@angular/cli): set correct mainFields for ng test when targeting es2015
Added test fails without the fix with the error described in the linked issue. Fixes #8379
1 parent daa7a81 commit 8ea77b0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ export function getTestConfig(wco: WebpackConfigOptions<WebpackTestOptions>) {
4848
}
4949

5050
return {
51+
resolve: {
52+
mainFields: [
53+
...(wco.supportES2015 ? ['es2015'] : []),
54+
'browser', 'module', 'main'
55+
]
56+
},
5157
devtool: buildOptions.sourcemaps ? 'inline-source-map' : 'eval',
5258
entry: {
5359
main: path.resolve(projectRoot, appConfig.root, appConfig.test)

tests/e2e/tests/test/test-target.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { ng } from '../../utils/process';
2+
import { updateJsonFile } from '../../utils/project';
3+
4+
export default function () {
5+
return updateJsonFile('tsconfig.json', configJson => {
6+
const compilerOptions = configJson['compilerOptions'];
7+
compilerOptions['target'] = 'es2015';
8+
})
9+
.then(() => updateJsonFile('src/tsconfig.spec.json', configJson => {
10+
const compilerOptions = configJson['compilerOptions'];
11+
compilerOptions['target'] = 'es2015';
12+
}))
13+
.then(() => ng('test', '--single-run'));
14+
}

0 commit comments

Comments
 (0)