Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
nodejs: [18, 19, 20, 21, 22.6,]
nodejs: [18, 19, 20, 21, 22, 23]

steps:
- uses: actions/checkout@v4
Expand All @@ -27,4 +27,6 @@ jobs:
- run: yarn build
- run: yarn compile
- run: yarn lint
- run: yarn test
- run: yarn test:ci
env:
NODE_OPTIONS: "${{ matrix.nodejs >= 20 && '--no-experimental-detect-module' }}"
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
with:
node-version-file: .nvmrc
cache: yarn
- run: yarn install --immutable
- uses: github/codeql-action/init@v3
with:
languages: javascript-typescript
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.6.0
23.11.0
934 changes: 0 additions & 934 deletions .yarn/releases/yarn-4.6.0.cjs

This file was deleted.

948 changes: 948 additions & 0 deletions .yarn/releases/yarn-4.9.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ plugins:
path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js"

yarnPath: .yarn/releases/yarn-4.6.0.cjs
yarnPath: .yarn/releases/yarn-4.9.1.cjs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ But what if you don't want to use Jest as your testing framework? What if you do
- **react:** >=18.2.0
- **react-native:** ">=0.73.2

> **NOTE:** Node.js [enabled the `--experimental-detect-module` flag](https://github.com/nodejs/node/releases/tag/v22.7.0) on v22.7.0 by default. This raises an issue when transforming Flow code with Babel, so we're not supporting v22.7+ until the flag remains experimental and all issues are resolved.
> **NOTE:** Node.js [enabled the `--experimental-detect-module` flag](https://github.com/nodejs/node/releases/tag/v22.7.0) on v22.7.0 by default. This raises an issue when Node finds Flow code before even getting into Babel transforms. If you are using Node.js v20 or higher, it's recommended that you run your tests with `NODE_OPTIONS="--no-experimental-detect-module"` environment variable.

## Install

Expand Down
6 changes: 0 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default eslintTs.config(
sonarjs.configs.recommended,
stylistic.configs.customize({
braceStyle: "1tbs",
flat: true,
quotes: "double",
semi: true,
}),
Expand Down Expand Up @@ -169,9 +168,6 @@ export default eslintTs.config(
curly: "error",
eqeqeq: "error",
"func-style": ["error", "declaration", { allowArrowFunctions: true }],
"import/default": "off",
"import/named": "off",
"import/namespace": "off",
"import/newline-after-import": "error",
"import/no-absolute-path": "error",
"import/no-cycle": ["error", {
Expand All @@ -181,7 +177,6 @@ export default eslintTs.config(
}],
"import/no-duplicates": ["error", { "prefer-inline": true }],
"import/no-import-module-exports": "error",
"import/no-named-as-default-member": "off",
"import/no-namespace": ["error", { ignore: ["eslint-plugin-import"] }],
"import/no-relative-packages": "error",
"import/no-unresolved": "error",
Expand Down Expand Up @@ -242,7 +237,6 @@ export default eslintTs.config(
"sonarjs/different-types-comparison": "off",
"sonarjs/function-return-type": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-empty-function": "off",
"sonarjs/no-extend-native": "off",
"sonarjs/no-nested-functions": "off",
"sonarjs/no-selector-parameter": "off",
Expand Down
65 changes: 32 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,62 +51,61 @@
"./package.json"
],
"engines": {
"node": ">=18 <=22.6"
"node": ">=18"
},
"scripts": {
"build": "vite build",
"check": "yarn build && yarn compile && yarn lint && yarn test --run",
"compile": "tsc",
"lint": "eslint .",
"release": "semantic-release",
"test": "vitest"
"test": "NODE_OPTIONS=\"--no-experimental-detect-module\" vitest",
"test:ci": "vitest"
},
"packageManager": "yarn@4.5.3",
"packageManager": "yarn@4.9.1",
"dependencies": {
"@babel/core": "^7.26.0",
"@babel/core": "^7.26.10",
"@babel/register": "^7.25.9",
"babel-plugin-extension-resolver": "^1.0.12",
"debug": "^4.4.0",
"dot-prop-immutable": "^2.1.1",
"rewiremock": "^3.14.5",
"supports-color": "^10.0.0",
"ts-pattern": "^5.6.0"
"ts-pattern": "^5.7.0"
},
"devDependencies": {
"@assertive-ts/core": "^2.1.0",
"@eslint/js": "^9.17.0",
"@react-native/babel-preset": "^0.76.5",
"@stylistic/eslint-plugin": "^2.12.1",
"@testing-library/react-native": "^12.9.0",
"@eslint/js": "^9.24.0",
"@react-native/babel-preset": "^0.79.1",
"@stylistic/eslint-plugin": "^4.2.0",
"@testing-library/react-native": "^13.2.0",
"@types/babel__core": "^7.20.5",
"@types/babel__register": "^7.17.3",
"@types/debug": "^4.1.12",
"@types/eslint__js": "^8.42.3",
"@types/node": "^22.10.2",
"@types/react": "^19.0.2",
"@types/react-test-renderer": "^19.0.0",
"@types/sinon": "^17.0.3",
"eslint": "^9.17.0",
"eslint-import-resolver-typescript": "^3.7.0",
"@types/node": "^22.14.1",
"@types/react": "^19.1.2",
"@types/react-test-renderer": "^19.1.0",
"@types/sinon": "^17.0.4",
"eslint": "^9.24.0",
"eslint-import-resolver-typescript": "^4.3.2",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^50.6.1",
"eslint-plugin-perfectionist": "^4.4.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-sonarjs": "^3.0.1",
"globals": "^15.14.0",
"react": "19.0.0",
"react-native": "^0.76.5",
"react-native-svg": "^15.10.1",
"react-test-renderer": "^19.0.0",
"semantic-release": "^24.2.0",
"eslint-plugin-jsdoc": "^50.6.9",
"eslint-plugin-perfectionist": "^4.11.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-sonarjs": "^3.0.2",
"globals": "^16.0.0",
"react": "19.1.0",
"react-native": "^0.79.1",
"react-native-svg": "^15.11.2",
"react-test-renderer": "^19.1.0",
"semantic-release": "^24.2.3",
"semantic-release-yarn": "^3.0.2",
"sinon": "^19.0.2",
"sinon": "^20.0.0",
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.2",
"vite": "^6.0.5",
"vite-plugin-dts": "^4.4.0",
"vitest": "^2.1.8"
"typescript": "^5.8.3",
"typescript-eslint": "^8.30.1",
"vite": "^6.2.6",
"vite-plugin-dts": "^4.5.3",
"vitest": "^3.1.1"
},
"peerDependencies": {
"@react-native/babel-preset": ">=0.73.18",
Expand Down
1 change: 0 additions & 1 deletion src/helpers/nativeMethodsMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const nativeMethodsMock: NativeMethods = {
measure: noop,
measureInWindow: noop,
measureLayout: noop,
refs: { },
setNativeProps: noop,
};

Expand Down
3 changes: 3 additions & 0 deletions src/lib/Components/AccessibilityInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { noop } from "../../helpers/commons";
export const AccessibilityInfoMock = {
addEventListener: (): unknown => ({ remove: noop }),
announceForAccessibility: noop,
announceForAccessibilityWithOptions: noop,
getRecommendedTimeoutMillis: noop,
isAccessibilityServiceEnabled: noop,
isBoldTextEnabled: noop,
isDarkerSystemColorsEnabled: (): Promise<boolean> => Promise.resolve(false),
isGrayscaleEnabled: noop,
isHighTextContrastEnabled: (): Promise<boolean> => Promise.resolve(false),
isInvertColorsEnabled: noop,
isReduceMotionEnabled: noop,
isReduceTransparencyEnabled: noop,
Expand Down
29 changes: 29 additions & 0 deletions src/lib/Core/NativeModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export const NativeModulesMock = {
},
ImageLoader: {
getSize: () => Promise.resolve([320, 240]),
getSizeWithHeaders: () => Promise.resolve({ height: 222, width: 333 }),
prefetchImage: noop,
prefetchImageWithMetadata: noop,
queryCache: noop,
},
ImageViewManager: {
getSize: (_uri: string, success: CB) => process.nextTick(() => success(320, 240)),
Expand All @@ -69,6 +72,32 @@ export const NativeModulesMock = {
addListener: noop,
removeListeners: noop,
},
NativeAnimatedModule: {
addAnimatedEventToView: noop,
addListener: noop,
connectAnimatedNodes: noop,
connectAnimatedNodeToView: noop,
createAnimatedNode: noop,
disconnectAnimatedNodeFromView: noop,
disconnectAnimatedNodes: noop,
dropAnimatedNode: noop,
extractAnimatedNodeOffset: noop,
flattenAnimatedNodeOffset: noop,
getValue: noop,
removeAnimatedEventFromView: noop,
removeListener: noop,
removeListeners: noop,
restoreDefaultValues: noop,
setAnimatedNodeOffset: noop,
setAnimatedNodeValue: noop,
startAnimatingNode: (_animationId: unknown, _nodeTag: unknown, _config: unknown, endCallback: CB) => {
setTimeout(() => endCallback({ finished: true }), 16);
},
startListeningToAnimatedNodeValue: noop,
stopAnimation: noop,
stopListeningToAnimatedNodeValue: noop,
updateAnimatedNodeConfig: noop,
},
Networking: {
abortRequest: noop,
addListener: noop,
Expand Down
18 changes: 7 additions & 11 deletions src/lib/babelRegister.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import register from "@babel/register";

register({
cache: true,
only: [/[/\\]node_modules[/\\](react-native|@react-native)[/\\]/],
plugins: [
["extension-resolver", {
extensions: [
".ios.js",
".ios.jsx",
".js",
".jsx",
],
}],
cache: false,
extensions: [
".ios.js",
".ios.jsx",
".js",
".jsx",
],
only: [/[/\\]node_modules[/\\](react-native|@react-native)[/\\]/],
presets: ["module:@react-native/babel-preset"],
});
6 changes: 3 additions & 3 deletions src/lib/coreMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Object.assign(global, { jest: { fn: () => noop } });

replace("react-native/Libraries/Core/InitializeCore", () => ({ }));
replace("react-native/Libraries/Core/NativeExceptionsManager", () => ({ }));
replace("react-native/Libraries/ReactNative/UIManager", () => UIManagerMock);
replace("react-native/Libraries/Linking/Linking", () => LinkingMock);
replace("react-native/Libraries/BatchedBridge/NativeModules", () => NativeModulesMock);
replace("react-native/Libraries/ReactNative/UIManager", () => ({ default: UIManagerMock }));
replace("react-native/Libraries/Linking/Linking", () => ({ default: LinkingMock }));
replace("react-native/Libraries/BatchedBridge/NativeModules", () => ({ default: NativeModulesMock }));
replace("react-native/Libraries/NativeComponent/NativeComponentRegistry", () => NativeComponentRegistryMock);
replace("react-native/Libraries/ReactNative/requireNativeComponent", () => ({ default: mockNativeComponent }));
replace("react-native/Libraries/ReactNative/RendererProxy", () => RendererProxyMock);
20 changes: 10 additions & 10 deletions src/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ import { ViewNativeComponentMock } from "./lib/Components/ViewNativeComponent";

const libs = "react-native/Libraries";

replace(`${libs}/Image/Image`, () => ImageMock);
replace(`${libs}/Text/Text`, () => TextMock);
replace(`${libs}/Components/TextInput/TextInput`, () => TextInputMock);
replace(`${libs}/Modal/Modal`, () => ModalMock);
replace(`${libs}/Image/Image`, () => ({ default: ImageMock }));
replace(`${libs}/Text/Text`, () => ({ default: TextMock }));
replace(`${libs}/Components/TextInput/TextInput`, () => ({ default: TextInputMock }));
replace(`${libs}/Modal/Modal`, () => ({ default: ModalMock }));
replace(`${libs}/Components/AccessibilityInfo/AccessibilityInfo`, () => ({ default: AccessibilityInfoMock }));
replace(`${libs}/Components/Clipboard/Clipboard`, () => ClipboardMock);
replace(`${libs}/Components/RefreshControl/RefreshControl`, () => RefreshControlMock);
replace(`${libs}/Components/ScrollView/ScrollView`, () => ScrollViewMock);
replace(`${libs}/Components/Clipboard/Clipboard`, () => ({ default: ClipboardMock }));
replace(`${libs}/Components/RefreshControl/RefreshControl`, () => ({ default: RefreshControlMock }));
replace(`${libs}/Components/ScrollView/ScrollView`, () => ({ default: ScrollViewMock }));
replace(`${libs}/Components/ActivityIndicator/ActivityIndicator`, () => ({ default: ActivityIndicatorMock }));
replace(`${libs}/AppState/AppState`, () => AppStateMock);
replace(`${libs}/Vibration/Vibration`, () => VibrationMock);
replace(`${libs}/Components/View/View`, () => ViewMock);
replace(`${libs}/AppState/AppState`, () => ({ default: AppStateMock }));
replace(`${libs}/Vibration/Vibration`, () => ({ default: VibrationMock }));
replace(`${libs}/Components/View/View`, () => ({ default: ViewMock }));
replace(`${libs}/Components/View/ViewNativeComponent`, () => ViewNativeComponentMock);
replace(`${libs}/Animated/Animated`, () => ({ default: AnimatedMock }));

Expand Down
Loading