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

[BUG] New project instructions don't work #1190

Closed
lonix1 opened this issue Mar 20, 2019 · 5 comments · Fixed by #1118
Closed

[BUG] New project instructions don't work #1190

lonix1 opened this issue Mar 20, 2019 · 5 comments · Fixed by #1118

Comments

@lonix1
Copy link

lonix1 commented Mar 20, 2019

I followed the official docs to create a new app.

Environment (latest of everything):
nx 7.7.2
angular-cli 7.3.1
node 10.15.3
npm 6.9.0
ubuntu 18
vscode 1.32.3

Repro:

sudo npm install --global @angular/cli@7.3.6     # latest
npx create-nx-workspace myworkspace              # choose empty workspace
cd myworkspace
ng g application myapp                           # choose angular, jest, cypress
npm install

npm run test                                     # succeeds
ng test                                          # succeeds

Problem: running tests in IDE, or using jest in terminal, fails:

  • From vscode: open vscode, then open the /apps/myapp/src/app/app.component.spec.ts
  • From terminal: node_modules/.bin/jest apps/myapp/src/app/app.component.spec.ts --testNamePattern="AppComponent"

In both cases error is

"Zone is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/zone.js"

This is significant because the IDE tooling and various test extensions use the jest approach to find and run tests (rather than npm run test / ng test).

@lonix1 lonix1 changed the title [Bug] New project instructions/templates don't work [Bug] New project instructions for testing don't work Mar 20, 2019
@lonix1
Copy link
Author

lonix1 commented Mar 21, 2019

This appears to be a problem for VSCode. However since it is the most used IDE in the node/angular world, this is a serious problem.

Has anyone figured out how to solve this? Can anyone share a boilerplate project which actually works?

@lonix1
Copy link
Author

lonix1 commented Mar 21, 2019

After following the workaround in that issue, the error is now

Uncaught (in promise): Failed to load app.component.html

and

This test module uses the component AppComponent which is using a "templateUrl" or "styleUrls", but they were never compiled. Please call "TestBed.compileComponents" before your test.

This is for a vanilla new project, using nx's generators. I've added nothing.

I also tried some tips on the angular site for this specific error, but they didn't help.

I've tried loads of workarounds and versions, without any progress. And there are many breaking changes with new versions of the dependencies.

@lonix1 lonix1 changed the title [Bug] New project instructions for testing don't work [BUG] New project instructions don't work Mar 21, 2019
@FrozenPandaz
Copy link
Collaborator

This extension has a configuration option for jest executable: https://github.com/jest-community/vscode-jest

This PR makes integration much better:
#1118

After that, you can set your path to the ./node_modules/.bin/ng test and it will work:
image

@lonix1
Copy link
Author

lonix1 commented Mar 22, 2019

Thanks for looking into this!

That PR looks cool, hope you guys manage to merge it soon!

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants