You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

jest-file-loader

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-file-loader

A jest transformer similar to webpack's file-loader

1.0.3
latest
Version published
Weekly downloads
13K
-12.94%
Maintainers
1
Weekly downloads
 
Created

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

FAQs

Package last updated on 27 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts