npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jest-erb-transformer

v1.2.12

Published

Jest transformer for Embedded Ruby (`.erb`) files in Ruby projects

Downloads

5,417

Readme

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 your package manager, e.g. 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 project package.json using the Jest transformer configuration syntax. For example, to compile in the rails environment:

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

Babel

By default the transformer does not process its output with Babel.

To perform post-processing with Babel, either configure the transformer babelConfig option as outlined in the options table below, or I have found including the .erb files in the babel-jest transformer directly has worked in some scenarios. For example:

"transform": {
  "^.+\\.js(?:\\.erb)?$": "babel-jest",
  "^.+\\.erb$": [ "jest-erb-transformer", { "application": "rails" } ]
  }

All Options

| 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.credentials. | | "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. | | "babelConfig" | false | Process the output of the ERB transformer using babel-jest. Options: false - Disables the use of Babel.true - Babel processing using project or file-relative Babel configuration file../path/to/.babelrc.json - Relative path to Babel configuration file to be used for processing.{ "comments": false } - Object containing Babel options to be used for processing. |

Contributing

Feel free to ask questions using issues or contribute if you have any improvements.

License

MIT