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:
Alec Larson
2019-12-09 05:41:48 -05:00
committed by Kacper Wiszczuk
parent 69d148023f
commit 4c77f4a7dc
6 changed files with 92 additions and 7 deletions
+3
View File
@@ -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),