jest-ejs-transformer
v0.1.0
Published
Use EJS templates in your Jest tests
Downloads
235
Readme
jest-ejs-transformer
Use EJS templates in your Jest tests.
Installation
yarn add jst-ejs-transformer
Usage
In your jest.config.js:
const { defaults: { moduleFileExtensions } } = require("jest-config")
module.exports = {
moduleFileExtensions: [ ...moduleFileExtensions, "ejs"],
transform: {
"\\.ejs$": "jest-ejs-transformer",
//"\\.js$": "babel-jest" (optional)
}
}
You can now import
or require
an EJS template as a module:
const Template = require("./template/ejs")
module.exports = {
render(props) {
return Template(props)
}
}