1.0.3 • Published 3 years ago
jest-file-loader v1.0.3
jest-file-loader
A jest transform to replicate a similar behaviour to webpack's file-loader
Will result in an export of the imported path relative to the configured jest rootDir
Setup
Add the transform to your jest configuration:
package.json
"jest": {
+ "transform": {
+ "\\.png$": "jest-file-loader"
+ }
}note: if also using babel, you'll have to manually add an entry for babel-jest also
Options
esModule
Type: Boolean Default: false
By default jest-file-loader generates modules that use CommonJS syntax
e.g.:
module.exports = "src/logo.png";You can enable using ES module syntax by setting the esModule option to true
e.g.:
export default "src/logo.png";example configuration in package.json
"jest": {
+ "transform": {
+ "\\.png$": ["jest-file-loader", {"esModule": true}]
+ }
}