-
-
Notifications
You must be signed in to change notification settings - Fork 3k
--dry-run option #1070
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
--dry-run option #1070
Conversation
isn't necessary imo |
👍 this option is useful for listing all tests, I think this would be a good addition. |
I was building a tool that needed it. Can't share the code, but there is a fairly straightforward alternative if you need it too: define global "describe" and "it" functions (etc.) -- each one like a spy, then require all your tests. |
👍 I can think of an example of where this might be helpful: In your team's CI environment, do |
This needs to be merged. |
Useful for listing the amount of tests should be run, then if you run tests in parallel across multiple containers assert all the tests did in fact run |
Why is this feature still not merged? |
Another use case for this feature: I have two npm scripts to handle this scenario:
I use mocha's "only" feature to cherry pick specific tests to run. However, I often forget to remove the "only" flag when I'm done. Finding which tests have specified "only" can be rather tediuous. I'm always very hesitant to hit the "go" button until I'm CERTAIN that I'm only running ONE SPECIFIC TEST. The "--dry-run" flag would give me confidence that I'm only going to run the test I intend to run. |
@lukewis although a dry run option would help here, consider adding a pre-commit hook that looks for FILES_PATTERN='(app|test).+\.js(\..+)?$'
FORBIDDEN='console.log(\|describe\.only\|it\.only'
# Quit if no relevant files are being checked in.
FILES=$(git diff --cached --name-only | grep -Ec $FILES_PATTERN)
if [ "$FILES" = "0" ]; then
exit 0
fi
cd "$(git rev-parse --show-toplevel)/"
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='37;41' xargs grep --color --with-filename -n $FORBIDDEN && \
echo 'Please remove debugging statements before commiting.' && exit 1 This is meant to run on Mac or Linux. Sorry, no Windows. |
Very interesting, @Droogans , thanks for sharing (especially appreciate the code sample)! I hadn't used any git hooks before, so researching them has been quite eye-opening. It feels like they are "really close" to being super useful! I wish it was easier to do things like
I know there are solutions to these problems, but it feels like it adds a moderate amount of complexity to the repository (git is already fairly complex by itself!). In the end, I'm still on the fence if hooks are a good fit to solve this problem (though I really appreciate the creativity!). I do love the "simplicity" of just having a --dry-run option, and I too can appreciate your suggested use case of creating a "report" of the active tests. |
Sorry, but this would be really bloody useful. We've currently got mocha seriously misbehaving following an upgrade and the ability to do a dry run to list all the tests to make sure we've not got require issues or some other issue with the test setup rather than the tests themselves would be a godsend. |
Came across this today looking for something similar. I wanted to simply list all the names of the tests so that I could externally partition the list and run the tests in batches on different machines. For example, dispatch all the A-M tests to run on one machine/process and dispatch all the N-Z tests to run on a second machine/process (Obviously I would partition more intelligently in the real world - but you get my point.) If the --dry-run were just a --list then I could write a test runner that would first call mocha to generate the list of tests, then partition the list, then dispatch mocha to run on N worker machines, giving each of them 1/Nth of the tests to run. Then aggregate their results/artifacts and finally report a unified pass/fail result to the continuous integration system. I don't know how to get started if I can't get a list of all the tests though. |
Can we re-open this PR since it's indeed extremely useful ?! |
Guys i created a package for this, go check it out |
👍 |
Still relevant |
Adds a --dry-run option, which makes all tests pass without actually running any.
This is sometimes useful as a developer, but also allows other tools to list tests without running them.