From 019f405490bbeb1d7ba6928986b3f3433e387b59 Mon Sep 17 00:00:00 2001 From: Raphael Thomazella Date: Tue, 3 Mar 2020 00:48:16 -0300 Subject: [PATCH] fix(tests): fix reanimated mock.js with patch-package --- package.json | 2 + patches/react-native-reanimated+1.7.0.patch | 24 ++ .../__snapshots__/Drawer.test.tsx.snap | 286 ++++++++++++++++++ yarn.lock | 47 +++ 4 files changed, 359 insertions(+) create mode 100644 patches/react-native-reanimated+1.7.0.patch create mode 100644 src/__tests__/__snapshots__/Drawer.test.tsx.snap diff --git a/package.json b/package.json index c094d5e..83d086c 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "start": "react-native start", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "test": "jest", + "postinstall": "patch-package", "test:watch": "jest --watch" }, "dependencies": { @@ -39,6 +40,7 @@ "eslint-plugin-prettier": "^3.1.2", "jest": "^24.9.0", "metro-react-native-babel-preset": "^0.56.0", + "patch-package": "6.2.1", "prettier": "^1.19.1", "react-test-renderer": "16.9.0", "typescript": "^3.7.3" diff --git a/patches/react-native-reanimated+1.7.0.patch b/patches/react-native-reanimated+1.7.0.patch new file mode 100644 index 0000000..8a2e2c8 --- /dev/null +++ b/patches/react-native-reanimated+1.7.0.patch @@ -0,0 +1,24 @@ +diff --git a/node_modules/react-native-reanimated/mock.js b/node_modules/react-native-reanimated/mock.js +index 43978f5..f2dee0c 100644 +--- a/node_modules/react-native-reanimated/mock.js ++++ b/node_modules/react-native-reanimated/mock.js +@@ -11,7 +11,9 @@ + const React = require('react'); + const { View, Text, Image, Animated } = require('react-native'); + +-function NOOP() {} ++function NOOP() { ++ return { __value: 1} ++} + + class Code extends React.Component { + render() { +@@ -109,7 +111,7 @@ module.exports = { + } + }, + block: (a) => a[a.length - 1], +- call: (a, b) => b(a), ++ call: (a, b) => {}, + debug: NOOP, + onChange: NOOP, + startClock: NOOP, diff --git a/src/__tests__/__snapshots__/Drawer.test.tsx.snap b/src/__tests__/__snapshots__/Drawer.test.tsx.snap new file mode 100644 index 0000000..91c3225 --- /dev/null +++ b/src/__tests__/__snapshots__/Drawer.test.tsx.snap @@ -0,0 +1,286 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DrawerNavigator should render properly 1`] = ` + + + + + + + + + Test Screen + + + + + + + + + + + + + + + + Home + + + + + + + Settings + + + + + + + + + + +`; diff --git a/yarn.lock b/yarn.lock index 3ffd3a0..6048ae1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1221,6 +1221,11 @@ semver "^6.3.0" tsutils "^3.17.1" +"@yarnpkg/lockfile@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" + integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ== + abab@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a" @@ -2881,6 +2886,14 @@ find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" +find-yarn-workspace-root@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-1.2.1.tgz#40eb8e6e7c2502ddfaa2577c176f221422f860db" + integrity sha512-dVtfb0WuQG+8Ag2uWkbG79hOUzEsRrhBzgfn86g2sJPkzmcpGdghbNTfUKGTxymFrY/tLIodDzLoW9nOJ4FY8Q== + dependencies: + fs-extra "^4.0.3" + micromatch "^3.1.4" + flat-cache@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" @@ -2935,6 +2948,15 @@ fs-extra@^1.0.0: jsonfile "^2.1.0" klaw "^1.0.0" +fs-extra@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" + integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-extra@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" @@ -4093,6 +4115,13 @@ kind-of@^6.0.0, kind-of@^6.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +klaw-sync@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c" + integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ== + dependencies: + graceful-fs "^4.1.11" + klaw@^1.0.0: version "1.3.1" resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" @@ -5034,6 +5063,24 @@ pascalcase@^0.1.1: resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= +patch-package@6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.2.1.tgz#e3c55cf09dffd3984dd300e30d842672b604307f" + integrity sha512-dfCtQor63PPij6DDYtCzBRoO5nNAcMSg7Cmh+DLhR+s3t0OLQBdvFxJksZHBe1J2MjsSWDjTF4+oQKFbdkssIg== + dependencies: + "@yarnpkg/lockfile" "^1.1.0" + chalk "^2.4.2" + cross-spawn "^6.0.5" + find-yarn-workspace-root "^1.2.1" + fs-extra "^7.0.1" + is-ci "^2.0.0" + klaw-sync "^6.0.0" + minimist "^1.2.0" + rimraf "^2.6.3" + semver "^5.6.0" + slash "^2.0.0" + tmp "^0.0.33" + path-exists@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"