Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 09cdabf

Browse files
committed
use yargs for option parsing and support config files
- `-d` is no longer an alias for `--debug` - `--grep` and `--fgrep` are now mutually exclusive - The option formerly known as `--compilers` is now removed from Mocha - `lib/template.html` moved to `lib/browser/template.html` - An error is thrown if a path to `mocha.opts` is specified by the user and the file was not found - `-gc` users should use `--gc-global` - Public API method `getOptions()` in `bin/options.js` is deprecated and currently has no alternative - Users of the `enableTimeouts` option of the `Mocha` constructor should use `timeout` instead. Specify `false` for no timeout - Users of the `useColors` option of the `Mocha` constructor should use `color` instead - Mocha now supports JS, JSON, YAML, or `package.json`-based config. - Any/all configuration, including `mocha.opts` can be used in addition to command-line arguments, and everything will be merged as applicable - Node/V8 flag support: - Support of all available `node` flags on a *per-version* basis - Support of any V8 flag by prepending `--v8-` to the option - These are supported within `mocha.opts` or config files - More flexible command-line parsing including negation of any boolean flag by prepending `--no-` to the name - Better `--help` - Descriptions of interfaces in `--help` text - A useful `Mocha` constructor - Debug-related flags (e.g., `--inspect`) now *imply* `--no-timeouts` - Many bug fixes around CLI option handling, e.g., closes mochajs#3475 - Fixes mochajs#3363, mochajs#2576, mochajs#3570 - `--no-timeouts` works - Added new, updated, or rewrote documentation for all non-self-explanatory options - Updated usage text, TOC - Added section on configuration - Added example configuration files in `example/config/` - Updated many dev deps, mostly within existing semver ranges - Removed `commander` - Added production deps: - ansi-colors - color terminal output - findup-sync - find package.json and other config files - js-yaml - parse YAML - log-symbols - visual symbols for success/fail etc. - node-environment-flags - per-version allowed Node.js env flags - object.assign - for IE11 - strip-json-comments - allow comments in JSON config files - wide-align - terminal formatting - yargs - option parser - yargs-parser - for compatible, lightweight parsing of config files - yargs-unparser - for passing config to `bin/_mocha` from `bin/mocha`
1 parent 6d3795d commit 09cdabf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+7959
-8067
lines changed

.eslintrc.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ overrides:
2323
- karma.conf.js
2424
- .wallaby.js
2525
- bin/*
26+
- lib/cli/**/*.js
27+
- test/node-unit/**/*.js
2628
parserOptions:
2729
ecmaVersion: 6
2830
env:
2931
browser: no
3032
- files:
31-
- test/**/*.js
33+
- test/**/*.{js,mjs}
3234
env:
3335
mocha: yes
3436
globals:
@@ -37,4 +39,9 @@ overrides:
3739
- doc/**/*.js
3840
env:
3941
node: no
42+
- files:
43+
- test/**/*.mjs
44+
parserOptions:
45+
ecmaVersion: 6
46+
sourceType: module
4047

.mocharc.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require: test/setup
2+
ui: bdd
3+
global:
4+
- okGlobalA,okGlobalB
5+
- okGlobalC
6+
- callback*
7+
timeout: 200

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ jobs:
6767
env: null
6868
before_install: true
6969
install: npm install --production
70-
# `--opts /dev/null` means "ignore test/mocha.opts"
71-
script: ./bin/mocha --opts /dev/null --reporter spec test/sanity/sanity.spec.js
70+
71+
script: ./bin/mocha --no-config --reporter spec test/sanity/sanity.spec.js
7272
cache:
7373
directories:
7474
- ~/.npm

.wallaby.js

+17-8
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,35 @@
33
module.exports = () => {
44
return {
55
files: [
6-
'index.js', 'lib/**/*.js', 'test/setup.js', 'test/assertions.js',
6+
'index.js',
7+
'lib/**/*.{js,json}',
8+
'test/setup.js',
9+
'test/assertions.js',
710
{
811
pattern: 'test/node-unit/**/*.fixture.js',
912
instrument: false
10-
}, {
13+
},
14+
{
1115
pattern: 'test/unit/**/*.fixture.js',
1216
instrument: false
13-
}
17+
},
18+
'package.json',
19+
'test/opts/mocha.opts',
20+
'mocharc.yml'
1421
],
15-
filesWithNoCoverageCalculated: ['test/**/*.fixture.js'],
16-
tests: [
17-
'test/unit/**/*.spec.js', 'test/node-unit/**/*.spec.js'
22+
filesWithNoCoverageCalculated: [
23+
'test/**/*.fixture.js',
24+
'test/setup.js',
25+
'test/assertions.js'
1826
],
27+
tests: ['test/unit/**/*.spec.js', 'test/node-unit/**/*.spec.js'],
1928
env: {
2029
type: 'node',
2130
runner: 'node'
2231
},
2332
workers: {recycle: true},
2433
testFramework: {type: 'mocha', path: __dirname},
25-
setup (wallaby) {
34+
setup(wallaby) {
2635
// running mocha instance is not the same as mocha under test,
2736
// running mocha is the project's source code mocha, mocha under test is instrumented version of the source code
2837
const runningMocha = wallaby.testFramework;
@@ -33,7 +42,7 @@ module.exports = () => {
3342
// to make test/node-unit/color.spec.js pass, we need to run mocha in the project's folder context
3443
const childProcess = require('child_process');
3544
const execFile = childProcess.execFile;
36-
childProcess.execFile = function () {
45+
childProcess.execFile = function() {
3746
let opts = arguments[2];
3847
if (typeof opts === 'function') {
3948
opts = {};

0 commit comments

Comments
 (0)