Skip to content

ng test fails with typescript compile errors when ng serve runs fine #8693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RodolpheGohard opened this issue Nov 30, 2017 · 3 comments
Closed

Comments

@RodolpheGohard
Copy link

Versions

$ ng --version
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.2.8
node: 6.10.3
os: win32 ia32
@angular/animations: 5.0.3
@angular/common: 5.0.3
@angular/compiler: 5.0.3
@angular/core: 5.0.3
@angular/forms: 5.0.3
@angular/http: 5.0.3
@angular/platform-browser: 5.0.3
@angular/platform-browser-dynamic: 5.0.3
@angular/router: 5.0.3
@angular/cli: 1.2.8
@angular/compiler-cli: 5.0.3
@angular/language-service: 5.0.3

$ node --version
v6.10.3

Windows 7

Repro steps & Observed behavior

First problem (workaroundable):

$ ng test
30 11 2017 15:18:44.033:ERROR [config]: Invalid config file!
  TSError: ⨯ Unable to compile TypeScript
Cannot find type definition file for 'jasmine'. (2688)
Cannot find type definition file for 'jasminewd2'. (2688)
Cannot find type definition file for 'jquery'. (2688)
Cannot find type definition file for 'lodash'. (2688)
Cannot find type definition file for 'node'. (2688)
Cannot find type definition file for 'q'. (2688)
Cannot find type definition file for 'selenium-webdriver'. (2688)
    at getOutput (d:\workspace\smp-sgwt\node_modules\ts-node\src\index.ts:300:15)
    at d:\workspace\smp-sgwt\node_modules\ts-node\src\index.ts:330:16
    at Object.compile (d:\workspace\smp-sgwt\node_modules\ts-node\src\index.ts:489:17)
    at Module.m._compile (d:\workspace\smp-sgwt\node_modules\ts-node\src\index.ts:382:43)
    at Module._extensions..js (module.js:579:10)
    at Object.require.extensions.(anonymous function) [as .js] (d:\workspace\smp-sgwt\node_modules\ts-node\src\index.ts:385:12)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.parseConfig (d:\workspace\smp-sgwt\node_modules\karma\lib\config.js:363:22)
    at new Server (d:\workspace\smp-sgwt\node_modules\karma\lib\server.js:56:20)
    at Promise (d:\workspace\smp-sgwt\node_modules\@angular\cli\tasks\test.js:34:33)
    at Class.run (d:\workspace\smp-sgwt\node_modules\@angular\cli\tasks\test.js:15:16)
    at Class.run (d:\workspace\smp-sgwt\node_modules\@angular\cli\commands\test.js:104:25)

this is solved with the workaround #4177 which was marked as closed though

Second (unsolved) problem:

afterwards, I get another error:

$ rm -rf node_modules/ts-node

$ ng test
 10% building modules 2/2 modules 0 active30 11 2017 15:28:00.084:WARN [karma]: No captured browser, open http://localhost:9876/
30 11 2017 15:28:00.099:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
30 11 2017 15:28:00.101:INFO [launcher]: Launching browser Chrome with unlimited concurrency
30 11 2017 15:28:00.153:INFO [launcher]: Starting browser Chrome

ERROR in d:/workspace/smp-sgwt/src/app/services/column-defs.service.ts (57,11): Type 'Set<{}>' is not an array type.

ERROR in d:/workspace/smp-sgwt/src/app/services/column-defs.service.ts (57,11): Type 'Set<{}>' is not an array type.
30 11 2017 15:28:15.389:ERROR [launcher]: Cannot start Chrome

The incrimated code is:

    const renderCtps = guardNullRows(params => [
      ... new Set(params.value.map(doStuff))
    ].join(', '));

This should works, as the target in tsconfig is : "target": "es2015", and indeed it does work with ng serve or ng build.

Desired behavior

This should works, as the target in tsconfig is : "target": "es2015", and indeed it does work with ng serve or ng build.

It seems that karma is not using the right target as defined in tsconfig.ts

see also #2312

@RodolpheGohard
Copy link
Author

Ok, I realised there was three configs: src/tsconfig.app.json, and also src/tsconfig.spec.json, and also a tsconfig.json at root.

the target was es5 in src/tsconfig.spec.json. I changed it and it works now. (there is still the first bug though which, if I understand correctly, messes with e2e tests, but I have none yet)

@filipesilva
Copy link
Contributor

The first problem you present shows Invalid config file!, which makes me believe it was a bad tsconfig file. It seems that other than that finding the right tsconfig where to set options has sorted your problem.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants