Skip to content

Commit

Permalink
Fix failing async tests in Node 10
Browse files Browse the repository at this point in the history
Dunno why they happened to work in Node 8 but whatever. Tested on both.
  • Loading branch information
acdlite committed Oct 20, 2018
1 parent d37f595 commit b753f76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,20 +444,16 @@ describe('ReactDOMServerHydration', () => {
});

it('should be able to use lazy components after hydrating', async () => {
async function fakeImport(result) {
return {default: result};
}

const Lazy = React.lazy(
() =>
new Promise(resolve => {
setTimeout(
() =>
resolve(
fakeImport(function World() {
resolve({
default: function World() {
return 'world';
}),
),
},
}),
1000,
);
}),
Expand Down Expand Up @@ -491,7 +487,7 @@ describe('ReactDOMServerHydration', () => {
expect(element.textContent).toBe('Hello loading');

jest.runAllTimers();
await Lazy;
await Promise.resolve();
expect(element.textContent).toBe('Hello world');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ describe('ReactDebugFiberPerf', () => {
return <span />;
}

async function fakeImport(result) {
function fakeImport(result) {
return {default: result};
}

Expand All @@ -600,7 +600,8 @@ describe('ReactDebugFiberPerf', () => {
return <div />;
}),
);
await LazyFoo;

await Promise.resolve();

ReactNoop.render(
<Parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ describe('ReactLazy', () => {
return fakeImport(Foo);
});

const LazyForwardRef = lazy(async () => {
const LazyForwardRef = lazy(() => {
class Bar extends React.Component {
render() {
return <Text text="Bar" />;
Expand Down

0 comments on commit b753f76

Please sign in to comment.