Closed tachtevrenidis closed 6 years ago
my init.js looks like this:
const detox = require('detox');
const config = require('../package.json').detox;
// these are changes for when the 'screenshots' feature is released in detox
const adapter = require('detox/runners/mocha/adapter');
before(async () => {
await detox.init(config);
});
beforeEach(async function () {
await adapter.beforeEach(this);
});
afterEach(async function () {
await adapter.afterEach(this);
});
after(async () => {
await detox.cleanup();
});
I'm not sure if I can investigate it within the next few days. Hopefully on Monday I'll be able to take a good look at it.
The only thing that looks kinda "suspicious" to me is the --reuse
flag in your use case. Try running without it and let's see if it helps. If (suddenly!) yes, then let's file it as a bug.
I tried with and without --reuse, the outcome is the same. I looked at the code a little, some observations:
1) there is a method in detox called 'takeScreenshot', that method is NEVER called (added console.log to debug) 2) video recording does not work also 3) when i run detox test, if detox has to boot a simulator, then I see a simctl instruction to the simulator, to take a screenshot but with params 'dev/null' which results in a noop. No further screenshot instructions 4) I tried with a custom artifacts dir but nothing 5) I tried with a test that passes and another one that fails on purpose, still nothing
I hope this helps!
Yes. That helps. I had once a similar issue.
Ensure your beforeEach and afterEach statements indeed get called
ininit.js
. I know I may sound ridiculous because you supplied me with the
contents of your init file which clearly show you have these statements,
etc.
But nevertheless please put there some console.logs and check that the Mocha adapter.beforeEach() and adapter.afterEach() gets called on practice.
Thanks in advance.
yeap did that. If I add bogus code in there and try to run the tests, I get an error on init.js. So that makes me think it is getting called. Also log recording is working but I am not sure this is tied to the beforeEach and afterEach using the adapter.
The thing is that only log recording can work without beforeEach and afterEach - it will be recording everything from the start till the end in startup.log file.
What kind of error do you get in init.js with your bogus code? Please post details.
for example, if I add this:
const detox = require('detox');
const config = require('../package.json').detox;
// these are changes for when the 'screenshots' feature is released in detox
const adapter = require('detox/runners/mocha/adapter');
before(async () => {
await detox.init(config);
});
beforeEach(async function () {
weird stuff
await adapter.beforeEach(this);
});
afterEach(async function () {
await adapter.afterEach(this);
});
after(async () => {
await detox.cleanup();
});
I get:
node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.debug --loglevel DEBUG --grep :android: --invert --record-logs all --take-screenshots true --artifacts-location "test-results/detox/ios/"
/Users/kotachte/Development/odsp-common-metro/items-view/mobile/e2e/init.js:12
weird stuff
^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at /Users/kotachte/Development/odsp-common-metro/common/temp/node_modules/.onedrive.pkgs.visualstudio.com/mocha/4.1.0/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/Users/kotachte/Development/odsp-common-metro/common/temp/node_modules/.onedrive.pkgs.visualstudio.com/mocha/4.1.0/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/Users/kotachte/Development/odsp-common-metro/common/temp/node_modules/.onedrive.pkgs.visualstudio.com/mocha/4.1.0/node_modules/mocha/lib/mocha.js:536:10)
at Object.<anonymous> (/Users/kotachte/Development/odsp-common-metro/common/temp/node_modules/.onedrive.pkgs.visualstudio.com/mocha/4.1.0/node_modules/mocha/bin/_mocha:573:18)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
child_process.js:644
throw err;
^
Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.debug --loglevel DEBUG --grep :android: --invert --record-logs all --take-screenshots true --artifacts-location "test-results/detox/ios/"
at checkExecSyncError (child_process.js:601:13)
@tachtevrenidis, could you please add something less "bogus" 😃, e.g.:
beforeEach(async function () {
try {
console.log('KOTACHTE TRY BEFORE_EACH');
await adapter.beforeEach(this);
console.log('KOTACHTE SUCCESS BEFORE_EACH');
} catch (e) {
console.error('KOTACHTE CAUGHT ERROR', e);
}
});
Please post your experiences.
here is an excerpt:
detox verb simulator-log-info watch strategy: watch
product Test Suite
user TRY BEFORE_EACH
detox verb SimulatorLogPlugin stopping to watch log
detox verb simulator-log-info Unwatch /Users/user/Library/Developer/CoreSimulator/Devices/C4912CB4-F17E-4382-9956-F04452DD233B/data/tmp/detox.last_launch_app_log.out
detox verb simulator-log-info Unwatch /Users/user/Library/Developer/CoreSimulator/Devices/C4912CB4-F17E-4382-9956-F04452DD233B/data/tmp/detox.last_launch_app_log.err
detox verb SimulatorLogPlugin starting to watch log
detox verb simulator-log-info Tail starting...
detox verb simulator-log-info filename: /Users/user/Library/Developer/CoreSimulator/Devices/C4912CB4-F17E-4382-9956-F04452DD233B/data/tmp/detox.last_launch_app_log.out
detox verb simulator-log-info encoding: utf-8
detox verb simulator-log-info filesystem.watch present? true
detox verb simulator-log-info useWatchFile: false
detox verb simulator-log-info watch strategy: watch
detox verb simulator-log-info Tail starting...
detox verb simulator-log-info filename: /Users/user/Library/Developer/CoreSimulator/Devices/C4912CB4-F17E-4382-9956-F04452DD233B/data/tmp/detox.last_launch_app_log.err
detox verb simulator-log-info encoding: utf-8
detox verb simulator-log-info filesystem.watch present? true
detox verb simulator-log-info useWatchFile: false
detox verb simulator-log-info watch strategy: watch
user SUCCESS BEFORE_EACH
I also see this:
detox verb 4: stdout: Xcode 9.4.1
Build version 9F2000
detox verb 5: /usr/bin/xcrun simctl boot C4912CB4-F17E-4382-9956-F04452DD233B
detox info 5: Booting device C4912CB4-F17E-4382-9956-F04452DD233B
detox verb 6: /usr/bin/xcrun simctl bootstatus C4912CB4-F17E-4382-9956-F04452DD233B
detox verb 6: stdout: Monitoring boot status for iPhone 8 (C4912CB4-F17E-4382-9956-F04452DD233B).
[2018-07-02 14:39:51 +0000] Status=4, isTerminal=NO, Elapsed=00:01.
Waiting on System App
[2018-07-02 14:39:51 +0000] Status=4, isTerminal=NO, Elapsed=00:01.
Waiting on System App
[2018-07-02 14:39:51 +0000] Status=4, isTerminal=NO, Elapsed=00:02.
Waiting on System App
[2018-07-02 14:39:52 +0000] Status=4, isTerminal=NO, Elapsed=00:03.
Waiting on System App
[2018-07-02 14:39:53 +0000] Status=4, isTerminal=NO, Elapsed=00:04.
Waiting on System App
[2018-07-02 14:39:54 +0000] Status=4, isTerminal=NO, Elapsed=00:05.
Waiting on System App
[2018-07-02 14:39:55 +0000] Status=4, isTerminal=NO, Elapsed=00:06.
Waiting on System App
[2018-07-02 14:39:57 +0000] Status=4, isTerminal=NO, Elapsed=00:07.
Waiting on System App
[2018-07-02 14:39:58 +0000] Status=1, isTerminal=NO, Elapsed=00:08.
Waiting on BackBoard
[2018-07-02 14:39:59 +0000] Status=4, isTerminal=NO, Elapsed=00:09.
Waiting on System App
[2018-07-02 14:39:59 +0000] Status=4294967295, isTerminal=YES, Elapsed=00:10.
Finished
takeScreenshot - EXECUTE: io C4912CB4-F17E-4382-9956-F04452DD233B screenshot "/dev/null"
detox verb 7: /usr/bin/xcrun simctl io C4912CB4-F17E-4382-9956-F04452DD233B screenshot "/dev/null"
detox ERR! 7: running "/usr/bin/xcrun simctl io C4912CB4-F17E-4382-9956-F04452DD233B screenshot "/dev/null"" returned 2
detox ERR! 7: stderr: An error was encountered processing the command (domain=SimulatorKit.SimDisplayScreenshotWriter.ScreenshotError, code=2):
Error creating the image
as I was saying earlier, I only see this 'takeScreenshot' reference if detox has to boot my simulator. If it is already booted, I don't see this.
I am available all day, if you need more debug info (we can chat, screen share etc if you want). Being able to generate screenshots is of high priority to us! Also, I want to thank you for taking the time to add this feature, and also taking the time to troubleshoot with me! Very appreciative!
Ping me tomorrow. You'll find my email in git log.
@tachtevrenidis, your issue will be addressed by the next detox@8.0.1
.
I am on RN 0.55 and Detox 8.0.0. I am running tests like this:
The artifacts folder is created and a subfolder with my test's name in it, but the folder is EMPTY. If I pass in --record-logs, I DO SEE the logs in the test artifacts folder.
The output from detox looks like this:
Help! :-)