No description, website, or topics provided.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
flow
src
.editorconfig
.flowconfig
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
package.json
yarn.lock

README.md

jsx-test-helpers

Unix Build status Version

Repo on GitHub Repo on GitLab Repo on BitBucket

Helpers to easily write tests for React component/JSX code

This package is very small and provide simple helpers to easily use React shallow rendering method in conjunction with react-element-to-jsx-string to write straightforward tests for React component.

⚠️ Be sure to read the test file, which is annotated 😙.

Installation

$ npm install jsx-test-helpers

Usage

⚠️ Be sure to read the test file, which have more complete annotated examples.

Example with Jest:

import React from 'react';
import { noop, renderJSX, JSX } from 'jsx-test-helpers';

import FunctionalComponentToTest from '../your-component';

// fixture
function FakeComponent() {}

test('Can render & test a functional component', () => {
  expected(renderJSX(<FunctionalComponentToTest bool />)).toMatch(
    JSX(<FakeComponent fixedProp={'some-value'} bool />)
  );
});

CONTRIBUTING

  • ⇄ Pull/Merge requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull/Merge requests must be accompanied by passing automated tests ($ npm test).

CHANGELOG

LICENSE