spectator: Angular build fails when there is Jest installed instead of Jasmine

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

I have a project where I’ve completely removed Jasmine and Karma. I use Jest for unit testing. There is nothing left from Jasmine in that project. I’ve added @ngneat/spectator package to devDependencies and now the project building fails with the following error:

ERROR in node_modules/@ngneat/spectator/lib/mock.d.ts(1,23): error TS2688: Cannot find type definition file for ‘jasmine’.

Expected behavior

There should be a way to use @ngneat/spectator with Jest without need to install anything from Jasmine.

Minimal reproduction of the problem with instructions

Add the following packages to package.json and try to build even empty app:

"dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "^7.2.0",
    "@angular/elements": "^7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "ajv": "^6.9.1",
    "core-js": "^2.5.4",
    "document-register-element": "^1.8.1",
    "rxjs": "~6.3.3",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-builders/jest": "^7.4.4",
    "@angular-devkit/build-angular": "~0.13.2",
    "@angular-devkit/build-ng-packagr": "~0.13.2",
    "@angular/cli": "~7.2.4",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@ngneat/spectator": "^4.5.0",
    "@types/jest": "^24.0.19",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jest": "^24.9.0",
    "jest-preset-angular": "^7.1.1",
    "ng-packagr": "^4.2.0",
    "require-dir": "^1.2.0",
    "through2": "3.0.1",
    "ts-node": "~7.0.0",
    "tsickle": ">=0.34.0",
    "tslib": "^1.9.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }

in the tsconfig I have the following:

...
"types": [
      "jest",
      "node"
    ],
...

What is the motivation / use case for changing the behavior?

Should be possible to use @ngneat/spectator without Jasmine installed.

Environment


Angular version: 7.2.0

Browser:
- not related to browser
 
For Tooling issues:
- Node version: 12.4.0
- Platform:  Windows 10 and MacOS 10.14.6

Others:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 27 (8 by maintainers)

Most upvoted comments

Any update on this? The proposed fix

Ok maybe i find a solution. That’s because i don’t exclude some files in my tsconfig. Try to add in your tsconfig "exclude": [ "node_modules", "**/*.spec.ts" ] For me works

does not work for me:

"@ngneat/spectator": "^7.1.0",
"@types/jest": "^24.0.23",
"jest": "^26.6.3",
"jest-preset-angular": "^8.4.0",

Also, I agree with @gagle. This seems like a workaround rather than a fix.

@Dimanoid @the0rem I reverted this change.

Why is this issues is closed? It is still a problem

I agree. I want to verify it with @dirkluijk.

Maybe this is because you imported stuff from @ngneat/spectator that should be imported from @ngneat/spectator/jest instead. Can you double check this please?