jest-ejs-transformer

0.1.0 • Public • Published

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)
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i jest-ejs-transformer

Weekly Downloads

218

Version

0.1.0

License

MIT

Unpacked Size

2.41 kB

Total Files

9

Last publish

Collaborators

  • tubbo