https://github.com/moox/jsx-test-helpers
https://github.com/moox/jsx-test-helpers
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/moox/jsx-test-helpers
- Owner: MoOx
- License: mit
- Archived: true
- Created: 2016-04-08T09:29:20.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-26T19:45:39.000Z (over 8 years ago)
- Last Synced: 2025-01-17T15:53:20.586Z (over 1 year ago)
- Language: JavaScript
- Size: 75.2 KB
- Stars: 36
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# jsx-test-helpers
[](https://travis-ci.org/MoOx/jsx-test-helpers)
[](https://github.com/MoOx/jsx-test-helpers/blob/master/CHANGELOG.md)
[](https://github.com/MoOx/jsx-test-helpers)
[](https://gitlab.com/MoOx/jsx-test-helpers)
[](https://bitbucket.org/MoOx/jsx-test-helpers)
> Helpers to easily write tests for React component/JSX code
This package [is very small](src/index.js) and provide simple helpers to easily use [React shallow rendering](http://facebook.github.io/react/docs/test-utils.html#shallow-rendering) method in conjunction with [react-element-to-jsx-string](https://github.com/algolia/react-element-to-jsx-string) to write straightforward tests for React component.
**⚠️ [Be sure to read the test file, which is annotated](src/__tests__/index.js) 😙.**
## Installation
```console
$ npm install jsx-test-helpers
```
## Usage
**⚠️ [Be sure to read the test file, which have more complete annotated examples](src/__tests__/index.js).**
Example with [Jest](http://facebook.github.io/jest/):
```js
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()).toMatch(
JSX()
);
});
```
---
## 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](CHANGELOG.md)
## [LICENSE](LICENSE)