Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/denar90/jest-nunjucks

Jest processor that compiles nunjucks templates
https://github.com/denar90/jest-nunjucks

Last synced: 21 days ago
JSON representation

Jest processor that compiles nunjucks templates

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/denar90/jest-nunjucks.svg?branch=master)](https://travis-ci.org/denar90/jest-nunjucks)

# jest-nunjucks

## Jest processor that compiles nunjucks templates

### Install

`npm i jest-nunjucks --save-dev`

### Config example

Add to your config

```json
"jest": {
"transform": {
"^.+\\.njk$": "jest-nunjucks",
}
}
```

To use [nunjucks configuration options](https://mozilla.github.io/nunjucks/api.html#configure) just add them into global jest config

```json
"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 ``.
If it's unset path for templates will be - ``;

```json
"jest": {
"globals": {
"nunjucks": {
"root": "./path-to-root-dir",
"config": {
"throwOnUndefined": true,
"trimBlocks": true
}
}
},
"transform": {
"^.+\\.njk$": "jest-nunjucks"
}
}
```

## License

MIT