Closed ovdncids closed 2 months ago
I fixed it on temporary.
/node_modules/spin.js/spin.js at line 79
export { Spinner }; -> module.exports = Spinner;
I hope to fix it next version.
This still seems to be an issue.
For Laravel devs using mix, using mix.js... will sort out this issue
It looks like Jest may need to be configured with Babel to handle ES6 modules: https://github.com/facebook/jest/issues/2550.
I'm having this same issue. Has anyone had any luck finding a permanent fix for this?
window.Spinner = require('spin.js');
instead of import Spinner from 'spin.js';
solved it for me. Maybe it'll help someone else.
Nevermind. It's not working.
Assuming that you don't actually need to test the internals of Spin.js, you can mock it:
in your Jest config:
moduleNameMapper": {
"spin.js": "<rootDir>/test/__mocks__/spinMock.js",
},
in spinMock.js:
module.exports = {};
Mocking suggestion by @JCB-K works, and I would say that it's a better solution to mock it, but you can also try using the transform ignore
"transformIgnorePatterns": [
"/node_modules/(?!spin.js).+\\.js$"
],
I'm unable to get "transformIgnorePatterns" to work to fix this for some reason, have tried quite a few variations at this point.
EDIT: Solved it: https://stackoverflow.com/questions/50147915/jest-transformignorepatterns-not-working Apparently a babel.config.js is required. Who'd've thought!
FAIL src/tests/App.test.js ● Test suite failed to run