angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Running ng test --cc fails for module="es2015" in tsconfig.spec.json

Open orazyto opened this issue 9 years ago • 4 comments

Bug Report or Feature Request (mark with an x)

- [X ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.0.1 node: 6.10.1 os: darwin x64 @angular/animations: 4.0.3 @angular/common: 4.0.3 @angular/compiler: 4.0.3 @angular/core: 4.0.3 @angular/forms: 4.0.3 @angular/http: 4.0.3 @angular/platform-browser: 4.0.3 @angular/platform-browser-dynamic: 4.0.3 @angular/router: 4.0.3 @angular/cli: 1.0.1 @angular/compiler-cli: 4.0.3

Repro steps.

ng new testProject In fresh project, update tsconfig.spec.json to have: module="es2015" This is needed as a temporary workaround for issues reported here: https://github.com/angular/angular-cli/issues/5651

The log given by the failure.

ng test --cc throws the following errors: ERROR in ./src/polyfills.ts Module build failed: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (38:0) at Parser.pp$5.raise (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:4443:13) at Parser.pp$1.parseStatement (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:1875:16) at Parser.parseStatement (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:5795:22) at Parser.pp$1.parseBlockBody (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:2262:21) at Parser.pp$1.parseTopLevel (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:1772:8) at Parser.parse (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:1667:17) at Object.parse (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:7163:37) at Instrumenter.instrumentSync (/Users/orazyto/Documents/testProject/node_modules/istanbul-lib-instrument/dist/instrumenter.js:121:31) at Instrumenter.instrument (/Users/orazyto/Documents/testProject/node_modules/istanbul-lib-instrument/dist/instrumenter.js:176:32) at Object.module.exports (/Users/orazyto/Documents/testProject/node_modules/istanbul-instrumenter-loader/index.js:25:25)

ERROR in ./src/test.ts Module build failed: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (2:0) at Parser.pp$5.raise (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:4443:13) at Parser.pp$1.parseStatement (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:1875:16) at Parser.parseStatement (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:5795:22) at Parser.pp$1.parseBlockBody (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:2262:21) at Parser.pp$1.parseTopLevel (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:1772:8) at Parser.parse (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:1667:17) at Object.parse (/Users/orazyto/Documents/testProject/node_modules/babylon/lib/index.js:7163:37) at Instrumenter.instrumentSync (/Users/orazyto/Documents/testProject/node_modules/istanbul-lib-instrument/dist/instrumenter.js:121:31) at Instrumenter.instrument (/Users/orazyto/Documents/testProject/node_modules/istanbul-lib-instrument/dist/instrumenter.js:176:32) at Object.module.exports (/Users/orazyto/Documents/testProject/node_modules/istanbul-instrumenter-loader/index.js:25:25)

Desired functionality.

I would like to be able to run tests, AND collect code coverage for my project. If I don't set module="es2015", I'm getting build failures as described in https://github.com/angular/angular-cli/issues/5651. However, this completely breaks code coverage collection.

Mention any other details that might be useful.

orazyto avatar May 01 '17 15:05 orazyto

Using module="es2015" isn't a real fix for the problem at hand, your browser might understand ES2015 modules but tooling (like the code coverage karma reporter) might not support it.

In this case the solution is waiting for a fix for #5651.

filipesilva avatar May 08 '17 09:05 filipesilva

Do you know when the fix is available? my CC is breaking too :(

Shavindra avatar Jun 06 '17 12:06 Shavindra

I have same error with --code-coverage option when run ng test with module"="es2015" config in tsconfig.spec.json

haku-d avatar Aug 23 '17 14:08 haku-d

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.