Skip to content
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

ng test not reporting TypeScript errors #5863

Closed
jeffkenney opened this issue Apr 6, 2017 · 6 comments
Closed

ng test not reporting TypeScript errors #5863

jeffkenney opened this issue Apr 6, 2017 · 6 comments
Assignees
Labels
effort2: medium (days) P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity2: inconvenient type: bug/fix

Comments

@jeffkenney
Copy link

Bug Report or Feature Request (mark with an x)

- [x] bug report
- [ ] feature request

Versions.

@angular/cli: 1.0.0
node: 6.9.1
os: darwin x64 (El Capitan)
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.1

Repro steps.

  • Perform a fresh install with ng new
  • Add the following test to src/app/app.component.spec.ts
it('should not compile if there are TypeScript errors', () => {
  const myFunc = (arg: string) => {};
  myFunc(1);
});
  • run ng test --single-run and see that there are no errors
  • run tsc --project src/tsconfig.spec.json and see a type error

The log given by the failure.

No errors are reported. The code compiles and the tests pass.

Desired functionality.

The following compilation error should be reported and the tests should not be run:

src/app/app.component.spec.ts(39,12): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'.

@mmmichl
Copy link

mmmichl commented Apr 12, 2017

Having the same issue on MacOS and on Linux.
BUT, on Windows 10 I will get compiler errors!

@lpg-mac
Copy link

lpg-mac commented Apr 13, 2017

Seeing same behavior as @mmmichl here: type error not detected on OSX, detected on Windows. One extra piece of info: this is only the case for the "first run"; when "ng test" is running in watch mode, the type error does get detected when the file with errors is modified (causing it to get recompiled), even on OSX.

@filipesilva filipesilva added effort2: medium (days) P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity2: inconvenient type: bug/fix labels May 4, 2017
@filipesilva
Copy link
Contributor

That's odd. @sumitarora, can you have a look? I work on windows so never came across this problem. #6160 might inadvertently fix this though.

@sumitarora
Copy link
Contributor

@filipesilva @jeffkenney @mmmichl @lpg-mac Tested the issue on Mac was able to easily replicate the issue. It has been fixed by #6160 and throws errors on a single run too.

 ~/w/o/t/foo   master *…  ng test --single-run                                                                                                                                                               14s  Mon  8 May 11:41:07 2017
 10% building modules 1/1 modules 0 active08 05 2017 11:41:21.658:INFO [karma]: Karma v1.4.1 server started at http://0.0.0.0:9876/
08 05 2017 11:41:21.660:INFO [launcher]: Launching browser Chrome with unlimited concurrency
08 05 2017 11:41:21.663:INFO [launcher]: Starting browser Chrome
08 05 2017 11:41:26.262:ERROR [karma]: Error: /Users/sumitarora/workspace/open-source/temp/foo/src/app/app.component.spec.ts (16,12): Argument of type '1' is not assignable to parameter of type 'string'.
    at Compiler.compiler.plugin (/Users/sumitarora/workspace/open-source/angular-cli/packages/@angular/cli/plugins/karma-webpack-throw-error.ts:10:23)
    at Compiler.applyPlugins (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:61:14)
    at Watching._done (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compiler.js:92:17)
    at onCompiled (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compiler.js:51:17)
    at /Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compiler.js:494:13
    at next (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:138:11)
    at Compiler.<anonymous> (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/CachePlugin.js:62:5)
    at Compiler.applyPluginsAsyncSeries (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:142:13)
    at /Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compiler.js:491:10
    at Compilation.applyPluginsAsyncSeries (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:131:46)
    at self.applyPluginsAsync.err (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compilation.js:645:19)
    at next (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:138:11)
    at Compilation.compilation.plugin (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/ProgressPlugin.js:121:6)
    at Compilation.applyPluginsAsyncSeries (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:142:13)
    at self.applyPluginsAsync.err (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compilation.js:636:11)
    at next (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:138:11)
    at Compilation.compilation.plugin (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/ProgressPlugin.js:117:6)
    at Compilation.applyPluginsAsyncSeries (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:142:13)
    at self.applyPluginsAsync.err (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compilation.js:631:10)
    at next (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:138:11)
    at Compilation.compilation.plugin.callback (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/ProgressPlugin.js:113:6)
    at Compilation.applyPluginsAsyncSeries (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:142:13)
    at sealPart2 (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compilation.js:627:9)
    at next (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:138:11)
    at Compilation.compilation.plugin (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/ProgressPlugin.js:109:6)
    at Compilation.applyPluginsAsyncSeries (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:142:13)
    at Compilation.seal (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compilation.js:575:8)
    at /Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compiler.js:488:16
    at /Users/sumitarora/workspace/open-source/angular-cli/node_modules/tapable/lib/Tapable.js:225:11
    at _addModuleChain (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compilation.js:477:11)
    at processModuleDependencies.err (/Users/sumitarora/workspace/open-source/angular-cli/node_modules/webpack/lib/Compilation.js:448:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
 !~/w/o/t/foo   master *…  ng --version                                                                                                                                                                 10.8s  Mon  8 May 11:41:26 2017
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: local (v1.1.0-beta.0, branch: test-perf)
node: 7.5.0
os: darwin x64
@angular/animations: 4.1.1
@angular/common: 4.1.1
@angular/compiler: 4.1.1
@angular/core: 4.1.1
@angular/forms: 4.1.1
@angular/http: 4.1.1
@angular/language-service: 4.1.1
@angular/platform-browser: 4.1.1
@angular/platform-browser-dynamic: 4.1.1
@angular/router: 4.1.1
@angular/cli: error
@angular/compiler-cli: 4.1.1
 ~/w/o/t/foo   master *… 

@filipesilva
Copy link
Contributor

Fixed by #6160

@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.
Labels
effort2: medium (days) P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful severity2: inconvenient type: bug/fix
Projects
None yet
Development

No branches or pull requests

5 participants