Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

detox test fail on android #799

Closed
ibaozi-cn opened this issue Jun 28, 2018 · 12 comments
Closed

detox test fail on android #799

ibaozi-cn opened this issue Jun 28, 2018 · 12 comments

Comments

@ibaozi-cn
Copy link

ibaozi-cn commented Jun 28, 2018

Description

detox test fail on android

Steps to Reproduce

1 detox build -c android.emu.debug
2 detox test -c android.emu.debug

Detox, Node, Device, Xcode and macOS Versions

  • Detox:8.0.0
  • React Native:0.51.1
  • Node:8.11.3
  • Device:Nexus_5X_API_25
  • Xcode:9.3
  • macOS: 10.13.4

Device and verbose Detox logs

test.txt

@rotemmiz
Copy link
Member

Not enough info here, but try Emulator with API 27, does it work ?

@lalka-workco
Copy link
Contributor

After upgrading to Detox 8.0 I am also seeing my tests on Android timeout.

I don't have the best understanding of the entire Android connection process, but it looks like the first command is sent before the "isReady" command is received. Unfortunately I cannot provide a sample RN app since I am working with a client under NDA.

As you can see, the command that says look for element with text 'Log in' is executed after receiving the ready onMessage, but in 8.0.0 that command is executed before the ready onMessage.

Here are some sanitized sample logs:

Detox 7.3.7

/Users/kevinlalka/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws:/
/localhost:63793 -e detoxSessionId d9c6a296-fe14-918e-6d5b-f8e497b31666 -e debug false com.projectname.project.devrn
 test/android.support.test.runner.AndroidJUnitRunner
 34670mentation spawned, childProcess.pid:
 send: {"type":"isReady","params":{},"messageId":-1000}
 INSTRUMENTATION_STATUS: numtests=1
 INSTRUMENTATION_STATUS: stream=
 com.projectname.project.DetoxTest:
 INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
 INSTRUMENTATION_STATUS: test=runDetoxTests
 INSTRUMENTATION_STATUS: class=com.projectname.project.DetoxTest
 INSTRUMENTATION_STATUS: current=1
 INSTRUMENTATION_STATUS_CODE: 1
 nstrumentation stdout:
 onMessage: {"type":"ready","params":{},"messageId":-1000}
  rbx
 send: {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"pe
rform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"android.support.test.espresso.Espresso"}
,"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForText","args":["Log in"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"android.support.test.espresso.action.ViewActions"},"method":"click","args":[]}}]},"messageId":1}
 onMessage: {"type":"invokeResult","params":{"result":"(null)"},"messageId":1}

Detox 8.0.0

 3: stderr:
 send: {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"pe
rform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"android.support.test.espresso.Espresso"}
,"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForText","args":["Log in"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"android.support.test.espresso.action.ViewActions"},"method":"click","args":[]}}]},"messageId":1}
 INSTRUMENTATION_STATUS: numtests=1
 INSTRUMENTATION_STATUS: stream=
 com.projectname.project.DetoxTest:
 nstrumentation stdout:
 INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
 INSTRUMENTATION_STATUS: test=runDetoxTests
 INSTRUMENTATION_STATUS: class=com.projectname.project.DetoxTest
 INSTRUMENTATION_STATUS: current=1
 INSTRUMENTATION_STATUS_CODE: 1
 nstrumentation stdout:
 onMessage: {"type":"ready","params":{},"messageId":-1000}
  rbx
14: /Users/kevinlalka/Library/Android/sdk/platform-tools/adb -s emulator-5554 uninstall com.projectname.project.devr

 INSTRUMENTATION_RESULT: shortMsg=Process crashed.
 INSTRUMENTATION_CODE: 0
 nstrumentation stdout:
 nstrumentationProcess terminated due to receipt of signal null

@rotemmiz
Copy link
Member

Well, now that you can easily create logcat logs with artifacts manager, please provide them

@lalka-workco
Copy link
Contributor

lalka-workco commented Jun 28, 2018

I cannot generate the new artifacts. When I try to use the --record-logs all flag I get the following error:

Caught exception inside plugin (ADBLogcatPlugin) at phase onBeforeEach
 DetoxRuntimeError: DetoxRuntimeError: Detox Artifacts API had no app pid at the time of calling
     at Object.getPid (/Users/kevinlalka/Projects/dev/project-react-native-porting/node_modules/detox/src/artifacts/Art
ifactsManager.js:58:17)
     at ADBLogcatPlugin.createTestRecording (/Users/kevinlalka/Projects/dev/project-react-native-porting/node_modules/d
etox/src/artifacts/log/android/ADBLogcatPlugin.js:25:26)
     at ADBLogcatPlugin.createTestArtifact (/Users/kevinlalka/Projects/dev/project-react-native-porting/node_modules/de
tox/src/artifacts/templates/plugin/WholeTestRecorderPlugin.js:42:17)
     at ADBLogcatPlugin.onBeforeEach (/Users/kevinlalka/Projects/dev/project-react-native-porting/node_modules/detox/sr
c/artifacts/templates/plugin/WholeTestRecorderPlugin.js:17:30)
     at <anonymous>
     at process._tickCallback (internal/process/next_tick.js:188:7)

Since we are using Jest I used your example file from the Docs here

I'm not sure where the jasmine variable is coming from but I'm not sure we use that in our code, but removing that generates an error saying that line is required.

EDIT: My settings are a little different than @Papeone -- I am using RN 0.55.4, Node 9.2.0 and Nexus_5X_API_27 Emulator

@rotemmiz
Copy link
Member

Does 0.55 works for you with Detox 7 ??
If these logs don't work, try using adb logcat and paste the log here.

@lalka-workco
Copy link
Contributor

adblog.log

Yes, I have Android running on 7.3.7 now on another branch. I attached one test run, let me know if this is helpful. The app builds and launches to the home screen, but the first action never takes place and it timeouts.

@ibaozi-cn
Copy link
Author

ibaozi-cn commented Jul 4, 2018

I change detox version to 'v7.4.3',It can run normally,Thanks @lalka-workco @rotemmiz

@noomorph
Copy link
Collaborator

@lalka-workco , @Papeone , I was thinking about it lately... Do you have launchApp: false somewhere in detox.init() method call?

@lalka-workco
Copy link
Contributor

@noomorph Yes. It is in my init.js. I do not use the default because I need to set permissions for things like location and notifications.

// init.js

import detox from 'detox';

const config = require('../package.json').detox;

// Set the default test timeout of 120s
jest.setTimeout(120000);

beforeAll(async () => {
  await detox.init(config, { launchApp: false });
});

afterAll(async () => {
  await detox.cleanup();
});

@noomorph
Copy link
Collaborator

noomorph commented Jul 24, 2018

@lalka-workco , thanks much! I was fixing the other things around when a sudden realization struck me. It is indeed a bug in artifacts manager, and I already know where the problem is, and hopefully I'll get a fix for it released this week. Let's be in touch about this. Sorry for the inconveniences. 😊

UPD: created a dedicated issue to it: #856

@noomorph
Copy link
Collaborator

noomorph commented Jul 24, 2018

This issue thread is a duplicate of already existing issues, hereby I close it.

@Papeone had an issue described in: #831 (resolved in the unreleased yet ^8.0.1).
@lalka-workco had an issue described in: #856 (in progress).

@lock
Copy link

lock bot commented Jul 27, 2018

This thread has been automatically locked to prevent bumping of old threads. Instead, if you believe the issue still reproduces, please open a new issue and provide all the required information.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 27, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants