Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

jest-erb-transformer

1.0.3 • Public • Published

Jest ERB Transformer

npm-version build-status code-coverage JavaScript Style Guide

Overview

Custom transformer for compiling Embedded Ruby template files (.erb) for use in the Jest JavaScript testing framework.

Install

Add to project using npm:

npm install jest-erb-transformer --save-dev

Add to project using Yarn:

yarn add jest-erb-transformer --dev

Configuration

Jest Configuration

Ensure the "erb" file extension and the jest-erb-transformer extension matcher and configuration is included in the project's package.json jest key:

"moduleFileExtensions"[
  "js",
  "erb"
],
"transform"{
  "^.+\\.erb$": "jest-erb-transformer"
}

See the Jest docs for more information on the configuration of transformers.

Options

To add custom configuration, such as using the Ruby on Rails runner for ERB compilation, add a configuration object to the transformer entry in the package.json using the Jest syntax. For example, to compile JavaScript in the rails environment:

"transform"{
  "^.+\\.erb$": [ "jest-erb-transformer", { "application": "rails" } ]
}
Key Default Value Description
"application" "ruby" Transformer is run using ruby by default, set value to "rails" to use bin/rails runner. The "rails" option can be useful if the .erb files include Ruby on Rails specific environment variables such as Rails.application.credentails.
"engine" "erb" Transformer uses the ruby 'ERB' engine by default, to use the Erubi engine set the value to "erubi".
"timeout" "5000" Set the timeout duration in milliseconds for the compilation of individual files.

License

MIT

Install

npm i jest-erb-transformer

DownloadsWeekly Downloads

19

Version

1.0.3

License

MIT

Unpacked Size

16.1 kB

Total Files

17

Last publish

Collaborators

  • avatar