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

[iOS] Tests stall in detox.init, error: [SRWebSocket sendString:error:]: unrecognized selector sent to instance #689

Closed
wildseansy opened this issue Apr 24, 2018 · 12 comments

Comments

@wildseansy
Copy link

wildseansy commented Apr 24, 2018

Description

I set up detox using the recommended instructions. My project builds, and but running detox test fails with the information below. My app is a hybrid app, but the very first screen presented in the app is a view controller with a react native view. I'm not doing anything fancy with the React Native bridge, everything is mostly using React Native defaults, but I have built in custom native RCT_EXPORT_MODULE plugins.

I ran with the debugging tools, and when I do that, everything works (sigh).

Looking through the detox project issues, this resembles #155, and #615.

Detox output
detox test  --configuration ios.sim.debug
node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.debug     --grep :android: --invert
detox info 1: Searching for device matching iPhone 7...
detox info 3: Uninstalling com.gixo.GixoRun...
detox info 3: com.gixo.GixoRun uninstalled
detox info 4: Installing /Users/seanholbert/proj/gixo/gixo-mobile/ios/build/Build/Products/Debug-iphonesimulator/GixoDebug.app...
detox info 4: /Users/seanholbert/proj/gixo/gixo-mobile/ios/build/Build/Products/Debug-iphonesimulator/GixoDebug.app installed
detox info 5: Terminating com.gixo.GixoRun...
detox info 5: com.gixo.GixoRun terminated
detox info 6: Launching com.gixo.GixoRun...
detox info 6: com.gixo.GixoRun launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/7CC04695-6102-4BD1-B795-7B7D791A0728/data/tmp/detox.last_launch_app_log.{out,err}
  1) "before all" hook

  0 passing (2m)
  1 failing

  1)  "before all" hook:
     Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
Detox server output
detox-server info 16:50:34: server listening on localhost:8099...
detox-server wss 16:50:47: role=tester login (sessionId=TestRun)
detox-server wss 16:50:47: role=tester action=loginSuccess (sessionId=TestRun)
detox-server wss 16:50:53: role=tester action=isReady (sessionId=TestRun)
detox-server wss 16:50:53: role=testee not connected, cannot fw action (sessionId=TestRun)
detox.last_launch_app_log.err
2018-04-24 16:50:56.167 Debug[5745:1949017] -[SRWebSocket sendString:error:]: unrecognized selector sent to instance 0x7ff871e00c20
2018-04-24 16:50:56.197 Debug[5745:1949017] -[SRWebSocket sendString:error:]: unrecognized selector sent to instance 0x7ff871e00c20
libc++abi.dylib: terminate_handler unexpectedly threw an exception
2018-04-24 16:50:56.198 Debug[5745:1949017] -[SRWebSocket sendString:error:]: unrecognized selector sent to instance 0x7ff871e00c20
2018-04-24 16:50:56.199 Debug[5745:1949017] -[SRWebSocket sendString:error:]: unrecognized selector sent to instance 0x7ff871e00c20
libc++abi.dylib: terminate_handler unexpectedly threw an exception...

When I run using detox 5.5.1, I get the exception below
Stack trace from detox.last_launch_app_log.err:

2018-04-24 16:35:18.567 Debug[99937:1919393] ☣️ DETOX:: Detox Action Sent: login
2018-04-24 16:35:18.567 Debug[99937:1919393] -[SRWebSocket sendString:error:]: unrecognized selector sent to instance 0x7ff50d603ac0
2018-04-24 16:35:18.584 Debug[99937:1919393] Uncaught exception: -[SRWebSocket sendString:error:]: unrecognized selector sent to instance 0x7ff50d603ac0; Stack trace:
0   CoreFoundation                      0x000000010f8201e6 __exceptionPreprocess + 294
1   libobjc.A.dylib                     0x0000000114fea031 objc_exception_throw + 48
2   CoreFoundation                      0x000000010f8a1784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3   CoreFoundation                      0x000000010f7a2898 ___forwarding___ + 1432
4   CoreFoundation                      0x000000010f7a2278 _CF_forwarding_prep_0 + 120
5   Detox                               0x000000010e904d77 -[WebSocket sendAction:withParams:withMessageId:] + 357
6   Detox                               0x000000010e905142 -[WebSocket webSocketDidOpen:] + 200
7   SocketRocket                        0x000000011158a35e __36-[SRWebSocket _HTTPHeadersDidFinish]_block_invoke + 130
8   EarlGrey                            0x0000000135aaa834 __60-[GREYDispatchQueueTracker grey_dispatchAsyncCallWithBlock:]_block_invoke + 36
9   libdispatch.dylib                   0x000000011996673b _dispatch_call_block_and_release + 12

