Detox: TypeError: Cannot read property 'bind' of undefined
I am facing some issues with running detox test
with jest
.
The error I am getting is:
detox test -c ios
detox[47286] INFO: [test.js] DETOX_CONFIGURATION="ios" DETOX_REPORT_SPECS=true DETOX_START_TIMESTAMP=1625074862848 DETOX_USE_CUSTOM_LOGGER=true jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
FAIL e2e/firstTest.e2e.jsrun...
● Test suite failed to run
TypeError: Cannot read property 'bind' of undefined
at jestAdapter (../node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:30:56)
detox[47286] ERROR: [cli.js] Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
package.json
{
"name": "trackout",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"e2e": "yarn e2e:build && yarn e2e:test",
"e2e:build": "detox build --configuration ios",
"e2e:test": " detox test --configuration ios"
},
"dependencies": {
"@react-native-async-storage/async-storage": "^1.15.5",
"react": "17.0.1",
"react-native": "^0.64.2",
"react-native-health": "^1.8.0",
"react-native-vector-icons": "^8.1.0"
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@babel/runtime": "^7.14.6",
"@react-native-community/eslint-config": "^3.0.0",
"@testing-library/jest-native": "^4.0.1",
"@testing-library/react-native": "^7.2.0",
"@types/jest": "^26.0.23",
"@types/react-native": "^0.64.10",
"@types/react-test-renderer": "^17.0.1",
"babel-jest": "^27.0.6",
"detox": "^18.18.1",
"eslint": "^7.29.0",
"eslint-plugin-detox": "^1.0.0",
"eslint-plugin-jest": "^24.3.6",
"jest": "^27.0.6",
"jest-circus": "^27.0.6",
"jest-expo": "^41.0.0",
"metro-react-native-babel-preset": "^0.66.0",
"react-test-renderer": "^17.0.2",
"regenerator-runtime": "^0.13.7",
"ts-jest": "^27.0.3",
"typescript": "^4.3.4"
},
"resolutions": {
"@types/react": "^17"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"setupFilesAfterEnv": [
"@testing-library/jest-native/extend-expect"
]
}
}
detoxrc.json
{
"testRunner": "jest",
"runnerConfig": "e2e/config.json",
"apps": {
"ios": {
"type": "ios.app",
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/TrackOut.app",
"build": "xcodebuild -workspace ios/TrackOut.xcworkspace -scheme TrackOut -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"device": {
"type": "iPhone 11"
}
},
"android": {
"type": "android.apk",
"binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY"
}
},
"devices": {
"simulator": {
"type": "ios.simulator",
"device": {
"type": "iPhone 11"
}
},
"emulator": {
"type": "android.emulator",
"device": {
"avdName": "Pixel_3a_API_30_x86"
}
}
},
"configurations": {
"ios": {
"device": "simulator",
"app": "ios"
},
"android": {
"device": "emulator",
"app": "android"
}
}
}
e2e/config.json and enviroment are the default generated from detox init
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18
@zRelux, @ibrahim7elmasry, @cpdyj, @nlmazhari, @gretzky
Like I originally suspected, there is a common denominator between your bug reports, and that is
jest-expo
.The problem is that 🤦 Expo dares to override
jest
’s symlink innode_modules/.bin
, i.e.:…instead of what Detox expects there to be normally:
Therefore, you are not launching the vanilla Jest but some custom wrapper enforced by
jest-expo
. 😞 Under the hood, from judging fromnpm ls jest
output, it uses an incompatible (and outdated) version of Jest, 25.x:Summarizing the above, you are caught between a rock and a hard place. The promptest workaround (warning: not tested on Windows) I might suggest for you case is using
detox.config.js
(JS, not JSON), where you evaluate the path to the nativejest
bin:@gretzky, you had a few more trivial errors in your Detox setup, but they are addressed in this commit in my fork: https://github.com/gretzky/detox-circus-legacy-issue-repro/compare/main...noomorph:hotfix?expand=1
My overall opinion is that it would be cool to resolve always the actual path to
jest
’s bin, but AFAIR I had difficulty with making it work on Windows (there they use*.ps1
wrappers instead of symlinks, and that fact ruined my first implementation attempt, unfortunately).I’ll try to make a safeguard mechanism for future situations like these soon in one of the upcoming minor versions of Detox.
Meanwhile, I’ll have to close this issue since it does not suggest any particular feature, and this is not a bug either. Please remind me if I forget to create a feature request with the item above (marked bold) within a day or two.
same for me. 26.6.3 works and all jest packages need to be at the same version.
Update jest to 26.6.3 or up it works with me
Try 27.0.5 and 26.6.3
26.6.3 works for me but 27.0.5 don’t.