-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
CLI: Add pass through test runner arguments #1025
Conversation
I think this can be passed using |
@rotemmiz , no, we have no |
Then this is probably what we need to add instead of exposing flags individually. |
I would rather add a mechanism to pass args to test runners, kinda like npm does. |
23e380f
to
0e5ab8d
Compare
I updated this PR to allow generic pass through test runner arguments via an environment variable, DETOX_TEST_RUNNER_FLAGS. I ran into two issues with the
The actual mechanism is pretty easy to change if you guys have another method you'd prefer, but I gave up on the |
@rotemmiz is this approach acceptable or do you have an alternative you'd prefer? |
I'm against setting an env var to cli if is not absolutely needed, it makes the usage cumbersome and error prone in my opinion. |
I can't use
It seems that the best I could do with args is |
Do you believe that this can be handled properly by |
The original python argparse say that it can do exactly that: https://docs.python.org/dev/library/argparse.html#partial-parsing I will do a test Friday morning since tomorrow (Thursday) is a holiday and I won't be at a computer, but it looks like we should be able to just pass all un-detox flags directly into jest, so |
@rotemmiz, @EdwardDrapkin , guys, I struggle a bit to see what's the problem here: function splitPassthrough(argv) {
const position = argv.indexOf('--');
if (position === -1) {
return [argv, []];
}
return [argv.slice(0, position), argv.slice(position + 1)];
}
const [argv, pargv] = splitPassthrough(process.argv);
console.log('argv', argv); // use with commander
console.log('pargv', pargv); // pass as-is Why can't we make a helper to split argv and use with commander in a way it used to be and add a routine to append |
Commander rewrites process.argv for subcommand invocations. Although I guess we could pass EDIT: nevermind, sigh, commander actually spawns a new process with an args struct it builds for subcommands, so I don't think we can parse |
0e5ab8d
to
0325d33
Compare
I spent some time digging in commander and it turns out it does parse the unknown args out and just drops them on the floor, but I was able to call the parser methods myself. It appears to work that extra flags just get passed clean through to the test runner. |
0325d33
to
763731b
Compare
This is great stuff!! Thanks for the stubburn investigation! |
There wasn't anything for me to rebase, so I pushed a documentation update to re-kick CI. Clicking through to the CI logs, it looks like some animations timed out in iOS 56, and I don't think anything I changed could have affected that - and if it did, not sure how it only affected one entry in the build matrix. I think it was just a random failure that periodically happens with simulators... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for that!
Edward, thank you very much! |
It's helpful to use --bail sometimes in either Jest or Mocha, so I exposed it and forwarded it in.