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 hangs after failing test #383

Closed
jliebrand opened this issue Nov 3, 2017 · 2 comments
Closed

Detox hangs after failing test #383

jliebrand opened this issue Nov 3, 2017 · 2 comments

Comments

@jliebrand
Copy link

I'm trying to track down why detox seems to hang for me, so I've just created a really simple test which should fail (there is no 'foobar' element):

describe('Example', () => {
  it('should have welcome screen', async () => {
    await expect(element(by.id('foobar'))).toBeVisible();
  });
});

It launches my app successfully, and then fails (as expected), but then just hangs. It never shuts the app, nor does the test run end...

Using detox 5.9.3 and RN 0.49.1

Output from simulator:

2017-11-03 09:03:49.880 [info][tid:com.facebook.react.JavaScript] Running application "MyApp" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-l
evel warning are ON, performance optimizations are OFF
2017-11-03 09:03:49.973 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 3 failure reason: "duration>1.5"
2017-11-03 09:03:50.036 MyApp[48824:547410] ☣️ DETOX:: Detox Action Sent: ready
2017-11-03 09:03:50.044 MyApp[48824:547410] ☣️ DETOX:: Detox Action Received: invoke
2017-11-03 09:03:50.246 MyApp[48824:547410] ☣️ DETOX:: Test Failed:
Cannot find UI Element.
Exception with Assertion: {
  "Assertion Criteria" : "assertWithMatcher:matcherForSufficientlyVisible(>=0.750000)",
  "Element Matcher" : "(((respondsToSelector(accessibilityIdentifier) && accessibilityID('foobar')) && !(kindOfClass('RCTScrollView'))) || (kindOfClass('UIScrollView') && ((kindOfCl
ass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(((respondsToSelector(accessibilityIdentifier) && accessibilityID('foobar')) && kindOfClass('RCTSc
rollView'))))))",
  "Recovery Suggestion" : "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element."
}

Error Trace: [
  {
    "Description" : "Interaction cannot continue because the desired element was not found.",
    "Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
    "Error Code" : "0",
    "File Name" : "GREYElementInteraction.m",
    "Function Name" : "-[GREYElementInteraction matchedElementsWithTimeout:error:]",
    "Line" : "124"
  }
]
2017-11-03 09:03:50.248 MyApp[48824:547410] ☣️ DETOX:: UI Hierarchy on test failure:
<UIWindow:0x7fe374613ed0; AX=N; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 667}};o
paque; alpha=1>
  |--<RCTRootView:0x7fe374505200; AX=N; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375,
 667}}; opaque; alpha=1>
  |  |--<RCTRootContentView:0x7fe374509c20; AX=N; AX.label='hello'; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focus
ed='N'; frame={{0, 0}, {375, 667}}; opaque; alpha=1>
  |  |  |--<RCTView:0x7fe374424db0; AX=N; AX.label='hello'; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N';f
rame={{0, 0}, {375, 667}}; opaque; alpha=1>
  |  |  |  |--<RCTView:0x7fe374424b40; AX=N; AX.label='hello'; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N
'; frame={{0, 0}, {375, 667}}; opaque; alpha=1>
  |  |  |  |  |--<RCTView:0x7fe3744248d0; AX=N; AX.label='hello'; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused
='N'; frame={{0, 0}, {375, 667}}; opaque; alpha=1>
  |  |  |  |  |  |--<RCTText:0x7fe3744231f0; AX=Y; AX.label='hello'; AX.frame={{0, 0}, {375, 17}}; AX.activationPoint={187.5, 8.5}; AX.traits='UIAccessibilityTraitStaticText'; AX.f
ocused='N'; frame={{0, 0}, {375, 17}}; alpha=1>
2017-11-03 09:03:50.248 MyApp[48824:547410] ☣️ DETOX:: Detox Action Sent: testFailed
2017-11-03 09:03:50.249 MyApp[48824:547410] ☣️ DETOX:: Test Failed:
Cannot find UI Element.
Exception with Assertion: {
  "Assertion Criteria" : "assertWithMatcher:matcherForSufficientlyVisible(>=0.750000)",
  "Element Matcher" : "(((respondsToSelector(accessibilityIdentifier) && accessibilityID('foobar')) && !(kindOfClass('RCTScrollView'))) || (kindOfClass('UIScrollView') && ((kindOfCl
ass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(((respondsToSelector(accessibilityIdentifier) && accessibilityID('foobar')) && kindOfClass('RCTSc
rollView'))))))",
  "Recovery Suggestion" : "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element."
}

Error Trace: [
  {
    "Description" : "Interaction cannot continue because the desired element was not found.",
    "Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
    "Error Code" : "0",
    "File Name" : "GREYElementInteraction.m",
    "Function Name" : "-[GREYElementInteraction matchedElementsWithTimeout:error:]",
    "Line" : "124"
  }
]
2017-11-03 09:03:50.251 MyApp[48824:547410] ☣️ DETOX:: UI Hierarchy on test failure:
<UIWindow:0x7fe374613ed0; AX=N; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375, 667}};o
paque; alpha=1>
  |--<RCTRootView:0x7fe374505200; AX=N; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {375,
 667}}; opaque; alpha=1>
  |  |--<RCTRootContentView:0x7fe374509c20; AX=N; AX.label='hello'; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focus