Steps to Reproduce

init.js

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

before(async () => {
  await detox.init(config);
});

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

My test

const {device, expect, element, by, waitFor} = require('detox');
describe('Logged Out', () => {
  beforeEach(async () => {
    await device.reloadReactNative();
  });
  
  it('should have welcome screen', async () => {
    await expect(element(by.id('welcome-screen'))).toBeVisible();
  });

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 7.3.3 (also tried with 5.5.1)
  • React Native: 55.3
  • Node: v8.9.4
  • Device: iPhone 7 Simulator (iOS 11.3)
  • Xcode: 9.3
  • macOS: 10.13.4

Device and verbose Detox logs

My detox config:

"detox": {
    "test-runner": "mocha",
    "runner-config": "e2e/mocha.opts",
    "specs": "e2e",
    "configurations": {
      "ios.sim.release": {
        "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/AppCenter.app",
        "build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/MyApp.xcworkspace -scheme Release -configuration Release -sdk iphonesimulator -derivedDataPath ios/build -quiet",
        "type": "ios.simulator",
        "name": "iPhone 7",
        "session": {
          "server": "ws://localhost:8099",
          "sessionId": "TestRun"
        }
      },
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/GixoDebug.app",
        "build": "xcodebuild -workspace ios/MyApp.xcworkspace -scheme Debug -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone 7",
        "session": {
          "server": "ws://localhost:8099",
          "sessionId": "TestRun"
        }
      },
      "ios.none": {
        "binaryPath": "ios",
        "type": "ios.none",
        "name": "iPhone 7",
        "session": {
            "server": "ws://localhost:8099",
            "sessionId": "TestRun"
        }
      },
    }
}
@wildseansy wildseansy changed the title Test [iOS] Running tests gets stuck in beforeAll Apr 24, 2018
@wildseansy wildseansy changed the title [iOS] Running tests gets stuck in beforeAll [iOS] Running tests gets stuck in beforeAll, error= [SRWebSocket sendString:error:]: unrecognized selector sent to instance Apr 25, 2018
@wildseansy wildseansy changed the title [iOS] Running tests gets stuck in beforeAll, error= [SRWebSocket sendString:error:]: unrecognized selector sent to instance [iOS] Tests stall in detox.init, error= [SRWebSocket sendString:error:]: unrecognized selector sent to instance Apr 25, 2018
@wildseansy wildseansy changed the title [iOS] Tests stall in detox.init, error= [SRWebSocket sendString:error:]: unrecognized selector sent to instance [iOS] Tests stall in detox.init, error: [SRWebSocket sendString:error:]: unrecognized selector sent to instance Apr 25, 2018
@LeoNatan
Copy link
Contributor

In your app, do you make use of SocketRocket?

@wildseansy
Copy link
Author

yeah, we use socket rocket

@LeoNatan
Copy link
Contributor

Great, that explains your issue. I will look how to fix soon.

@wildseansy
Copy link
Author

Thanks @LeoNatan appreciate the help. Our dependency is

 pod 'SocketRocket',         '~> 0.5.1'

@LeoNatan
Copy link
Contributor

I added a fix. I have no way to test.

Just know that 0.5.1 of Socket Rocket is very old and there is mode modern API. The people that manage it now seem to forgot to add some tags. Facebook is not strong on versioning 🙄

@wildseansy
Copy link
Author

ah yeah, that makes sense. Maybe I'll try to compile it into our project how detox does it. Either way, knowing this, I'm sure I can find a work around until the next version of detox is released. Thanks!

@wildseansy
Copy link
Author

In case anyone else has this issue, for now I have added the following to my Podfile for getting tests running:

  pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git', :commit => '877ac74'

this commit is the same one that Detox points to. This fixes the [SRWebSocket sendString:error:]: unrecognized selector sent to instance errors.

@wildseansy
Copy link
Author

verified fixed in 7.3.4

@LeoNatan
Copy link
Contributor

In either case, stick with the newer SocketRocket.

@yogeshthanvi
Copy link

I am not able to update my detox using command npm update detox can anyone help me ?

@wildseansy
Copy link
Author

@yogeshthanvi - did you try changing your project package.json to have

 "detox": "^7.3.4"

And then run

rm -rf ./node_modules
npm install

@LeoNatan
Copy link
Contributor

@yogeshthanvi Please don't hijack issues for your problems. Also, GitHub issues is not the place for general usage questions. Please use Stack Overflow. This is the second time you do this in a very short time. Please abide by our community rules.

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

4 participants