caoge c760052ff9 机车状态修改 | 8 月之前 | |
---|---|---|
.. | ||
LICENSE | 8 月之前 | |
README.md | 8 月之前 | |
index.js | 8 月之前 | |
package.json | 8 月之前 |
Jest doesn't handle non JavaScript assets by default.
You can use this module to avoid errors when importing non JavaScript assets.
npm install --save-dev jest-transform-stub
In your Jest config, add jest-transform-stub to transform non JavaScript assets you want to stub:
{
"jest": {
// ..
"transform": {
"^.+\\.js$": "babel-jest",
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
}
}
My module isn't being transformed
Jest doesn't apply transforms to node_modules by default. You can solve this by using moduleNameMapper
:
{
"jest": {
// ..
"moduleNameMapper": {
"^.+.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
}
}