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

Add new option "--dry-run" #4640

Merged
merged 4 commits into from
Jun 5, 2021
Merged

Add new option "--dry-run" #4640

merged 4 commits into from
Jun 5, 2021

Conversation

juergba
Copy link
Contributor

@juergba juergba commented May 29, 2021

Description

Adds a --dry-run option, which executes the runner and makes all tests pass without actually running any hook/test.

Description of the Change

  • add option --dry-run
  • pass it to the mocha, then runner instance
  • do not execute any hook or test
  • other options as skip or only work as in a normal run

additionally:

  • remove utils.dQuote() and utils.sQuote()
  • use template strings instead

related PR #1070

@juergba juergba self-assigned this May 29, 2021
@juergba juergba added type: feature enhancement proposal semver-minor implementation requires increase of "minor" version number; "features" labels May 29, 2021
@juergba juergba added this to the v9.0.0 milestone May 30, 2021
@juergba juergba requested a review from a team June 1, 2021 06:44
@juergba juergba marked this pull request as ready for review June 1, 2021 06:45
@nicojs
Copy link
Contributor

nicojs commented Jun 4, 2021

Interesting. What is the use case for this feature?

i.e. are we sure people might not misuse this in pipelines to make all tests pass?

@juergba
Copy link
Contributor Author

juergba commented Jun 4, 2021

There is an old PR #1070 where quite a few users have been asking for this feature.

My main reasoning is: failing hooks are changing the amount of tests being executed. When a hook fails (mainly before and beforeEach) then tests get skipped and "disappear" without any reporting. This unfortunate hook pattern has been chosen years ago, so it's not a bug. With dry-run you can check which tests should actually run.
Furthermore it's useful for checking dynamically created tests.

i.e. are we sure people might not misuse this in pipelines to make all tests pass?

No, how could we? This is the responsibility of the user, but we can add some kind of control later, if necessary.

@juergba juergba merged commit 8212306 into master Jun 5, 2021
@juergba juergba deleted the juergba/dry-run branch June 5, 2021 09:18
@0xorial
Copy link

0xorial commented Oct 11, 2022

Just out of curiosity - to me this sounds like a critical feature to integrate mocha in any IDE (when I open it I usually want to see a list of tests and be able to re-run/debug them individually). But obviously this is not the case as it was implemented only recently. How is/was it supposed to be integrated in the IDEs? (I myself got here because I was looking for a way to use TAP in vscode or WebStorm)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor implementation requires increase of "minor" version number; "features" type: feature enhancement proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants