Awesome
jest-nunjucks
Jest processor that compiles nunjucks templates
Install
npm i jest-nunjucks --save-dev
Config example
Add to your config
"jest": {
"transform": {
"^.+\\.njk$": "jest-nunjucks",
}
}
To use nunjucks configuration options just add them into global jest config
"jest": {
"globals": {
"nunjucks": {
"config": {
"throwOnUndefined": true,
"trimBlocks": true
}
}
},
"transform": {
"^.+\\.njk$": "jest-nunjucks"
}
}
To use set path to look for templates use root option, it will be resolved with jest <rootDir>
.
If it's unset path for templates will be - <rootDir>
;
"jest": {
"globals": {
"nunjucks": {
"root": "./path-to-root-dir",
"config": {
"throwOnUndefined": true,
"trimBlocks": true
}
}
},
"transform": {
"^.+\\.njk$": "jest-nunjucks"
}
}
License
MIT