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

Use jest type instead of jasmine types #24

Closed
Robin-Hoodie opened this issue Feb 19, 2020 · 5 comments · Fixed by #41
Closed

Use jest type instead of jasmine types #24

Robin-Hoodie opened this issue Feb 19, 2020 · 5 comments · Fixed by #41

Comments

@Robin-Hoodie
Copy link

Robin-Hoodie commented Feb 19, 2020

Is your feature request related to a problem? Please describe.
As Jest types are built on top of It would probably be a better idea to use Jest types instead of the default Jasmine types Angular comes with. We're already adding @types/jest to package.json, but it doesn't seem like we're actually using it.

Describe the solution you'd like

After adding this schematic with ng add, we could, in addition to the current functionality

  • Remove @types/jasmine from package.json
  • Remove @types/jasminewd2 from package.json
  • Change types: ["jasmine", "node"] to types: ["jest", "node"] in tsconfig.spec.json
@strattonwhisler
Copy link

Thanks for the report.

I have a fix in progress for using types: ["jest", "node"] instead of types: ["jasmine", "node"] in tsconfig.spec.json.

Unfortunately, @types/jasmine and @types/jasminewd2 cannot be removed without causing issues with E2E testing since Protractor is configured to use Jasmine. At the moment, Protractor doesn't support Jest (see angular/protractor#3889). Looks like the Protractor team would be open to adding Jest support though (angular/protractor#3889 (comment)). Until then, this schematic will have to keep Jasmine around.

@Robin-Hoodie
Copy link
Author

@inventer99 Is it not an option to use types: ["jest", "jasmine", "node"] in that case?

@strattonwhisler
Copy link

@Robin-Hoodie I see how my reply may have been confusing.

Your originally suggested solution for the types entry in tsconfig.spec.json is correct. e2e and unit tests use different tsconfig.json files, so the unit tests can utilize types: ['jest', 'node'] while the e2e tests utilize types: ['jasmine', 'jasminewd2', 'node']. We don't need to merge the two.

My comment was in regard to the types packages (node_modules) for Jasmine rather than the compilerOptions.types . Since e2e tests use Jasmine, we need to keep the types/packages around, even though the unit tests no longer use them.

schuchard added a commit that referenced this issue Sep 2, 2020
Add support single application projects and workspaces with apps and libraries. 

## Jest runner

Replace the direct reliance on [`jest-preset-angular`](https://github.com/thymikee/jest-preset-angular) and package json scripts in favor of [`angular-builders/jest`](https://github.com/just-jeb/angular-builders/tree/master/packages/jest). This provides the ability to run tests with `ng test`

This should address #30 #28 #22 #11 
It better positions us to support #1 

## Jest types

Update each projects `tsconfig.spec.json` to configure the `jest` types while removing `jasmine`

This should address #24 #14

## Other
Non-user facing changes 

- refactor development scripts from `package.json` to TS file
- create 2 sandboxes (single app and workspace with app and lib)
- test both sandboxes during CI
- add MIT license
- add prettier
@schuchard
Copy link
Collaborator

I've looped this change into a larger PR. Please see if ng add @briebug/[email protected] solves the issue

@HamzaMoiyadi
Copy link

Hey,
I just installed version 3.1.0, which has the jest type added in the tsconfig.spec.json correctly, however I am still getting the following issue. Am I doing something wrong here?

Screenshot_20210610_230754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants