Skip to content

Commit

Permalink
fix(core): Babel register haste map only to for react-native modules
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseLion committed Mar 10, 2024
1 parent e330913 commit 0e015a7
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 7 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-etc": "^2.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.2.0",
"eslint-plugin-jsdoc": "^48.2.1",
"eslint-plugin-sonarjs": "^0.24.0",
"mocha": "^10.3.0",
"react": "18.2.0",
"react-native": "^0.73.5",
"react-native-svg": "^15.1.0",
"react-test-renderer": "^18.2.0",
"semantic-release": "^23.0.2",
"semantic-release-yarn": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/babelRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import register from "@babel/register";

register({
cache: true,
only: [/node_modules[/\\](react-native|@react-native).*/],
only: [/node_modules[/\\](react-native|@react-native)[/\\]/],
plugins: [
["module-resolver", {
resolvePath(sourcePath: string) {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/register.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { expect } from "@assertive-ts/core";
import { render, waitFor, userEvent } from "@testing-library/react-native";
import { ReactElement, useCallback, useRef, useState } from "react";
import { ActivityIndicator, Animated, Button, Image, Modal, ScrollView, Text, TextInput, View } from "react-native";
import { Rect, Svg } from "react-native-svg";

function TestScreen(): ReactElement {

Expand Down Expand Up @@ -45,6 +46,15 @@ function TestScreen(): ReactElement {
<Text>{"foo"}</Text>
</Modal>
</View>
<Svg testID="svg-test">
<Rect
x={0}
y={0}
width={100}
height={100}
fill="red"
/>
</Svg>
<Button title="Click Me!" onPress={animateView} />
<Animated.View style={{ marginLeft: enterLeft }}>
<Text>{`Animated view: ${animated}`}</Text>
Expand All @@ -61,6 +71,7 @@ describe("[Unit] register.test.ts", () => {
getByPlaceholderText,
getByDisplayValue,
getByLabelText,
getByTestId,
findByText,
} = render(<TestScreen />);

Expand All @@ -71,6 +82,7 @@ describe("[Unit] register.test.ts", () => {
expect(getByLabelText("Profile picture")).toBePresent();
expect(getByText("I'm on a modal")).toBePresent();
expect(() => getByText("foo")).toThrowError();
expect(getByTestId("svg-test")).toBePresent();
expect(getByText("Animated view: false")).toBePresent();

const clickMeButton = await findByText("Click Me!");
Expand Down
122 changes: 117 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3258,6 +3258,13 @@ __metadata:
languageName: node
linkType: hard

"boolbase@npm:^1.0.0":
version: 1.0.0
resolution: "boolbase@npm:1.0.0"
checksum: 10/3e25c80ef626c3a3487c73dbfc70ac322ec830666c9ad915d11b701142fab25ec1e63eff2c450c74347acfd2de854ccde865cd79ef4db1683f7c7b046ea43bb0
languageName: node
linkType: hard

"bottleneck@npm:^2.15.3":
version: 2.19.5
resolution: "bottleneck@npm:2.19.5"
Expand Down Expand Up @@ -4009,6 +4016,36 @@ __metadata:
languageName: node
linkType: hard

"css-select@npm:^5.1.0":
version: 5.1.0
resolution: "css-select@npm:5.1.0"
dependencies:
boolbase: "npm:^1.0.0"
css-what: "npm:^6.1.0"
domhandler: "npm:^5.0.2"
domutils: "npm:^3.0.1"
nth-check: "npm:^2.0.1"
checksum: 10/d486b1e7eb140468218a5ab5af53257e01f937d2173ac46981f6b7de9c5283d55427a36715dc8decfc0c079cf89259ac5b41ef58f6e1a422eee44ab8bfdc78da
languageName: node
linkType: hard

"css-tree@npm:^1.1.3":
version: 1.1.3
resolution: "css-tree@npm:1.1.3"
dependencies:
mdn-data: "npm:2.0.14"
source-map: "npm:^0.6.1"
checksum: 10/29710728cc4b136f1e9b23ee1228ec403ec9f3d487bc94a9c5dbec563c1e08c59bc917dd6f82521a35e869ff655c298270f43ca673265005b0cd05b292eb05ab
languageName: node
linkType: hard

"css-what@npm:^6.1.0":
version: 6.1.0
resolution: "css-what@npm:6.1.0"
checksum: 10/c67a3a2d0d81843af87f8bf0a4d0845b0f952377714abbb2884e48942409d57a2110eabee003609d02ee487b054614bdfcfc59ee265728ff105bd5aa221c1d0e
languageName: node
linkType: hard

"cssesc@npm:^3.0.0":
version: 3.0.0
resolution: "cssesc@npm:3.0.0"
Expand Down Expand Up @@ -4267,6 +4304,44 @@ __metadata:
languageName: node
linkType: hard

"dom-serializer@npm:^2.0.0":
version: 2.0.0
resolution: "dom-serializer@npm:2.0.0"
dependencies:
domelementtype: "npm:^2.3.0"
domhandler: "npm:^5.0.2"
entities: "npm:^4.2.0"
checksum: 10/e3bf9027a64450bca0a72297ecdc1e3abb7a2912268a9f3f5d33a2e29c1e2c3502c6e9f860fc6625940bfe0cfb57a44953262b9e94df76872fdfb8151097eeb3
languageName: node
linkType: hard

"domelementtype@npm:^2.3.0":
version: 2.3.0
resolution: "domelementtype@npm:2.3.0"
checksum: 10/ee837a318ff702622f383409d1f5b25dd1024b692ef64d3096ff702e26339f8e345820f29a68bcdcea8cfee3531776b3382651232fbeae95612d6f0a75efb4f6
languageName: node
linkType: hard

"domhandler@npm:^5.0.2, domhandler@npm:^5.0.3":
version: 5.0.3
resolution: "domhandler@npm:5.0.3"
dependencies:
domelementtype: "npm:^2.3.0"
checksum: 10/809b805a50a9c6884a29f38aec0a4e1b4537f40e1c861950ed47d10b049febe6b79ab72adaeeebb3cc8fc1cd33f34e97048a72a9265103426d93efafa78d3e96
languageName: node
linkType: hard

"domutils@npm:^3.0.1":
version: 3.1.0
resolution: "domutils@npm:3.1.0"
dependencies:
dom-serializer: "npm:^2.0.0"
domelementtype: "npm:^2.3.0"
domhandler: "npm:^5.0.3"
checksum: 10/9a169a6e57ac4c738269a73ab4caf785114ed70e46254139c1bbc8144ac3102aacb28a6149508395ae34aa5d6a40081f4fa5313855dc8319c6d8359866b6dfea
languageName: node
linkType: hard

"dot-prop-immutable@npm:^2.1.1":
version: 2.1.1
resolution: "dot-prop-immutable@npm:2.1.1"
Expand Down Expand Up @@ -4360,6 +4435,13 @@ __metadata:
languageName: node
linkType: hard

"entities@npm:^4.2.0":
version: 4.5.0
resolution: "entities@npm:4.5.0"
checksum: 10/ede2a35c9bce1aeccd055a1b445d41c75a14a2bb1cd22e242f20cf04d236cdcd7f9c859eb83f76885327bfae0c25bf03303665ee1ce3d47c5927b98b0e3e3d48
languageName: node
linkType: hard

"env-ci@npm:^11.0.0":
version: 11.0.0
resolution: "env-ci@npm:11.0.0"
Expand Down Expand Up @@ -4669,9 +4751,9 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-jsdoc@npm:^48.2.0":
version: 48.2.0
resolution: "eslint-plugin-jsdoc@npm:48.2.0"
"eslint-plugin-jsdoc@npm:^48.2.1":
version: 48.2.1
resolution: "eslint-plugin-jsdoc@npm:48.2.1"
dependencies:
"@es-joy/jsdoccomment": "npm:~0.42.0"
are-docs-informative: "npm:^0.0.2"
Expand All @@ -4684,7 +4766,7 @@ __metadata:
spdx-expression-parse: "npm:^4.0.0"
peerDependencies:
eslint: ^7.0.0 || ^8.0.0 || ^9.0.0
checksum: 10/4a616f6d888311f63ccf0f4c697714c66978bb3717cb5a6a5af410615d9b28ff4febe3241939135a75636f2a4e95229563acbb7761db39e4ff7e7b23c2129262
checksum: 10/4b4e6592ea27646d2556b0feedda4427dac110f4a9adf858aa040aead0d673d263d5474673f774d1202492b8971065ff027fbe3531c20a2b255b11cbc06a90ca
languageName: node
linkType: hard

Expand Down Expand Up @@ -7125,6 +7207,13 @@ __metadata:
languageName: node
linkType: hard

"mdn-data@npm:2.0.14":
version: 2.0.14
resolution: "mdn-data@npm:2.0.14"
checksum: 10/64c629fcf14807e30d6dc79f97cbcafa16db066f53a294299f3932b3beb0eb0d1386d3a7fe408fc67348c449a4e0999360c894ba4c81eb209d7be4e36503de0e
languageName: node
linkType: hard

"memoize-one@npm:^5.0.0":
version: 5.2.1
resolution: "memoize-one@npm:5.2.1"
Expand Down Expand Up @@ -8048,6 +8137,15 @@ __metadata:
languageName: node
linkType: hard

"nth-check@npm:^2.0.1":
version: 2.1.1
resolution: "nth-check@npm:2.1.1"
dependencies:
boolbase: "npm:^1.0.0"
checksum: 10/5afc3dafcd1573b08877ca8e6148c52abd565f1d06b1eb08caf982e3fa289a82f2cae697ffb55b5021e146d60443f1590a5d6b944844e944714a5b549675bcd3
languageName: node
linkType: hard

"nullthrows@npm:^1.1.1":
version: 1.1.1
resolution: "nullthrows@npm:1.1.1"
Expand Down Expand Up @@ -8846,6 +8944,19 @@ __metadata:
languageName: node
linkType: hard

"react-native-svg@npm:^15.1.0":
version: 15.1.0
resolution: "react-native-svg@npm:15.1.0"
dependencies:
css-select: "npm:^5.1.0"
css-tree: "npm:^1.1.3"
peerDependencies:
react: "*"
react-native: "*"
checksum: 10/5733b9f8fd11ada31c6a2a3fff372ff144e6d729251553f2af0de638eec5150b860fb907449f236ae37ff83593c3742944354f7d72c017a8338fc8693ee0c117
languageName: node
linkType: hard

"react-native-testing-mocks@workspace:.":
version: 0.0.0-use.local
resolution: "react-native-testing-mocks@workspace:."
Expand All @@ -8871,11 +8982,12 @@ __metadata:
eslint-import-resolver-typescript: "npm:^3.6.1"
eslint-plugin-etc: "npm:^2.0.3"
eslint-plugin-import: "npm:^2.29.1"
eslint-plugin-jsdoc: "npm:^48.2.0"
eslint-plugin-jsdoc: "npm:^48.2.1"
eslint-plugin-sonarjs: "npm:^0.24.0"
mocha: "npm:^10.3.0"
react: "npm:18.2.0"
react-native: "npm:^0.73.5"
react-native-svg: "npm:^15.1.0"
react-test-renderer: "npm:^18.2.0"
semantic-release: "npm:^23.0.2"
semantic-release-yarn: "npm:^3.0.2"
Expand Down

0 comments on commit 0e015a7

Please sign in to comment.