Skip to content

Commit

Permalink
Merge pull request #23 from wordpress-mobile/wp-fork-add-jest-28-support
Browse files Browse the repository at this point in the history
Add support for Jest 28+
  • Loading branch information
Gerardo Pacheco authored Jan 30, 2023
2 parents 2a8952c + 455061b commit d1e7674
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-reanimated",
"version": "2.9.1-wp-2",
"version": "2.9.1-wp-3",
"description": "More powerful alternative to Animated library for React Native.",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
Expand Down
Binary file removed react-native-reanimated-2.9.1-wp-2.tgz
Binary file not shown.
Binary file added react-native-reanimated-2.9.1-wp-3.tgz
Binary file not shown.
18 changes: 17 additions & 1 deletion src/reanimated2/jestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,23 @@ export const advanceAnimationByFrame = (count) => {
};

export const setUpTests = (userConfig = {}) => {
const expect = require('expect');
let expect = global.expect;
if (expect === undefined) {
const expectModule = require('expect');
expect = expectModule;
// Starting from Jest 28, "expect" package uses named exports instead of default export.
// So, requiring "expect" package doesn't give direct access to "expect" function anymore.
// It gives access to the module object instead.
// We use this info to detect if the project uses Jest 28 or higher.
if (typeof expect === 'object') {
const jestGlobals = require('@jest/globals');
expect = jestGlobals.expect;
}
if (expect === undefined || expect.extend === undefined) {
expect = expectModule.default;
}
}

require('setimmediate');
frameTime = Math.round(1000 / config.fps);

Expand Down

0 comments on commit d1e7674

Please sign in to comment.