Skip to content

isair/jest-transform-stub-named

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jest-transform-stub-named

Jest doesn't handle non JavaScript assets by default.

You can use this module to avoid errors when importing non JavaScript assets.

Forked from jest-transform-stub the difference is that this library mocks every media file to return its filename. Makes it possible to test that the correct images are loaded for components.

Usage

npm install --save-dev jest-transform-stub-named

In your Jest config, add jest-transform-stub-named to transform non JavaScript assets you want to stub:

{
  "jest": {
    // ..
    "transform": {
      "^.+\\.js$": "babel-jest",
      ".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub-named"
    }
  }
}

About

Jest stub transform with filename instead of blank to allow for better snapshot tests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%