mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
We currently write all our tests against the DOM implementation.
I need a way to run the Fiber tests against it. But I don't want
to take on any package dependencies on Fiber modules yet.
There's a problem with jest right now where you can't globally
mock modules that already exist. So I have to add a global call
to jest.mock.
Luckily we already have a way to test the useCreateElement paths
using a feature flag. I won't activate this flag in travis until
it passes, but the idea is to run all three variants in travis.
I'm not sure that invoking rAF and rIC synchronously is the best
way to test this since it doesn't capture the backwards
compatibility aspect. I.e. the fact that people might be relying
on the synchronous nature in real apps too. It's a start.
Ideally, jest would have these built-in.
(cherry picked from commit c06a68a10b)
12 lines
292 B
JavaScript
12 lines
292 B
JavaScript
/* eslint-disable */
|
|
global.__DEV__ = true;
|
|
|
|
// For testing DOM Fiber, we synchronously invoke all the scheduling.
|
|
global.requestAnimationFrame = function(callback) {
|
|
callback();
|
|
};
|
|
|
|
global.requestIdleCallback = function(callback) {
|
|
callback({ timeRemaining() { return Infinity; } });
|
|
};
|