mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
feat: call "cleanup" automatically (#238)
* feat: add "cleanup" function * docs: add "cleanup" section * feat: automatically call "cleanup" after each test ...if an "afterEach" global function is defined, and process.env.RTL_SKIP_AUTO_CLEANUP is falsy. Taken from: https://github.com/testing-library/react-testing-library/blob/14670debd45236d2c5d0a61a83dadc72af1bef7c/src/index.js * docs: mention automatic cleanup * add within * fix lint * Updated tests, added auto-cleanup test * Added ways to prevent auto cleanup * Small fix * Code review changes * Update website/docs/API.md Co-authored-by: Michał Pierzchała <thymikee@gmail.com> * More changes * Removed afterEach(cleanup) calls in examples * Code cleanup Co-authored-by: Michał Pierzchała <thymikee@gmail.com> Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
This commit is contained in:
committed by
Michał Pierzchała
parent
40ed26812d
commit
ad66a5489d
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { NavigationContainer } from '@react-navigation/native';
|
||||
import { render, fireEvent, cleanup } from 'react-native-testing-library';
|
||||
import { render, fireEvent } from 'react-native-testing-library';
|
||||
|
||||
import AppNavigator from '../AppNavigator';
|
||||
|
||||
@@ -8,8 +8,6 @@ import AppNavigator from '../AppNavigator';
|
||||
jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
|
||||
|
||||
describe('Testing react navigation', () => {
|
||||
afterEach(cleanup);
|
||||
|
||||
test('page contains the header and 10 items', () => {
|
||||
const component = (
|
||||
<NavigationContainer>
|
||||
|
||||
Reference in New Issue
Block a user