This repository was archived by the owner on Dec 31, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,27 @@ TypeError: Cannot read property 'createEvent' of null
26
26
at processImmediate (internal/timers.js:464:21)
27
27
```
28
28
29
+ To find the test that this error originates from easier, apply this patch
30
+
31
+ ``` bash
32
+ patch node_modules/react-dom/cjs/react-dom-test-utils.development.js < react-dom-test-utils.development.js.patch
33
+ yarn test
34
+ ```
35
+
36
+ And now you get something like
37
+
38
+ ``` bash
39
+ RUNS ./test.js
40
+ /Users/user/Documents/repos/react-testing-library-error-repro/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1010
41
+ throw ex || err;
42
+ ^
43
+
44
+ Test Failed: /Users/user/Documents/repos/react-testing-library-error-repro/test.js::it
45
+ at Object.act (/Users/user/Documents/repos/react-testing-library-error-repro/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1072:16)
46
+ at /Users/user/Documents/repos/react-testing-library-error-repro/test.js:41:30
47
+ at processTicksAndRejections (node:internal/process/task_queues:95:5)
48
+ ```
49
+
29
50
Environment:
30
51
``` bash
31
52
$ npx envinfo
Original file line number Diff line number Diff line change
1
+ --- node_modules/react-dom/cjs/react-dom-test-utils.development.js 2022-06-22 09:44:47.000000000 -0400
2
+ +++ react-dom-test-utils.development.js 2022-06-22 09:44:53.000000000 -0400
3
+ @@ -996,15 +996,19 @@
4
+ return didFlushWork;
5
+ };
6
+
7
+ - function flushWorkAndMicroTasks(onDone) {
8
+ + function flushWorkAndMicroTasks(onDone, ex) {
9
+ try {
10
+ flushWork();
11
+ enqueueTask(function () {
12
+ + try {
13
+ if (flushWork()) {
14
+ flushWorkAndMicroTasks(onDone);
15
+ } else {
16
+ onDone();
17
+ }
18
+ + } catch (err) {
19
+ + throw ex || err;
20
+ + }
21
+ });
22
+ } catch (err) {
23
+ onDone(err);
24
+ @@ -1064,6 +1068,9 @@
25
+ // effects and microtasks in a loop until flushPassiveEffects() === false,
26
+ // and cleans up
27
+
28
+ + const {testPath, currentTestName} = expect.getState();
29
+ + const ex = new Error(`${testPath}::${currentTestName}`);
30
+ + ex.name = 'Test Failed';
31
+
32
+ return {
33
+ then: function (resolve, reject) {
34
+ @@ -1085,7 +1092,7 @@
35
+ } else {
36
+ resolve();
37
+ }
38
+ - });
39
+ + }, ex);
40
+ }, function (err) {
41
+ onDone();
42
+ reject(err);
You can’t perform that action at this time.
0 commit comments