Skip to content

Commit b5790cc

Browse files
committed
fix: auto-cleanup afterEach
1 parent d25b7b1 commit b5790cc

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/helpers.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {fireEvent} from "./events";
2+
13
function jestFakeTimersAreEnabled() {
24
/* istanbul ignore else */
35
if (typeof jest !== 'undefined' && jest !== null) {
@@ -14,7 +16,16 @@ function jestFakeTimersAreEnabled() {
1416

1517
const instance = {current: undefined};
1618

19+
/**
20+
* Should not rely directly on `afterEach` without library detection
21+
* @see https://testing-library.com/docs/react-testing-library/setup/#skipping-auto-cleanup
22+
*/
1723
afterEach(() => {
24+
/**
25+
* Behavior should be customizability like it is with `react-testing-library`
26+
* @see https://testing-library.com/docs/react-testing-library/setup/#skipping-auto-cleanup
27+
*/
28+
if (instance.current) fireEvent.sigkill(instance.current);
1829
instance.current = undefined;
1930
})
2031

src/pure.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ async function render(
6666

6767
exec.stderr.on('data', (result: string) => {
6868
if (_readyPromiseInternals && !_isReadyResolved) {
69+
/**
70+
* TODO: We're getting an error where "result" is only the first line of many drawn.
71+
* Let's go ahead and set a timeout var in `config.js` and debounce the rejection
72+
*
73+
* Then, we'll set a boolean to not do any other kind of logging to stdout (or promise resolve)
74+
* until that timeout/debounce has expired.
75+
*
76+
* Also merge with the `'error'` field above
77+
*/
6978
_readyPromiseInternals.reject(new Error(result))
7079
_isReadyResolved = true;
7180
}

0 commit comments

Comments
 (0)