Skip to content

Commit

Permalink
fix(@angular/cli): set correct mainFields for ng test when targeting …
Browse files Browse the repository at this point in the history
…es2015

Added test fails without the fix with the error described in the linked issue.

Fixes #8379
  • Loading branch information
devoto13 authored and hansl committed Nov 23, 2017
1 parent daa7a81 commit 8ea77b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/@angular/cli/models/webpack-configs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export function getTestConfig(wco: WebpackConfigOptions<WebpackTestOptions>) {
}

return {
resolve: {
mainFields: [
...(wco.supportES2015 ? ['es2015'] : []),
'browser', 'module', 'main'
]
},
devtool: buildOptions.sourcemaps ? 'inline-source-map' : 'eval',
entry: {
main: path.resolve(projectRoot, appConfig.root, appConfig.test)
Expand Down
14 changes: 14 additions & 0 deletions tests/e2e/tests/test/test-target.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';

export default function () {
return updateJsonFile('tsconfig.json', configJson => {
const compilerOptions = configJson['compilerOptions'];
compilerOptions['target'] = 'es2015';
})
.then(() => updateJsonFile('src/tsconfig.spec.json', configJson => {
const compilerOptions = configJson['compilerOptions'];
compilerOptions['target'] = 'es2015';
}))
.then(() => ng('test', '--single-run'));
}

0 comments on commit 8ea77b0

Please sign in to comment.