jest-transform-pug

A Jest transform that compiles .pug files as template functions

MIT License

Downloads
3.5K
Stars
1

jest-transform-pug

A Jest transform that compiles your .pug files as template functions just like your pug loader would (e.g rollup-plugin-pug or pug-loader).

Usage

npm install jest-transform-pug --save-dev

Setup

Define jest-transform-pug as a transformer for Jest, by adding the following to your Jest configuration in your package.json:

{
  "jest": {
    "transform": {
      "\\.(pug)$": "jest-transform-pug"
    }
  }
}

Warning, this would override default transforms automatically set up by jest. Hence, if you rely on e.g., babel transpilation in your tests, you will need to set up babel jest as well:

{
  "jest": {
    "transform": {
      "^.+\\.jsx?$": "babel-jest",
      "\\.(pug)$": "jest-transform-pug"
    }
  }
}