Problem: I want to test svelte components with jest but unable to do so since I'm unable to ignore the scss style mentioned inside the component. Is there a way to bypass the scss. My approach so far is as follows:-
jest.config.js
module.exports = {
transform: {
'^.+\\.svelte$': 'svelte-jester',
'^.+\\.js$': 'babel-jest',
},
moduleFileExtensions: ['js', 'svelte'],
moduleDirectories: ['node_modules', 'src'],
moduleNameMapper: {
"^.*\\.scss$": "SCSSStub.js"
}
}
babel.config.js
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
}
SCSSStub.js
module.exports = {};
Apart from this approach, I tried identity-obj-proxy as well as adding
moduleNameMapper: { '^.+\\.(css|less|scss)$': 'babel-jest',},
to jest.config.js. None of them worked.