Fix failing async tests in Node 10
Dunno why they happened to work in Node 8 but whatever. Tested on both.
Andrew Clark committed
Oct 20, 2018 at 16:06 UTC
b753f76a74644dd19e7a29f8aa4e8c759190f9ef
3 files changed
+9
-12
packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js
+5
-9
@@ -444,20 +444,16 @@ describe('ReactDOMServerHydration', () => {
444
});
445
446
it('should be able to use lazy components after hydrating', async () => {
447
- async function fakeImport(result) {
448
- return {default: result};
449
- }
450
-
447
const Lazy = React.lazy(
448
() =>
449
new Promise(resolve => {
450
setTimeout(
451
() =>
456
- resolve(
457
- fakeImport(function World() {
452
+ resolve({
453
+ default: function World() {
454
return 'world';
459
- }),
460
- ),
455
+ },
456
+ }),
457
1000,
458
);
459
}),
@@ -491,7 +487,7 @@ describe('ReactDOMServerHydration', () => {
487
expect(element.textContent).toBe('Hello loading');
488
489
jest.runAllTimers();
494
- await Lazy;
490
+ await Promise.resolve();
491
expect(element.textContent).toBe('Hello world');
492
});
493
});
packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.internal.js
+3
-2
@@ -573,7 +573,7 @@ describe('ReactDebugFiberPerf', () => {
573
return <span />;
574
}
575
576
- async function fakeImport(result) {
576
+ function fakeImport(result) {
577
return {default: result};
578
}
579
@@ -600,7 +600,8 @@ describe('ReactDebugFiberPerf', () => {
600
return <div />;
601
}),
602
);
603
- await LazyFoo;
603
+
604
+ await Promise.resolve();
605
606
ReactNoop.render(
607
<Parent>
packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js
+1
-1
@@ -319,7 +319,7 @@ describe('ReactLazy', () => {
319
return fakeImport(Foo);
320
});
321
322
- const LazyForwardRef = lazy(async () => {
322
+ const LazyForwardRef = lazy(() => {
323
class Bar extends React.Component {
324
render() {
325
return <Text text="Bar" />;