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

/jest-ejs-transformer/

    Package Sidebar

    Install

    npm i jest-ejs-transformer

    Weekly Downloads

    135

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    2.41 kB

    Total Files

    9

    Last publish

    Collaborators

    • tubbo