diff --git a/packages/@angular/cli/models/webpack-configs/test.ts b/packages/@angular/cli/models/webpack-configs/test.ts index 73c54824bb11..00d3942d201d 100644 --- a/packages/@angular/cli/models/webpack-configs/test.ts +++ b/packages/@angular/cli/models/webpack-configs/test.ts @@ -48,6 +48,12 @@ export function getTestConfig(wco: WebpackConfigOptions) { } 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) diff --git a/tests/e2e/tests/test/test-target.ts b/tests/e2e/tests/test/test-target.ts new file mode 100644 index 000000000000..a2ff244af4ca --- /dev/null +++ b/tests/e2e/tests/test/test-target.ts @@ -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')); +}