Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

babel-plugin-jest-hoist

Package Overview
Dependencies
0
Maintainers
4
Versions
189
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-jest-hoist

Babel plugin to hoist `jest.disableAutomock`, `jest.enableAutomock`, `jest.unmock`, `jest.mock`, calls above `import` statements. This plugin is automatically included when using [babel-jest](https://github.com/facebook/jest/tree/master/packages/babel-jes


Version published
Weekly downloads
24M
increased by0.31%
Maintainers
4
Install size
22.0 kB
Created
Weekly downloads
 

Package description

What is babel-plugin-jest-hoist?

The babel-plugin-jest-hoist npm package is designed to work with Jest, a popular JavaScript testing framework. It allows Jest to hoist `jest.mock`, `jest.unmock`, `jest.enableAutomock`, `jest.disableAutomock`, `jest.useFakeTimers`, `jest.useRealTimers`, `jest.setMock`, and `jest.clearAllMocks` calls to the top of the file. This is necessary because Jest needs to isolate modules for mocking before they are used in tests, and doing so manually can be error-prone and tedious.

What are babel-plugin-jest-hoist's main functionalities?

Hoisting jest.mock calls

Automatically hoists `jest.mock` calls to the top of the file, ensuring that modules are mocked before any other code execution.

"use strict";\njest.mock('moduleName');\nconsole.log('This is a test.');"

Hoisting jest.useFakeTimers calls

Automatically hoists `jest.useFakeTimers` calls to the top, allowing tests to use fake timers from the start.

"use strict";\njest.useFakeTimers();\nconsole.log('This is a test with fake timers.');"

Other packages similar to babel-plugin-jest-hoist

Changelog

Source

jest 13.0.0

  • Added duration of individual tests in verbose mode.
  • Added a browser config option to properly resolve npm packages with a browser field in package.json if you are writing tests for client side apps
  • Added jest-repl.
  • Split up jest-cli into jest-runtime and jest-config.
  • Added a notification plugin that shows a test run notification using --notify.
  • Refactored TestRunner into SearchSource and improved the "no tests found" message.
  • Added jest.isMockFunction(jest.fn()) to test for mock functions.
  • Improved test reporter printing and added a test failure summary when running many tests.
    • Add support for property testing via testcheck-js.
  • Added a webpack tutorial.
  • Added support for virtual mocks through jest.mock('Module', implementation, {virtual: true}).
  • Added snapshot functionality through toMatchSnapshot().
  • Redesigned website.

Readme

Source

babel-plugin-jest-hoist

Babel plugin to hoist jest.disableAutomock, jest.enableAutomock, jest.unmock, jest.mock, calls above import statements. This plugin is automatically included when using babel-jest.

Installation

$ npm install babel-plugin-jest-hoist

Usage

.babelrc

{
  "plugins": ["jest-hoist"]
}

Via CLI

$ babel --plugins jest-hoist script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["jest-hoist"]
});

FAQs

Last updated on 22 Jun 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc