I'm trying to use jest in my JSPM project.
My jspm.config file looks like this:
SystemJS.config({
paths: {
"npm:": "jspm_packages/npm/",
"github:": "jspm_packages/github/",
"moment": "scripts/vendor/moment/moment.min.js"
}
});
In my package.json i have the follow JEST configurations:
"jest": {
"verbose": true,
"collectCoverage": true,
"moduleNameMapper": {
"^npm:(.*)": "<rootDir>/jspm_packages/npm/$1",
"^github:(.*)": "<rootDir>/jspm_packages/github/$1",
"moment": "<rootDir>/public/scripts/vendor/moment"
},
"moduleDirectories": [
"jspm_packages/npm",
"jspm_packages/github",
"public/scripts/vendor",
"node_modules"
],
"rootDir": "",
"modulePathIgnorePatterns": [
"jspm_packages/npm/[email protected]/"
]
},
I try the aproach of the poeticGeek answer in jest testing with es6 + jspm + systemjs + reactJS
but in my test.js whenever i import moment from 'moment';
the tests never completes, seems to enter in an infinite loop.
If i remove the moment inside the moduleNameMapper appears the following error: Cannot find module 'moment' from 'date.test.js'
Any ideas?
The problem was:"rootDir": ""
in the configuration file.