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 ability to query Mocha version programmatically #3535

Merged
merged 5 commits into from Nov 10, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/mocha.js
Expand Up @@ -677,6 +677,20 @@ Mocha.prototype.forbidPending = function() {
return this;
};

/**
* Mocha version as specified by "package.json".
*
* @name Mocha#version
* @type string
* @readonly
*/
Object.defineProperty(Mocha.prototype, 'version', {
value: require('../package').version,
configurable: false,
Copy link
Member

Choose a reason for hiding this comment

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

FWIW these are the default values for configurable and writable and could be omitted.

Is there a reasoning behind enumerable: true?

Copy link
Member

Choose a reason for hiding this comment

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

ping @plroebuck

Copy link
Contributor Author

@plroebuck plroebuck Nov 9, 2018

Choose a reason for hiding this comment

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

Defaults were explicit to imply intent (as there were only three boolean properties) rather than oversight. Found various examples (like this) within Node.js itself that did same. Airbnb doesn't mention one way or the other.
enumerable: true allows it to show up in a for loop over properties.

You feel otherwise concerning the style?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ORESoftware, don't know how to interpret your "thumbs up"...

enumerable: true,
writable: false
});

/**
* Callback to be invoked when test execution is complete.
*
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package.json
Expand Up @@ -502,6 +502,7 @@
"markdownlint-cli": "^0.9.0",
"nps": "^5.7.1",
"nyc": "^11.7.3",
"package-json-versionify": "^1.0.4",
"prettier-eslint-cli": "^4.7.1",
"rimraf": "^2.5.2",
"svgo": "^0.7.2",
Expand All @@ -518,6 +519,11 @@
"mocha.js",
"browser-entry.js"
],
"browserify": {
"transform": [
"package-json-versionify"
]
},
"browser": {
"growl": "./lib/browser/growl.js",
"tty": "./lib/browser/tty.js",
Expand Down