Skip to content

A jest transformer similar to webpack's file-loader

Notifications You must be signed in to change notification settings

remos/jest-file-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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}]
+    }
  }

About

A jest transformer similar to webpack's file-loader

Resources

Stars

Watchers

Forks

Packages

No packages published