Using Detox as Black Box tester - detox

I understand detox is a grey-box framework, but while going through iOS setup I see that the detox config is:
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/HelloWorld.app",
"build": "xcodebuild -project ios/example.xcodeproj -scheme example -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone 7"
So my question is Can I run Detox test on .app or .apk without integrating it in app first?
Say like appium I give it apk location and run test ?

That's how Detox works. You don't have to integrate it in your project. Just provide the .app's location in package.json.

Related

How can resolve error after expo run:ios -d ID

"xcodebuild -workspace LearnReactNative.xcworkspace -configuration Debug -scheme LearnReactNative -destination id=63F83D37-4D70-4681-8CBF-5235A5A93CF9"
this occurred after above scripts.
I try to reinstall xcode, repository.
What can I do ?

Detox on Android - can't run tests in parallel

I'm trying to speed up my detox e2e tests on Android so I thought I'll try to run them on multiple devices. I was able to easily do the same on iOS using the --workers flag but that doesn't seem to work at all on Android.
Here is my relevant detox config piece:
"android.sim.debug": {
"binaryPath": "...",
"build": "...",
"type": "android.attached",
"name": ".*"
},
Then I'm using this command to run the tests:
detox test --configuration android.sim.debug --workers 2
What I tried to do:
I fired up 2 emulators
I run detox tests with the command above
But the tests are only running on one of the emulators, the other one is being ignored
Any suggestions how can I run these tests on multiple emulators?

Detox build is failing by throwing YogaKit.modulemap' fatal error not found

Detox build is failing by throwing YogaKit.modulemap' fatal error not found
Xcode Version:- 11.3
"react": "16.11.0",
"react-native": "0.62.2"
"detox": "13.3.0", tried latest 16 version as well
But build got succeeded with the below configuration
"dependencies": {
"react": "^16.3.0-alpha.1",
"react-native": "0.59.9"
},
"devDependencies": {
"babel-jest": "22.4.1",
"babel-preset-react-native": "4.0.0",
"detox": "13.3.0",
"jest": "22.4.2",
"mocha": "^5.0.4",
"react-test-renderer": "^16.3.0-alpha.1"
** BUILD SUCCEEDED **
I think latest version of react-native is not compatible with the detox. I tried to get resolve for Yogakit, but ended with no luck.
Please let me know if anything is required. I would be thankful if someone shared the working config with the latest react-native.
`fatal error: module map file ....../ios/build/Build/Products/Debug-iphonesimulator/YogaKit/YogaKit.modulemap'
not found
1 error generated.
20 errors generated.
fatal error: module map file '...../ios/build/Build/Products/Debug-iphonesimulator/YogaKit/YogaKit.modulemap'
not found
1 error generated.
22 errors generated.
** BUILD FAILED **
The following build commands failed:
CompileC /....../ios/build/Build/Intermediates.noindex/King.build/Debug-iphonesimulator/King.build/Objects-normal/x86_64/AppDelegate.o /....../ios/King/AppDelegate.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
detox[29631] ERROR: [cli.js] Error: Command failed: xcodebuild -project ios/King.xcodeproj -scheme King -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build`
take a look at this config in package.json
"detox": {
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app",
"build": "xcodebuild -project ios/example.xcodeproj -scheme example -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone 11 Pro"
}
}
}
}
and take a look at that
For React Native 0.60 or above, or any other iOS apps in a workspace (eg: CocoaPods) use -workspace ios/example.xcworkspace instead of -project.
This is how I got it working:
Open xcworkspace file
Click on this :
http://files.simformsolutions.com.s3.amazonaws.com/simformscreen/ReactN.xcworkspace_2020-09-17_12-48-42.png
You will see such available options for your project/app as update
project settings to recommended :
http://files.simformsolutions.com.s3.amazonaws.com/simformscreen/ReactN.xcworkspace_2020-09-17_12-49-43.png
Click on the warnings and update the project to recommended settings, for all warnings.
On Convert to swift 5 available, if you click it, it will specifically show you the YogaKit module, click convert.
It will take time and voila!!
The build should succeed this time.
Xcode Menu -> File -> Save as Workspace -> (untitled name)
and then open that workspace file in the Xcode,
it will work
go to ios folder
open terminal
pod update
and then
https://www.youtube.com/watch?v=U30qHiEQWU8
I'm not sure what this Detox thing is so hopefully this isn't off topic
I came across this question by researching a missing YogaKit.modulemap not found kind of error (sorry I don't have the exact error) which I got after doing a pod install.
I fixed it by opening [project].xcworkspace then at the top Product > Clean Build Folder
OR
shift + command + k
Make sure Xcode has finished cleaning the build before trying to run the project again.
On the Podfile target post install ...
post_install do |installer|
flipper_post_install(installer)
installer.pods_project.targets.each do |target|
if target.name == 'YogaKit'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end

detox app could not be found, did you run './gradlew assembleAndroidTest'?

I am doing detox test for react native android version 0.57. I am getting this error.
Error is
Error: 'D:\folder\android\app\build\outputs\apk\androidTest\dev\debug\app-dev-debug-androidTest.apk' could not be found, did you run './gradlew assembleAndroidTest' ?
Package.json
"android.emu.debug": {
"binaryPath": "android/app/build/outputs/apk/dev/debug/app-dev-debug.apk",
"build": "cd android && .\\gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.attached",
"name": "192.168.83.101:5555"
}
Error picture
Detox has strange behavior where it mutates your path to your apk, if you specify it using binaryPath.
To specify the exact path to your apk, add an entry for testBinaryPath that points to the APK you want Detox to use.
This error is usually caused but not having built the test apk. It can usually be resolved by running
detox build -c android.emu.debug
If you make changes to your application you should always run the above script before running any test.
I usually run the following script to make sure that the build is uptodate before testing.
detox build -c android.emu.debug && detox test -c android.emu.debug
change path android/app/build/outputs/apk/dev/debug/app-dev-debug.apk to android/app/build/outputs/apk/debug/app-debug.apk
and detox automatically will create apk to path android/app/build/outputs/apk/AndroidTest/debug/app-debug-androidTest.apk

xctool tests fail when xcodebuild works - Travis CI

I'm trying to integrate my project into Travis CI, and my builds have failed with the following errors:
Undefined symbols for architecture i386 and Undefined symbols for architecture x86_64
I get these errors for basically every class in my project that hasn't been added to the test target under Target Membership. I could probably solve this by adding every single .m file as a member of the test target, but that doesn't really make much sense, and my
I've tried to replicate this issue locally by running both of the following commands:
xcodebuild -workspace myWorkspace.xcworkspace -scheme MyProjectTests -sdk iphonesimulator build test
xctool -workspace myWorkspace.xcworkspace -scheme MyProjectTests -sdk iphonesimulator build test
Using xcodebuild, it works, runs, and the tests pass. Using xctool the tests fail with the same errors that Travis is using, as Travis uses xctool.
Does anyone have any ideas if there's a best fix for this issue? I assume I missed something somewhere, but I followed the standard Travis 'Getting Started' walkthrough.
After fussing with this a bunch with no luck, it appears as though I'm able to set a custom script for Travis to use instead.. As mentioned, the xcodebuild worked, so I added the following to my travis.yml file and everything was all good:
script:
- xcodebuild -workspace myWorkspace.xcworkspace -scheme MyProjectTests -sdk iphonesimulator build test