ed='N'; frame={{0, 0}, {375, 667}}; opaque; alpha=1>
  |  |  |--<RCTView:0x7fe374424db0; AX=N; AX.label='hello'; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N';f
rame={{0, 0}, {375, 667}}; opaque; alpha=1>
  |  |  |  |--<RCTView:0x7fe374424b40; AX=N; AX.label='hello'; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N
'; frame={{0, 0}, {375, 667}}; opaque; alpha=1>
  |  |  |  |  |--<RCTView:0x7fe3744248d0; AX=N; AX.label='hello'; AX.frame={{0, 0}, {375, 667}}; AX.activationPoint={187.5, 333.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused
='N'; frame={{0, 0}, {375, 667}}; opaque; alpha=1>
  |  |  |  |  |  |--<RCTText:0x7fe3744231f0; AX=Y; AX.label='hello'; AX.frame={{0, 0}, {375, 17}}; AX.activationPoint={187.5, 8.5}; AX.traits='UIAccessibilityTraitStaticText'; AX.f
ocused='N'; frame={{0, 0}, {375, 17}}; alpha=1>
2017-11-03 09:03:50.261 MyApp[48824:547410] ☣️ DETOX:: Detox Action Received: cleanup
2017-11-03 09:03:50.262 MyApp[48824:547410] ☣️ DETOX:: Detox Action Sent: cleanupDone
2017-11-03 09:03:51.985 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 4 failure reason: "duration>1.5"
2017-11-03 09:03:54.000 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 5 failure reason: "duration>1.5"
2017-11-03 09:03:56.015 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 6 failure reason: "duration>1.5"
2017-11-03 09:03:58.030 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 7 failure reason: "duration>1.5"
2017-11-03 09:04:00.046 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 8 failure reason: "duration>1.5"
2017-11-03 09:04:02.058 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 9 failure reason: "duration>1.5"
2017-11-03 09:04:04.073 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 10 failure reason: "duration>1.5"
2017-11-03 09:04:06.088 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 11 failure reason: "duration>1.5"
2017-11-03 09:04:08.103 MyApp[48824:547430] ☣️ DETOX:: Ignoring timer: 12 failure reason: "duration>1.5"

(Those calls about ignoring timer keep repeating endlessly)

@jliebrand
Copy link
Author

Just tested on a completely clean react native app and the same problem persists.

{
	"name": "DetoxTest",
	"version": "0.0.1",
	"private": true,
	"scripts": {
		"start": "node node_modules/react-native/local-cli/cli.js start",
		"test": "jest"
	},
	"dependencies": {
		"react": "16.0.0-beta.5",
		"react-native": "0.49.5"
	},
	"detox": {
		"configurations": {
			"ios.sim.debug": {
				"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/DetoxTest.app",
				"build": "xcodebuild -project ios/DetoxTest.xcodeproj -scheme DetoxTest -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
				"type": "ios.simulator",
				"name": "iPhone 7"
			}
		}
	},
	"devDependencies": {
		"babel-jest": "21.2.0",
		"babel-polyfill": "^6.26.0",
		"babel-preset-react-native": "4.0.0",
		"detox": "^5.9.3",
		"jest": "21.2.1",
		"mocha": "^4.0.1",
		"react-test-renderer": "16.0.0-beta.5"
	},
	"jest": {
		"preset": "react-native"
	}
}

with:

describe('Example', () => {
  beforeEach(async () => {
    await device.reloadReactNative();
  });

  it('should have welcome screen', async () => {
    await expect(element(by.id('foobar'))).toBeVisible();
  });

  it('should show hello screen after tap', async () => {
    await element(by.id('hello_button')).tap();
    await expect(element(by.text('Hello!!!'))).toBeVisible();
  });

  it('should show world screen after tap', async () => {
    await element(by.id('world_button')).tap();
    await expect(element(by.text('World!!!'))).toBeVisible();
  });
})

@LeoNatan
Copy link
Contributor

LeoNatan commented Nov 6, 2017

The problem is in Mocha 4.0. Use Mocha 3.5.
Also, please search existing issues before starting a new one. #368

@LeoNatan LeoNatan closed this as completed Nov 6, 2017
@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

2 participants