Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Detox fails to run tests with jest(with both new and old implementations) #363

Closed
aamorozov opened this issue Oct 24, 2017 · 16 comments
Closed

Comments

@aamorozov
Copy link

aamorozov commented Oct 24, 2017

Description

Was trying different ways but can't get it to work. Wondering if it's an issue on my side(most likely) or there is some incompatibility with newer versions.

It might be related to this issue #330 as I recently installed new Xcode 9.

e2e.setup.js

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

// Set the default timeout
jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000;

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

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

jest.config-e2e.json

{
  "preset": "react-native",
  "testMatch": ["**/app/__tests__/e2e/specs/?(*.)(spec|test).js?(x)"],
  "setupTestFrameworkScriptFile": "./e2e.setup.js"
}

package.json

"detox": {
    "runner": "jest",
    "specs": "./app/__tests__/e2e/specs/",
    "configurations": {
      "ios.sim.debug": {
        "binaryPath":
          "ios/build/Build/Products/Debug-iphonesimulator/appname.app",
        "build":
          "xcodebuild -workspace ios/appname.xcworkspace -configuration Debug -scheme appscheme -sdk iphonesimulator -derivedDataPath build",
        "type": "ios.simulator",
        "name": "iPhone 7"
      }
    }
  }

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 5.9.2
  • Node: v8.7.0
  • Device: Iphone 7
  • Xcode: 9
  • macOS: Sierra v.10.12.6
  • React-native: 0.49.3
  • React: 16.0.0

Device and verbose Detox logs

When running jest directly with detox build && jest --verbose --runInBand --forceExit -c ./jest.config-e2e.json, it hangs on "Searching for device".

** BUILD SUCCEEDED **

 server listening on localhost:52384...
 : Searching for device matching iPhone 7...

 RUNS  app/__tests__/e2e/specs/eventsSection.test.js

After making the updates specified in https://github.com/wix/detox/blob/master/docs/Guide.Jest.md. Running detox build && detox test:

ReferenceError: element/device is not defined  // with
Cannot determine which configuration to use. use --configuration to choose one of the following:
                          ios.sim.debug
@sibelius
Copy link

you need to set configuration

-c ios.sim.debug

check this #355

@aamorozov
Copy link
Author

aamorozov commented Oct 24, 2017

@sibelius Thanks! But still no luck. After this output it just lists all available devices and then just hangs on the first test loading without actually booting the device

node_modules/.bin/jest ./app/__tests__/e2e/specs/ --runInBand
 rror: Could not create artifacts root dir: undefined/detox_artifacts.2017-10-24T15:53:17.410Z
 server listening on localhost:52611...
 onOpen [object Object]
 send: {"type":"login","params":{"sessionId":"3f44c35c-70cb-7b32-c469-03bf9c190f44","role":"tester"},"messageId":0}
 role=tester login (sessionId=3f44c35c-70cb-7b32-c469-03bf9c190f44)
 role=tester action=loginSuccess (sessionId=3f44c35c-70cb-7b32-c469-03bf9c190f44)
 onMessage: {"type":"loginSuccess","params":{"sessionId":"3f44c35c-70cb-7b32-c469-03bf9c190f44","role":"tester"},"messageId":0}
  rbx
 : applesimutils --list "iPhone 7" --maxResults=1
 : Searching for device matching iPhone 7...
 [ stdout:
   {tdout:
     "state" : "Booted",
     "availability" : "(available)",
     "name" : "iPhone 7",
     "udid" : "AB98DA1E-A01A-4A5F-B82C-C46B2BDC1DDE",
     "os" : {
       "version" : "11.0.1",
       "availability" : "(available)",
       "name" : "iOS 11.0",
       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-0",
       "buildversion" : "15A8401"
     }out:
   }tdout:

@sibelius
Copy link

-a e2e

@aamorozov
Copy link
Author

@sibelius Nope, same thing. I'm confused about the stdout cause it shows that the simulator is being booted/app launched but the simulator actually doesn't run:

5: app launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/AB98DA1E-A01A-4A5F-B82C-C46B2BDC1DDE/data/tmp/detox.last_launch_app_log.{out,e r}
 send: {"type":"isReady","params":{},"messageId":-1000}
 role=tester action=isReady (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=testee not connected, cannot fw action (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=testee login (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=testee action=loginSuccess (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=testee disconnect (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)

@aamorozov
Copy link
Author

It also seems like the test is running and is trying to locate the elements when the simulator is down.. ¯\_(ツ)_/¯ :

 role=testee disconnect (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 send: {"type":"invoke","params":{"target":{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"detox_matcherForAccessibilityLabel:","args":[{"type":"NSString","value":"Continue"}]}}]}},"method":"assertWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForSufficientlyVisible","args":[]}}]},"messageId":1}
 send: {"type":"currentStatus","params":{},"messageId":2}
 role=tester action=invoke (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=testee not connected, cannot fw action (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=tester action=currentStatus (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=testee not connected, cannot fw action (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 send: {"type":"invoke","params":{"target":{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"detox_matcherForAccessibilityLabel:","args":[{"type":"NSString","value":"Events"}]}}]}},"method":"assertWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForSufficientlyVisible","args":[]}}]},"messageId":3}
 send: {"type":"currentStatus","params":{},"messageId":4}
 role=tester action=invoke (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=testee not connected, cannot fw action (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=tester action=currentStatus (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)
 role=testee not connected, cannot fw action (sessionId=12e98044-ba86-e999-58f4-588f2904eefe)

@khirakawa
Copy link

I'm having similar issues as well. FWIW, here's what I'm using:

  • Detox: 5.9.2
  • Node: v8.6.0
  • Device: Iphone 7
  • Xcode: 8.3.3
  • macOS: Sierra v.10.12.3
  • React-native: 0.48.4
  • React: 16.0.0-alpha.12

@khirakawa
Copy link

Interestingly, if I run node_modules/.bin/jest instead of detox test -c ios.sim.debug, I can get the tests to pass.

@SMJ93
Copy link
Contributor

SMJ93 commented Oct 25, 2017

@khirakawa @aamorozov If you load up the simulator before hand through xcode or open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app what happens?

@aamorozov
Copy link
Author

aamorozov commented Oct 25, 2017

@SMJ93 For me it runs the simulator, builds the package, but once it tries to run the tests it crashes the app right away(without showing the launch screen) and then the process just hangs on the first test case. That actually happens even after I downgraded detox back to 5.6.2

@SMJ93
Copy link
Contributor

SMJ93 commented Oct 25, 2017

@aamorozov We experienced something similar with React Native Firebase on iOS using Mocha. Updating my pods, React Native and detox solved it for me, but it looks like you're fully up to date.

I am taking a look at the Jest test runner as we speak. It is causing us issues with Android #362, i'll keep you updated.

@SMJ93
Copy link
Contributor

SMJ93 commented Oct 25, 2017

@aamorozov I get the same issue when running ios e2e tests with jest on the example project.

@LeoNatan
Copy link
Contributor

Hello,

We are moving support questions to Stack Overflow. Please ask a question there with the detox tag. This section is only meant for Detox issues and enhancement requests.

Thanks

@SMJ93
Copy link
Contributor

SMJ93 commented Nov 16, 2017

@LeoNatan PR #371 fixes this issue. Can this remain open until that PR is merged in?

@LeoNatan
Copy link
Contributor

Sure.

@LeoNatan LeoNatan reopened this Nov 16, 2017
@rotemmiz
Copy link
Member

Fixed in #423

@SMJ93
Copy link
Contributor

SMJ93 commented Nov 28, 2017

Cheers @rotemmiz. When is the next planned release?

@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants