1.0.6 • Published 2 years ago

@nanshu/react-test-preset v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Install

yarn add @nanshu/react-test-preset -D

add babel.config.js

module.exports = require('@nanshu/react-test-preset/babel.config');

add jest.config.ts

export { default } from '@nanshu/react-test-preset/jest.config';

generator coverage badges

Add at least one of the below coverage hashes in your README file:

![Statements](#statements#)
![Branches](#branches#)
![Functions](#functions#)
![Lines](#lines#)

Add this script in your package.json file:

"badges": "npx istanbul-badges-readme --coverageDir='./coverage'"

run

yarn badges

Demo

https://www.jestjs.cn/

https://enzymejs.github.io/enzyme/

import React from 'react';
import { shallow } from 'enzyme';
import JsonTree from './index';

describe('JsonTree components', () => {
  it('basic', () => {
    const wrapper = shallow(<JsonTree data={{ name: 'chou' }} />);
    expect(wrapper).toMatchSnapshot();
    wrapper.unmount();
  });
});