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

react-test-generator

v0.0.3

Published

generate tests for react components with propTypes and static analysis

Downloads

14

Readme

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.