Jest
With Jest, you can mock out any type of assets such as scss, like so:
Add the following to your package.json:
{
"jest":{
"moduleNameMapper":{
"\\.(css|less|sass|scss)$": "<rootDir>/__mocks__/styleMock.js",
"\\.(gif|ttf|eot|svg)$": "<rootDir>/__mocks__/fileMock.js"
}
}
}The styleMock.js or fileMock.js contents should be:
module.exports = {};
To mock out SVG, PNG and other assets, use jest-transform-stub library:
yarn add --dev jest-transform-stubEdit package.json:
{
"jest":{
"moduleNameMapper":{
"\\.(css|less|sass|scss|svg|png)$": "jest-transform-stub"
}
}
}