mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
feat: add "cleanup" function (#237)
* feat: add "cleanup" function * docs: add "cleanup" section * test: "cleanup" function * don't expose cleanup queue Co-authored-by: Alec Larson <alec.stanford.larson@gmail.com> Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
This commit is contained in:
committed by
Kacper Wiszczuk
parent
69d148023f
commit
4c77f4a7dc
@@ -2,6 +2,7 @@
|
||||
import * as React from 'react';
|
||||
import TestRenderer, { type ReactTestRenderer } from 'react-test-renderer'; // eslint-disable-line import/no-extraneous-dependencies
|
||||
import act from './act';
|
||||
import { addToCleanupQueue } from './cleanup';
|
||||
import { getByAPI } from './helpers/getByAPI';
|
||||
import { queryByAPI } from './helpers/queryByAPI';
|
||||
import a11yAPI from './helpers/a11yAPI';
|
||||
@@ -34,6 +35,8 @@ export default function render<T>(
|
||||
const update = updateWithAct(renderer, wrap);
|
||||
const instance = renderer.root;
|
||||
|
||||
addToCleanupQueue(renderer.unmount);
|
||||
|
||||
return {
|
||||
...getByAPI(instance),
|
||||
...queryByAPI(instance),
|
||||
|
||||
Reference in New Issue
Block a user