jest: Bug: Cannot find module './createSpy' from 'jasmine-light.js'
Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
Cannot find module './createSpy' from 'jasmine-light.js'
- local install of jest in node_modules directory, called directly or from
npm test
- when cheating createSpy module, it fails on Env module and so on
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install
and yarn test
.
What is the expected behavior?
Tests run without en error.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
- node v8.1.3
- npm 5.0.3
- jest v20.0.4
- windows 10 64bit
jest --showConfig:
{
"config": {
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "C:\\Users\\MAREKH~1\\AppData\\Local\\Temp\\jest",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"\\\\node_modules\\\\"
],
"globals": {
"ts-jest": {
"tsConfigFile": "test/tsconfig.json",
"skipBabel": true
}
},
"haste": {
"providesModuleNodeModules": []
},
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"ts"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": [],
"name": "aa9b43f456cf36d229d63d785a874457",
"resetMocks": false,
"resetModules": false,
"rootDir": "C:\\projects\\edde-framework\\edde-js",
"roots": [
"C:\\projects\\edde-framework\\edde-js"
],
"setupFiles": [],
"snapshotSerializers": [],
"testEnvironment": "jest-environment-jsdom",
"testMatch": [],
"testPathIgnorePatterns": [
"\\\\node_modules\\\\"
],
"testRegex": "(/test/.*|\\.spec)\\.ts$",
"testRunner": "C:\\projects\\edde-framework\\edde-js\\node_modules\\jest-jasmine2\\build\\index.js",
"testURL": "about:blank",
"timers": "real",
"transform": [
[
"^.+\\.tsx?$",
"C:\\projects\\edde-framework\\edde-js\\node_modules\\ts-jest\\preprocessor.js"
]
],
"transformIgnorePatterns": [
"\\\\node_modules\\\\"
]
},
"framework": "jasmine2",
"globalConfig": {
"bail": true,
"collectCoverage": true,
"collectCoverageFrom": [
"src/**"
],
"coverageDirectory": "C:\\projects\\edde-framework\\edde-js\\coverage",
"coverageReporters": [
"text-summary"
],
"coverageThreshold": {
"global": {
"branches": 50,
"functions": 50,
"lines": 50,
"statements": 50
}
},
"expand": false,
"mapCoverage": true,
"noStackTrace": false,
"notify": false,
"projects": [
"C:/projects/edde-framework/edde-js"
],
"rootDir": "C:\\projects\\edde-framework\\edde-js",
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": false,
"watch": false,
"watchman": true
},
"version": "20.0.4"
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24 (8 by maintainers)
Commits related to this issue
- throw error in normalize if js extension is not included in moduleFileExtensions Fixes #4025 — committed to SimenB/jest by SimenB 6 years ago
- Throw explicit errors for common moduleFileExtension failures (#7160) <!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two... — committed to jestjs/jest by SimenB 6 years ago
I found the issue. I removed
"js"
as a file extension from the Jest config as I only have"ts"
files. You cannot do that. Adding"js"
again solves the problem for me.@thymikee the problem is that
jasmine-light.js
is bundled with jest and no longer being required ifjs
is not inmoduleFileExtensions
. To repro, just put"moduleFileExtensions": ["xx"]
in yourpackage.json
and try to test a.xx
file.I have this error as well, on macOS X. Tried Jest with a new project/setup, using the TypeScript setup.
This needs a fix then, thanks
I suffered the same problem on Linux machine. @Prior99 suggestion solved my problem.
Not if you’re getting in randomly, no - this issue is for an error in configuration (or typo in
require
/import
). If the error isn’t consistent, it’s something else