react-testing-library-shallow
v0.0.3
Published
Shallow renderer for react-testing-library
Downloads
5
Maintainers
Readme
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();
});
});