When running detox test with detox 8 I get the following error:
detox[7016] INFO: [DetoxServer.js] server listening on localhost:56121...
detox[7016] ERROR: [exec.js/EXEC_FAIL, #1] "C:\Users\stina.emrikstrand\AppData\Local\Android\sdk\platform-tools\adb -s emulator-5554 shell dumpsys power | findstr /R /C:"^\sm[UW].="" failed with code = 1, stdout and stderr:
detox[7016] ERROR: [exec.js/EXEC_FAIL, #1]
detox[7016] ERROR: [exec.js/EXEC_FAIL, #1]
detox[7016] ERROR: [index.js/DETOX_INIT_ERROR]
{ ChildProcessError: Command failed: C:\Users\stina.emrikstrand\AppData\Local\Android\sdk\platform-tools\adb -s emulator-5554 shell dumpsys power | findstr /R /C:"^\sm[UW].="
C:\Users\stina.emrikstrand\AppData\Local\Android\sdk\platform-tools\adb -s emulator-5554 shell dumpsys power | findstr /R /C:"^\s*m[UW].*=" (exited with error code 1)
at callback (C:\Users\stina.emrikstrand\code\App\powerup\node_modules\child-process-promise\lib\index.js:33:27)
at ChildProcess.exithandler (child_process.js:295:5)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:962:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:249:5)
I have located the problem to that windows _findstr_ does not support /s in regex. If I replace the line:
_const stdout = await this.shell(deviceId, dumpsys power | ${grep('^\\s*m[UW].*=')});_
with
_const stdout = await this.shell(deviceId, dumpsys power | ${grep('^ *m[UW].*=')});_
in detox/src/devices/android/ADB.js, it seems to work, for windows at least. I'm not sure about other OS, and since I'm not a developer I'm not sure this is the best way of solving it either :)
Hmmm.... looks fair, though weird a bit - I'm almost sure I tested that, but maybe I forgot something. What Windows version, you say?
Sorry for the missing information. I'm using windows 10.
As I understand from the documentation, findstr is very limited regarding the regex metacharacters: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/findstr :(
@dat00ste, no worries. 馃憤 I just did not want to enforce Windows users of Detox to install grep. Sad that findstr is so weak, but anyway your suggestion with a less stricter regexp should work just fine.
I've submitted a pull request with a bugfix already.
I hope that a hotfix version will appear in the next few days, maybe today if we are very lucky.
P.S. And extra thanks for investigating the issue before submitting it. 馃
Great, thanks!
Im not sure but maybe it needs to be replaced in this line as well?:
_const bundleIdRegex = pipeCommands.escape.inQuotedRegexp(bundleId) + '\s*$';_
@dat00ste, it is a good question. I clearly remember it worked just fine on Windows... hmm.
@dat00ste, right you are! apparently, it was looking for s* not [ ]*. Thanks much!
No problem, happy to help :).