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

Mocha constructor: improve browser setup #4070

Merged
merged 4 commits into from
Nov 3, 2019
Merged

Conversation

juergba
Copy link
Contributor

@juergba juergba commented Oct 16, 2019

Description

The browser setup can result in an error when the option and its corresponding function don't match in their name, eg. --diff<==> hideDiff().
see comment

Mocha options are used in different contexts:

  • via CLI: options can be set with canonical / alias / camel-cased canonical / camel-cased alias names.
    The parser autocompletes the names and the whole bunch of options is dumped into the mocha instance.
    eg. --timeout 200 results in: {timeout: 200, t: 200 timeouts: 200}

  • using Mocha programmatically: Mocha constructor accepts and processes only canonical or their camel-cased option names,
    eg. {timeout: 200, checkLeaks: true}

  • browser: setup() calls public function where option name matches function name.

mocha.setup({
  global: ['foo']  // calls Mocha#global()
});
mocha.checkLeaks(false);  // should work also with 'false'

Description of the Change

  • Following public functions are also used for the browser setup. Currently they are just able to turn the feature on (true). They should work both ways (true or false):
    • Mocha#allowUncaught
    • Mocha#asyncOnly
    • Mocha#checkLeaks
    • Mocha#forbidOnly
    • Mocha#forbidPending
    • Mocha#fullTrace
  • Mocha#ignoreLeaks: soft deprecate (Mocha#checkLeaks already exists)
  • Mocha#globals: keep this function, since its an alias name and add a new Mocha#global
  • Mocha#hideDiff: soft deprecate and add a new Mocha#diff
  • Mocha#useColors: soft deprecate and add a new Mocha#color
  • Mocha#useInlineDiffs: soft deprecate and add a new Mocha#inlineDiffs
  • fix some JSDoc links

@juergba juergba self-assigned this Oct 16, 2019
@coveralls
Copy link

coveralls commented Oct 16, 2019

Coverage Status

Coverage increased (+0.03%) to 92.74% when pulling f50cb95 on juergba/mocha-browser into f73e7c6 on master.

@juergba juergba changed the title Browser setup: rename some Mocha functions Mocha constructor: fix browser setup Oct 16, 2019
@juergba juergba force-pushed the juergba/mocha-browser branch 5 times, most recently from 72f7bfc to 7beddb0 Compare October 23, 2019 08:22
@juergba juergba marked this pull request as ready for review October 24, 2019 09:10
@juergba juergba added area: browser browser-specific type: bug a defect, confirmed by a maintainer status: needs review a maintainer should (re-)review this pull request semver-patch implementation requires increase of "patch" version number; "bug fixes" labels Oct 24, 2019
@juergba juergba added this to the v7.0.0 milestone Oct 24, 2019
@juergba juergba changed the title Mocha constructor: fix browser setup Mocha constructor: improve browser setup Oct 24, 2019
Copy link
Contributor

@craigtaub craigtaub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍 . Anything to standardise the usage is good in my books.

@juergba juergba merged commit ec8e2f8 into master Nov 3, 2019
@juergba juergba deleted the juergba/mocha-browser branch November 3, 2019 09:31
@juergba juergba removed the status: needs review a maintainer should (re-)review this pull request label Nov 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: browser browser-specific semver-patch implementation requires increase of "patch" version number; "bug fixes" type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants