Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

transform-jest-deps

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transform-jest-deps

Parse the AST, transforming paths in require() calls and other jest-specific calls


Version published
Weekly downloads
2.7K
increased by137.02%
Maintainers
1
Weekly downloads
 
Created
Source

transform-jest-deps

Parse the AST, transforming paths in require() calls and other jest-specific calls.

NPM

Based on the transform-deps module.

Install

npm install --save-dev transform-jest-deps

Features

  • Supports ES6 and JSX acorn plugins out-of-the-box.
  • Other plugins can be enabled using falafel options.

Example

var transform = require('transform-jest-deps');
var src = "require('x'); require('y');"
src = transform(src, function(name) {
  if (name == 'x') return 'z';
});
console.log(src);

Output:

require('z'); require('y')

Options

In addition to the options supported by falafel, we support:

  • ignoreTryCatch: Ignore require statements in try/catch blocks

Options may be passed by using an object as the second argument. If this is done, pass the transform function as the 3rd argument.

API

src = transformJestDeps(src, transformFn);

src = transformJestDeps(src, options, transformFn);

Example using options to parse ES6 and JSX:

var acorn = require('acorn-jsx');
var transform = require('transform-jest-deps');
var src = [
  "require('x');",
  "function Thing() {}",
  "var foo = <Thing/>;",
  "var arr1 = [1]; var arr2 = [...arr1, 2]",
  "require('y');"
].join("\n");

src = transform(src, {
  ecmaVersion: 6,
  parser: acorn,
  plugins: {jsx: true}
}, function(name) {
  if (name == 'x') return 'z';
});

License

MIT

Keywords

FAQs

Package last updated on 21 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc