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).
npm install jest-transform-pug --save-dev
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"
}
}
}