New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-test-generator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-test-generator

generate tests for react components with propTypes and static analysis

latest
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

React Test Generator

This is project is very much experimental, and very much a work in progress. The end goal is to provide meaningful baseline tests for your React Components. Whether or does that or not right now is definitely debatable. But in the spirit of publish early...

What does it do Right now?

Right now it will crawl a given directory looking for react components (see here to learn how we currently figure out what is a component.). Once it finds a component it will right a basic test asserting said it is in fact a react element, as well as tests asserting that props that propTypes implies are not required do not cause the component to throw when rendered.

It is command line only right now, though i hope to provide a node accessible api shortly.

Use

Installing globally is the most useful for now

npm install react-test-generator -g

Once installed call this command in your terminal

react-testgen -i '/path/to/my/components -o '/tests'

and can call react-testgen -h for help.

This will generate test files for each located component following the same directory structure as the input path. This is a useful command for executing all the tests at once:

find ./gen-test -name '*.js' -exec tape {} \;'

Commands

  • -i, --in - in directory
  • -o, --out out directory
  • --no-overwrite - do not overwrite current test files

See here for usage example in a package.json.

Please file issues offering suggestions or documenting bugs, as this is, as mentioned above a huge WIP.

Here is an example of some generated tests being run, you can find the components that generated these tests here and tests they generated here.

Keywords

tests

FAQs

Package last updated on 12 Mar 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