1.0.3 • Published 2 years ago

jest-file-loader v1.0.3

Weekly downloads
406
License
MIT
Repository
github
Last release
2 years ago

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

2 years ago

1.0.2

2 years ago

1.0.1

4 years ago

1.0.0

4 years ago