Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eddyerburgh/jest-transform-stub
Jest stub transform
https://github.com/eddyerburgh/jest-transform-stub
Last synced: 2 days ago
JSON representation
Jest stub transform
- Host: GitHub
- URL: https://github.com/eddyerburgh/jest-transform-stub
- Owner: eddyerburgh
- License: mit
- Created: 2018-02-27T21:52:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T09:43:47.000Z (almost 2 years ago)
- Last Synced: 2024-10-10T00:33:46.524Z (about 1 month ago)
- Language: JavaScript
- Size: 275 KB
- Stars: 112
- Watchers: 3
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jest-transform-stub
Jest doesn't handle non JavaScript assets by default.
You can use this module to avoid errors when importing non JavaScript assets.
## Usage
```shell
npm install --save-dev jest-transform-stub
```In your Jest config, add jest-transform-stub to transform non JavaScript assets you want to stub:
```js
{
"jest": {
// ..
"transform": {
"^.+\\.js$": "babel-jest",
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
}
}
```## FAQ
**My module isn't being transformed**
Jest doesn't apply transforms to node_modules by default. You can solve this by using `moduleNameMapper`:
```js
{
"jest": {
// ..
"moduleNameMapper": {
"^.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
}
}
```