react-testing-library-shallow

0.0.3 • Public • Published

React Testing Library Shallow

This library implements shallow rendering for React Testing Library.

Work in progress! This library is currently optimized only for Jest with @swc/jest used for the code transpilation.

Setup

Following configuration of @swc/jest is needed.

{
    jsc: {
        transform: {
            react: {
                pragma: '__reactTestingLibraryShallow.createElement',
                runtime: 'classic',
            },
        },
    },
},

Following configuration of jest is needed.

{
    // This setup file entry should be used as early as possible
    setupFiles: ['react-testing-library-shallow/lib/setup.js'],
}

Usage

import shallow from 'react-testing-library-shallow';
import MyComponent from './MyComponent';

describe('MyComponent', () => {
    test('can be shallow rendered', () => {
        expect(shallow(<MyComponent value={1} />)).toMatchSnapshot();
    });
});

Package Sidebar

Install

npm i react-testing-library-shallow

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

4.59 kB

Total Files

7

Last publish

Collaborators

  • filipoliko