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

react-test-env

Package Overview
Dependencies
Maintainers
7
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-test-env

React Test Environment Setup

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

React Test Environment Setup

When React is loaded, it performs a check to detect whether it's executing in the context of a document. Therefore, when testing React components or otherwise simulating a DOM using JSDOM, you must ensure that the document is initialized prior to loading React. The purpose of this module is to reduce this boilerplate and create the expected global variables in a single call.

Usage

The module exports a single function which accepts an optional markup string to be passed to JSDOM. You'll likely want to require the module as the first line of your script, so that the globals are available to any subsequent modules that may depend on their existance.

require( 'react-test-env' )();

/**
 * External dependencies
 */
var React = require( 'react' );

// ...

By default, a fully functional localStorage and noop XMLHttpRequest will be added to the global scope. One or both of these can be disabled by passing an additional features option when calling the module.

require( 'react-test-env' )( null, {
	localStorage: false
} );

FAQs

Package last updated on 15 Aug 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