Skip to content

Filipoliko/react-testing-library-shallow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();
    });
});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published