https://github.com/filipoliko/react-testing-library-shallow
https://github.com/filipoliko/react-testing-library-shallow
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/filipoliko/react-testing-library-shallow
- Owner: Filipoliko
- License: mit
- Archived: true
- Created: 2022-06-23T13:34:49.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-06T12:12:39.000Z (over 1 year ago)
- Last Synced: 2025-02-06T12:47:50.760Z (over 1 year ago)
- Language: JavaScript
- Size: 24.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# React Testing Library Shallow
**Project abandoned! Check out [shallow-react-snapshot](https://www.npmjs.com/package/shallow-react-snapshot) instead.**
This library implements `shallow` rendering for [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/).
*Work in progress! This library is currently optimized only for [Jest](https://jestjs.io) with [`@swc/jest`](https://www.npmjs.com/package/@swc/jest) used for the code transpilation.*
## Setup
Following configuration of `@swc/jest` is needed.
```javascript
{
jsc: {
transform: {
react: {
pragma: '__reactTestingLibraryShallow.createElement',
runtime: 'classic',
},
},
},
},
```
Following configuration of `jest` is needed.
```javascript
{
// This setup file entry should be used as early as possible
setupFiles: ['react-testing-library-shallow/lib/setup.js'],
}
```
## Usage
```javascript
import shallow from 'react-testing-library-shallow';
import MyComponent from './MyComponent';
describe('MyComponent', () => {
test('can be shallow rendered', () => {
expect(shallow()).toMatchSnapshot();
});
});
```