mocha 3.2.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +178 -0
- package/LICENSE +1 -1
- package/README.md +41 -1
- package/bin/_mocha +29 -2
- package/bin/mocha +4 -0
- package/lib/mocha.js +31 -3
- package/lib/reporters/html.js +4 -2
- package/lib/runnable.js +5 -2
- package/lib/runner.js +11 -6
- package/lib/utils.js +7 -3
- package/mocha.js +2042 -1353
- package/package.json +24 -13
- package/bin/.eslintrc +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,181 @@
|
|
|
1
|
+
# 3.5.0 / 2017-07-31
|
|
2
|
+
|
|
3
|
+
## :newspaper: News
|
|
4
|
+
|
|
5
|
+
- Mocha now has a [code of conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) (thanks [@kungapal]!).
|
|
6
|
+
- Old issues and PRs are now being marked "stale" by [Probot's "Stale" plugin](https://github.com/probot/stale). If an issue is marked as such, and you would like to see it remain open, simply add a new comment to the ticket or PR.
|
|
7
|
+
- **WARNING**: Support for non-ES5-compliant environments will be dropped starting with version 4.0.0 of Mocha!
|
|
8
|
+
|
|
9
|
+
## :lock: Security Fixes
|
|
10
|
+
|
|
11
|
+
- [#2860]: Address [CVE-2015-8315](https://nodesecurity.io/advisories/46) via upgrade of [debug](https://npm.im/debug) ([@boneskull])
|
|
12
|
+
|
|
13
|
+
## :tada: Enhancements
|
|
14
|
+
|
|
15
|
+
- [#2696]: Add `--forbid-only` and `--forbid-pending` flags. Use these in CI or hooks to ensure tests aren't accidentally being skipped! ([@charlierudolph])
|
|
16
|
+
- [#2813]: Support Node.js 8's `--napi-modules` flag ([@jupp0r])
|
|
17
|
+
|
|
18
|
+
## :nut_and_bolt: Other
|
|
19
|
+
|
|
20
|
+
- Various CI-and-test-related fixes and improvements ([@boneskull], [@dasilvacontin], [@PopradiArpad], [@Munter], [@ScottFreeCode])
|
|
21
|
+
- "Officially" support Node.js 8 ([@elergy])
|
|
22
|
+
|
|
23
|
+
[#2860]: https://github.com/mochajs/mocha/pulls/2860
|
|
24
|
+
[#2696]: https://github.com/mochajs/mocha/pulls/2696
|
|
25
|
+
[#2813]: https://github.com/mochajs/mocha/pulls/2813
|
|
26
|
+
[@charlierudolph]: https://github.com/charlierudolph
|
|
27
|
+
[@PopradiArpad]: https://github.com/PopradiArpad
|
|
28
|
+
[@kungapal]: https://github.com/kungapal
|
|
29
|
+
[@elergy]: https://github.com/elergy
|
|
30
|
+
[@jupp0r]: https://github.com/jupp0r
|
|
31
|
+
|
|
32
|
+
# 3.4.2 / 2017-05-24
|
|
33
|
+
|
|
34
|
+
## :bug: Fixes
|
|
35
|
+
|
|
36
|
+
- [#2802]: Remove call to deprecated `os.tmpDir` ([@makepanic])
|
|
37
|
+
- [#2820]: Eagerly set `process.exitCode` ([@chrisleck])
|
|
38
|
+
|
|
39
|
+
## :nut_and_bolt: Other
|
|
40
|
+
|
|
41
|
+
- [#2778]: Move linting into an npm script ([@Munter])
|
|
42
|
+
|
|
43
|
+
[@chrisleck]: https://github.com/chrisleck
|
|
44
|
+
[@makepanic]: https://github.com/makepanic
|
|
45
|
+
[@Munter]: https://github.com/Munter
|
|
46
|
+
|
|
47
|
+
[#2778]: https://github.com/mochajs/mocha/pulls/2778
|
|
48
|
+
[#2802]: https://github.com/mochajs/mocha/issues/2802
|
|
49
|
+
[#2820]: https://github.com/mochajs/mocha/pull/2820
|
|
50
|
+
|
|
51
|
+
# 3.4.1 / 2017-05-14
|
|
52
|
+
|
|
53
|
+
Fixed a publishing mishap with git's autocrlf settings.
|
|
54
|
+
|
|
55
|
+
# 3.4.0 / 2017-05-14
|
|
56
|
+
|
|
57
|
+
Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.
|
|
58
|
+
|
|
59
|
+
This week's highlights:
|
|
60
|
+
|
|
61
|
+
- `allowUncaught` added to commandline as `--allow-uncaught` (and bugfixed)
|
|
62
|
+
- warning-related Node flags
|
|
63
|
+
|
|
64
|
+
## :tada: Enhancements
|
|
65
|
+
|
|
66
|
+
- [#2793], [#2697]: add --allowUncaught to Node.js ([@lrowe])
|
|
67
|
+
- [#2733]: Add `--no-warnings` and `--trace-warnings` flags ([@sonicdoe])
|
|
68
|
+
|
|
69
|
+
## :bug: Fixes
|
|
70
|
+
|
|
71
|
+
- [#2793], [#2697]: fix broken allowUncaught ([@lrowe])
|
|
72
|
+
|
|
73
|
+
## :nut_and_bolt: Other
|
|
74
|
+
|
|
75
|
+
- [#2778]: Add license report and scan status ([@xizhao])
|
|
76
|
+
- [#2794]: no special case for macOS running Karma locally ([@boneskull])
|
|
77
|
+
- [#2795]: reverts use of semistandard directly ([#2648]) ([@boneskull])
|
|
78
|
+
|
|
79
|
+
[@lrowe]: https://github.com/lrowe
|
|
80
|
+
[@sonicdoe]: https://github.com/sonicdoe
|
|
81
|
+
[@xizhao]: https://github.com/xizhao
|
|
82
|
+
[@boneskull]: https://github.com/boneskull
|
|
83
|
+
|
|
84
|
+
[#2795]: https://github.com/mochajs/mocha/pull/2795
|
|
85
|
+
[#2733]: https://github.com/mochajs/mocha/pull/2733
|
|
86
|
+
[#2793]: https://github.com/mochajs/mocha/pull/2793
|
|
87
|
+
[#2697]: https://github.com/mochajs/mocha/pull/2697
|
|
88
|
+
[#2778]: https://github.com/mochajs/mocha/pull/2778
|
|
89
|
+
[#2794]: https://github.com/mochajs/mocha/pull/2794
|
|
90
|
+
|
|
91
|
+
# 3.3.0 / 2017-04-24
|
|
92
|
+
|
|
93
|
+
Thanks to all our contributors, maintainers, sponsors, and users! ❤️
|
|
94
|
+
|
|
95
|
+
As highlights:
|
|
96
|
+
|
|
97
|
+
- We've got coverage now!
|
|
98
|
+
- Testing is looking less flaky \o/.
|
|
99
|
+
- No more nitpicking about "mocha.js" build on PRs.
|
|
100
|
+
|
|
101
|
+
## :tada: Enhancements
|
|
102
|
+
|
|
103
|
+
- [#2659]: Adds support for loading reporter from an absolute or relative path ([@sul4bh])
|
|
104
|
+
- [#2769]: Support `--inspect-brk` on command-line ([@igwejk])
|
|
105
|
+
|
|
106
|
+
## :bug: Fixes
|
|
107
|
+
|
|
108
|
+
- [#2662]: Replace unicode chars w/ hex codes in HTML reporter ([@rotemdan])
|
|
109
|
+
|
|
110
|
+
## :mag: Coverage
|
|
111
|
+
|
|
112
|
+
- [#2672]: Add coverage for node tests ([@c089], [@Munter])
|
|
113
|
+
- [#2680]: Increase tests coverage for base reporter ([@epallerols])
|
|
114
|
+
- [#2690]: Increase tests coverage for doc reporter ([@craigtaub])
|
|
115
|
+
- [#2701]: Increase tests coverage for landing, min, tap and list reporters ([@craigtaub])
|
|
116
|
+
- [#2691]: Increase tests coverage for spec + dot reporters ([@craigtaub])
|
|
117
|
+
- [#2698]: Increase tests coverage for xunit reporter ([@craigtaub])
|
|
118
|
+
- [#2699]: Increase tests coverage for json-stream, markdown and progress reporters ([@craigtaub])
|
|
119
|
+
- [#2703]: Cover .some() function in utils.js with tests ([@seppevs])
|
|
120
|
+
- [#2773]: Add tests for loading reporters w/ relative/absolute paths ([@sul4bh])
|
|
121
|
+
|
|
122
|
+
## :nut_and_bolt: Other
|
|
123
|
+
|
|
124
|
+
- Remove bin/.eslintrc; ensure execs are linted ([@boneskull])
|
|
125
|
+
- [#2542]: Expand CONTRIBUTING.md ([@boneskull])
|
|
126
|
+
- [#2660]: Double timeouts on integration tests ([@Munter])
|
|
127
|
+
- [#2653]: Update copyright year ([@Scottkao85], [@Munter])
|
|
128
|
+
- [#2621]: Update dependencies to enable Greenkeeper ([@boneskull], [@greenkeeper])
|
|
129
|
+
- [#2625]: Use trusty container in travis-ci; use "artifacts" addon ([@boneskull])
|
|
130
|
+
- [#2670]: doc(CONTRIBUTING): fix link to org members ([@coderbyheart])
|
|
131
|
+
- Add Mocha propaganda to README.md ([@boneskull])
|
|
132
|
+
- [#2470]: Avoid test flake in "delay" test ([@boneskull])
|
|
133
|
+
- [#2675]: Limit browser concurrency on sauce ([@boneskull])
|
|
134
|
+
- [#2669]: Use temporary test-only build of mocha.js for browsers tests ([@Munter])
|
|
135
|
+
- Fix "projects" link in README.md ([@boneskull])
|
|
136
|
+
- [#2678]: Chore(Saucelabs): test on IE9, IE10 and IE11 ([@coderbyheart])
|
|
137
|
+
- [#2648]: Use `semistandard` directly ([@kt3k])
|
|
138
|
+
- [#2727]: Make the build reproducible ([@lamby])
|
|
139
|
+
|
|
140
|
+
[@boneskull]: https://github.com/boneskull
|
|
141
|
+
[@c089]: https://github.com/c089
|
|
142
|
+
[@coderbyheart]: https://github.com/coderbyheart
|
|
143
|
+
[@craigtaub]: https://github.com/craigtaub
|
|
144
|
+
[@epallerols]: https://github.com/epallerols
|
|
145
|
+
[@greenkeeper]: https://github.com/greenkeeper
|
|
146
|
+
[@igwejk]: https://github.com/igwejk
|
|
147
|
+
[@kt3k]: https://github.com/kt3k
|
|
148
|
+
[@lamby]: https://github.com/lamby
|
|
149
|
+
[@Munter]: https://github.com/Munter
|
|
150
|
+
[@rotemdan]: https://github.com/rotemdan
|
|
151
|
+
[@seppevs]: https://github.com/seppevs
|
|
152
|
+
[@sul4bh]: https://github.com/sul4bh
|
|
153
|
+
|
|
154
|
+
[#2470]: https://github.com/mochajs/mocha/pull/2470
|
|
155
|
+
[#2542]: https://github.com/mochajs/mocha/issues/2542
|
|
156
|
+
[#2621]: https://github.com/mochajs/mocha/pull/2621
|
|
157
|
+
[#2625]: https://github.com/mochajs/mocha/pull/2625
|
|
158
|
+
[#2648]: https://github.com/mochajs/mocha/pull/2648
|
|
159
|
+
[#2653]: https://github.com/mochajs/mocha/pull/2653
|
|
160
|
+
[#2659]: https://github.com/mochajs/mocha/pull/2659
|
|
161
|
+
[#2660]: https://github.com/mochajs/mocha/pull/2660
|
|
162
|
+
[#2662]: https://github.com/mochajs/mocha/pull/2662
|
|
163
|
+
[#2669]: https://github.com/mochajs/mocha/pull/2669
|
|
164
|
+
[#2670]: https://github.com/mochajs/mocha/pull/2670
|
|
165
|
+
[#2672]: https://github.com/mochajs/mocha/pull/2672
|
|
166
|
+
[#2675]: https://github.com/mochajs/mocha/pull/2675
|
|
167
|
+
[#2678]: https://github.com/mochajs/mocha/pull/2678
|
|
168
|
+
[#2680]: https://github.com/mochajs/mocha/pull/2680
|
|
169
|
+
[#2690]: https://github.com/mochajs/mocha/pull/2690
|
|
170
|
+
[#2691]: https://github.com/mochajs/mocha/pull/2691
|
|
171
|
+
[#2698]: https://github.com/mochajs/mocha/pull/2698
|
|
172
|
+
[#2699]: https://github.com/mochajs/mocha/pull/2699
|
|
173
|
+
[#2701]: https://github.com/mochajs/mocha/pull/2701
|
|
174
|
+
[#2703]: https://github.com/mochajs/mocha/pull/2703
|
|
175
|
+
[#2727]: https://github.com/mochajs/mocha/pull/2727
|
|
176
|
+
[#2769]: https://github.com/mochajs/mocha/pull/2769
|
|
177
|
+
[#2773]: https://github.com/mochajs/mocha/pull/2773
|
|
178
|
+
|
|
1
179
|
# 3.2.0 / 2016-11-24
|
|
2
180
|
|
|
3
181
|
## :newspaper: News
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(The MIT License)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2011-2017 JS Foundation and contributors, https://js.foundation
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -1,9 +1,47 @@
|
|
|
1
|
+
# Mocha needs YOU!
|
|
2
|
+
|
|
3
|
+
*Did you know* Mocha [is a dependency of over 100,000 projects](https://libraries.io/npm/mocha) published to npm alone?
|
|
4
|
+
|
|
5
|
+
**Despite this, we're currently unable to merge most pull requests due to lack of maintenance resources.**
|
|
6
|
+
|
|
7
|
+
**Are you interested in triaging issues or reviewing open PRs? Have some time to hack on its codebase?** If you would like to help maintain Mocha, please contact `@boneskull` on [Gitter](https://gitter.im/mochajs/mocha).
|
|
8
|
+
|
|
9
|
+
*Thank you* :kissing_heart: to all of you interested in helping. These are Mocha's immediate needs:
|
|
10
|
+
|
|
11
|
+
1. Increase test coverage on Node.js and browser
|
|
12
|
+
- Increase integration coverage for all reporters
|
|
13
|
+
- `html` reporter must be tested in browser
|
|
14
|
+
- ~~Basic console reporters (*not* `nyan`, `landing`, etc.) must be tested in **both** browser and Node.js contexts; PhantomJS can consume all console reporters~~
|
|
15
|
+
- ~~Filesystem-based reporters must be tested in Node.js context~~
|
|
16
|
+
- **UPDATE - May 24 2017**: Thanks to [community contributions](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#mag-coverage), the coverage on most reporters has increased dramatically! The `html` reporter is still in [dire need of coverage](https://coveralls.io/builds/11674428/source?filename=lib%2Freporters%2Fhtml.js).
|
|
17
|
+
- Increase coverage against all interfaces (`exports` in particular). Ideally this becomes a "matrix" where we repeat sets of integration tests across all interfaces.
|
|
18
|
+
- Refactor non-Node.js-specific tests to allow them to run in a browser context. Node.js-specific tests include those which *require* the CLI or filesystem. Most everything else is fair game.
|
|
19
|
+
2. Review current open pull requests
|
|
20
|
+
- We need individuals familiar with Mocha's codebase. Got questions? Ask them in [our chat room](https://gitter.im/mochajs/mocha).
|
|
21
|
+
- Pull requests **must** have supporting tests. The only exceptions are pure cosmetic or non-functional changes.
|
|
22
|
+
- Pull request contributors must sign the CLA.
|
|
23
|
+
3. Close old, inactive issues and pull requests
|
|
24
|
+
- ~~A bot should do this. We need a bot. Got a bot?~~ We now use GitHub's own [probot-stale](https://www.npmjs.com/package/probot-stale).
|
|
25
|
+
4. Triage issues
|
|
26
|
+
- If we run into "critical" bugs, they need fixing.
|
|
27
|
+
- "Critical" means Mocha is broken w/o workarounds for a *large percentage* of users
|
|
28
|
+
- Otherwise: respond to issues, close new dupe issues, confirm bugs, ask for more info, etc.
|
|
29
|
+
|
|
30
|
+
Once we gain ground on the above items, we can work together formalize our contribution guidelines and governance. For further info & ideas, please see our [projects](https://github.com/mochajs/mocha/projects/).
|
|
31
|
+
|
|
32
|
+
*You needn't be a maintainer to submit a pull request for test coverage!*
|
|
33
|
+
|
|
34
|
+
-- @boneskull, *Jan 17 2016*
|
|
35
|
+
|
|
1
36
|
<br><br>
|
|
2
37
|
<p align="center">
|
|
3
38
|
<img src="https://cldup.com/xFVFxOioAU.svg" alt="Mocha test framework"/>
|
|
4
39
|
</p>
|
|
5
40
|
|
|
6
|
-
[](http://travis-ci.org/mochajs/mocha)
|
|
41
|
+
[](http://travis-ci.org/mochajs/mocha)
|
|
42
|
+
[](https://coveralls.io/github/mochajs/mocha)
|
|
43
|
+
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha?ref=badge_shield)
|
|
44
|
+
[](https://gitter.im/mochajs/mocha?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
7
45
|
[](#backers)
|
|
8
46
|
[](#sponsors)
|
|
9
47
|
<br><img alt="Mocha Browser Support h/t SauceLabs" src="https://saucelabs.com/browser-matrix/mochajs.svg" width="354">
|
|
@@ -82,3 +120,5 @@ Does your company use Mocha? Ask your manager or marketing team if your company
|
|
|
82
120
|
## License
|
|
83
121
|
|
|
84
122
|
[MIT](LICENSE)
|
|
123
|
+
|
|
124
|
+
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha?ref=badge_large)
|
package/bin/_mocha
CHANGED
|
@@ -91,12 +91,15 @@ program
|
|
|
91
91
|
.option('--icu-data-dir', 'include ICU data')
|
|
92
92
|
.option('--inline-diffs', 'display actual/expected differences inline within each string')
|
|
93
93
|
.option('--inspect', 'activate devtools in chrome')
|
|
94
|
+
.option('--inspect-brk', 'activate devtools in chrome and break on the first line')
|
|
94
95
|
.option('--interfaces', 'display available interfaces')
|
|
95
96
|
.option('--no-deprecation', 'silence deprecation warnings')
|
|
96
97
|
.option('--no-exit', 'require a clean shutdown of the event loop: mocha will not call process.exit')
|
|
97
98
|
.option('--no-timeouts', 'disables timeouts, given implicitly with --debug')
|
|
99
|
+
.option('--no-warnings', 'silence all node process warnings')
|
|
98
100
|
.option('--opts <path>', 'specify opts path', 'test/mocha.opts')
|
|
99
101
|
.option('--perf-basic-prof', 'enable perf linux profiler (basic support)')
|
|
102
|
+
.option('--napi-modules', 'enable experimental NAPI modules')
|
|
100
103
|
.option('--prof', 'log statistical profiling information')
|
|
101
104
|
.option('--log-timer-events', 'Time events including external callbacks')
|
|
102
105
|
.option('--recursive', 'include sub directories')
|
|
@@ -105,9 +108,13 @@ program
|
|
|
105
108
|
.option('--throw-deprecation', 'throw an exception anytime a deprecated function is used')
|
|
106
109
|
.option('--trace', 'trace function calls')
|
|
107
110
|
.option('--trace-deprecation', 'show stack traces on deprecations')
|
|
111
|
+
.option('--trace-warnings', 'show stack traces on node process warnings')
|
|
108
112
|
.option('--use_strict', 'enforce strict mode')
|
|
109
113
|
.option('--watch-extensions <ext>,...', 'additional extensions to monitor with --watch', list, [])
|
|
110
|
-
.option('--delay', 'wait for async suite definition')
|
|
114
|
+
.option('--delay', 'wait for async suite definition')
|
|
115
|
+
.option('--allow-uncaught', 'enable uncaught errors to propagate')
|
|
116
|
+
.option('--forbid-only', 'causes test marked with only to fail the suite')
|
|
117
|
+
.option('--forbid-pending', 'causes pending tests and test marked with skip to fail the suite');
|
|
111
118
|
|
|
112
119
|
program._name = 'mocha';
|
|
113
120
|
|
|
@@ -313,6 +320,12 @@ if (program.delay) {
|
|
|
313
320
|
mocha.delay();
|
|
314
321
|
}
|
|
315
322
|
|
|
323
|
+
// --allow-uncaught
|
|
324
|
+
|
|
325
|
+
if (program.allowUncaught) {
|
|
326
|
+
mocha.allowUncaught();
|
|
327
|
+
}
|
|
328
|
+
|
|
316
329
|
// --globals
|
|
317
330
|
|
|
318
331
|
mocha.globals(globals);
|
|
@@ -323,6 +336,14 @@ if (program.retries) {
|
|
|
323
336
|
mocha.suite.retries(program.retries);
|
|
324
337
|
}
|
|
325
338
|
|
|
339
|
+
// --forbid-only
|
|
340
|
+
|
|
341
|
+
if (program.forbidOnly) mocha.forbidOnly();
|
|
342
|
+
|
|
343
|
+
// --forbid-pending
|
|
344
|
+
|
|
345
|
+
if (program.forbidPending) mocha.forbidPending();
|
|
346
|
+
|
|
326
347
|
// custom compiler support
|
|
327
348
|
|
|
328
349
|
var extensions = ['js'];
|
|
@@ -466,12 +487,18 @@ function exitLater (code) {
|
|
|
466
487
|
}
|
|
467
488
|
|
|
468
489
|
function exit (code) {
|
|
490
|
+
var clampedCode = Math.min(code, 255);
|
|
491
|
+
|
|
492
|
+
// Eagerly set the process's exit code in case stream.write doesn't
|
|
493
|
+
// execute its callback before the process terminates.
|
|
494
|
+
process.exitCode = clampedCode;
|
|
495
|
+
|
|
469
496
|
// flush output for Node.js Windows pipe bug
|
|
470
497
|
// https://github.com/joyent/node/issues/6247 is just one bug example
|
|
471
498
|
// https://github.com/visionmedia/mocha/issues/333 has a good discussion
|
|
472
499
|
function done () {
|
|
473
500
|
if (!(draining--)) {
|
|
474
|
-
process.exit(
|
|
501
|
+
process.exit(clampedCode);
|
|
475
502
|
}
|
|
476
503
|
}
|
|
477
504
|
|
package/bin/mocha
CHANGED
|
@@ -28,6 +28,7 @@ process.argv.slice(2).forEach(function (arg) {
|
|
|
28
28
|
case '--debug':
|
|
29
29
|
case '--debug-brk':
|
|
30
30
|
case '--inspect':
|
|
31
|
+
case '--inspect-brk':
|
|
31
32
|
args.unshift(arg);
|
|
32
33
|
args.push('--no-timeouts');
|
|
33
34
|
break;
|
|
@@ -38,13 +39,16 @@ process.argv.slice(2).forEach(function (arg) {
|
|
|
38
39
|
case '--gc-global':
|
|
39
40
|
case '--es_staging':
|
|
40
41
|
case '--no-deprecation':
|
|
42
|
+
case '--no-warnings':
|
|
41
43
|
case '--prof':
|
|
42
44
|
case '--log-timer-events':
|
|
43
45
|
case '--throw-deprecation':
|
|
44
46
|
case '--trace-deprecation':
|
|
47
|
+
case '--trace-warnings':
|
|
45
48
|
case '--use_strict':
|
|
46
49
|
case '--allow-natives-syntax':
|
|
47
50
|
case '--perf-basic-prof':
|
|
51
|
+
case '--napi-modules':
|
|
48
52
|
args.unshift(arg);
|
|
49
53
|
break;
|
|
50
54
|
default:
|
package/lib/mocha.js
CHANGED
|
@@ -152,9 +152,17 @@ Mocha.prototype.reporter = function (reporter, reporterOptions) {
|
|
|
152
152
|
try {
|
|
153
153
|
_reporter = require(reporter);
|
|
154
154
|
} catch (err) {
|
|
155
|
-
err.message.indexOf('Cannot find module') !== -1
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
if (err.message.indexOf('Cannot find module') !== -1) {
|
|
156
|
+
// Try to load reporters from a path (absolute or relative)
|
|
157
|
+
try {
|
|
158
|
+
_reporter = require(path.resolve(process.cwd(), reporter));
|
|
159
|
+
} catch (_err) {
|
|
160
|
+
err.message.indexOf('Cannot find module') !== -1 ? console.warn('"' + reporter + '" reporter not found')
|
|
161
|
+
: console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
|
|
165
|
+
}
|
|
158
166
|
}
|
|
159
167
|
}
|
|
160
168
|
if (!_reporter && reporter === 'teamcity') {
|
|
@@ -475,6 +483,24 @@ Mocha.prototype.delay = function delay () {
|
|
|
475
483
|
return this;
|
|
476
484
|
};
|
|
477
485
|
|
|
486
|
+
/**
|
|
487
|
+
* Tests marked only fail the suite
|
|
488
|
+
* @returns {Mocha}
|
|
489
|
+
*/
|
|
490
|
+
Mocha.prototype.forbidOnly = function () {
|
|
491
|
+
this.options.forbidOnly = true;
|
|
492
|
+
return this;
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Pending tests and tests marked skip fail the suite
|
|
497
|
+
* @returns {Mocha}
|
|
498
|
+
*/
|
|
499
|
+
Mocha.prototype.forbidPending = function () {
|
|
500
|
+
this.options.forbidPending = true;
|
|
501
|
+
return this;
|
|
502
|
+
};
|
|
503
|
+
|
|
478
504
|
/**
|
|
479
505
|
* Run tests and invoke `fn()` when complete.
|
|
480
506
|
*
|
|
@@ -496,6 +522,8 @@ Mocha.prototype.run = function (fn) {
|
|
|
496
522
|
runner.hasOnly = options.hasOnly;
|
|
497
523
|
runner.asyncOnly = options.asyncOnly;
|
|
498
524
|
runner.allowUncaught = options.allowUncaught;
|
|
525
|
+
runner.forbidOnly = options.forbidOnly;
|
|
526
|
+
runner.forbidPending = options.forbidPending;
|
|
499
527
|
if (options.grep) {
|
|
500
528
|
runner.grep(options.grep, options.invert);
|
|
501
529
|
}
|
package/lib/reporters/html.js
CHANGED
|
@@ -41,6 +41,8 @@ var statsTemplate = '<ul id="mocha-stats">' +
|
|
|
41
41
|
'<li class="duration">duration: <em>0</em>s</li>' +
|
|
42
42
|
'</ul>';
|
|
43
43
|
|
|
44
|
+
var playIcon = '‣';
|
|
45
|
+
|
|
44
46
|
/**
|
|
45
47
|
* Initialize a new `HTML` reporter.
|
|
46
48
|
*
|
|
@@ -136,7 +138,7 @@ function HTML (runner) {
|
|
|
136
138
|
runner.on('pass', function (test) {
|
|
137
139
|
var url = self.testURL(test);
|
|
138
140
|
var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
|
|
139
|
-
'<a href="%s" class="replay"
|
|
141
|
+
'<a href="%s" class="replay">' + playIcon + '</a></h2></li>';
|
|
140
142
|
var el = fragment(markup, test.speed, test.title, test.duration, url);
|
|
141
143
|
self.addCodeToggle(el, test.body);
|
|
142
144
|
appendToStack(el);
|
|
@@ -144,7 +146,7 @@ function HTML (runner) {
|
|
|
144
146
|
});
|
|
145
147
|
|
|
146
148
|
runner.on('fail', function (test) {
|
|
147
|
-
var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay"
|
|
149
|
+
var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">' + playIcon + '</a></h2></li>',
|
|
148
150
|
test.title, self.testURL(test));
|
|
149
151
|
var stackString; // Note: Includes leading newline
|
|
150
152
|
var message = test.err.toString();
|
package/lib/runnable.js
CHANGED
package/lib/runner.js
CHANGED
|
@@ -432,15 +432,14 @@ Runner.prototype.runTest = function (fn) {
|
|
|
432
432
|
if (this.asyncOnly) {
|
|
433
433
|
test.asyncOnly = true;
|
|
434
434
|
}
|
|
435
|
-
|
|
435
|
+
test.on('error', function (err) {
|
|
436
|
+
self.fail(test, err);
|
|
437
|
+
});
|
|
436
438
|
if (this.allowUncaught) {
|
|
437
439
|
test.allowUncaught = true;
|
|
438
440
|
return test.run(fn);
|
|
439
441
|
}
|
|
440
442
|
try {
|
|
441
|
-
test.on('error', function (err) {
|
|
442
|
-
self.fail(test, err);
|
|
443
|
-
});
|
|
444
443
|
test.run(fn);
|
|
445
444
|
} catch (err) {
|
|
446
445
|
fn(err);
|
|
@@ -681,9 +680,9 @@ Runner.prototype.runSuite = function (suite, fn) {
|
|
|
681
680
|
*/
|
|
682
681
|
Runner.prototype.uncaught = function (err) {
|
|
683
682
|
if (err) {
|
|
684
|
-
debug('uncaught exception %s', err
|
|
683
|
+
debug('uncaught exception %s', err === (function () {
|
|
685
684
|
return this;
|
|
686
|
-
}.call(err) ?
|
|
685
|
+
}.call(err)) ? (err.message || err) : err);
|
|
687
686
|
} else {
|
|
688
687
|
debug('uncaught undefined exception');
|
|
689
688
|
err = undefinedError();
|
|
@@ -821,6 +820,12 @@ Runner.prototype.run = function (fn) {
|
|
|
821
820
|
|
|
822
821
|
// callback
|
|
823
822
|
this.on('end', function () {
|
|
823
|
+
if (self.forbidOnly && self.hasOnly) {
|
|
824
|
+
self.failures += self.stats.tests;
|
|
825
|
+
}
|
|
826
|
+
if (self.forbidPending) {
|
|
827
|
+
self.failures += self.stats.pending;
|
|
828
|
+
}
|
|
824
829
|
debug('end');
|
|
825
830
|
process.removeListener('uncaughtException', uncaught);
|
|
826
831
|
fn(self.failures);
|
package/lib/utils.js
CHANGED
|
@@ -322,7 +322,9 @@ exports.parseQuery = function (qs) {
|
|
|
322
322
|
var key = pair.slice(0, i);
|
|
323
323
|
var val = pair.slice(++i);
|
|
324
324
|
|
|
325
|
-
|
|
325
|
+
// Due to how the URLSearchParams API treats spaces
|
|
326
|
+
obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
|
|
327
|
+
|
|
326
328
|
return obj;
|
|
327
329
|
}, {});
|
|
328
330
|
};
|
|
@@ -416,7 +418,7 @@ var type = exports.type = function type (value) {
|
|
|
416
418
|
return 'buffer';
|
|
417
419
|
}
|
|
418
420
|
return Object.prototype.toString.call(value)
|
|
419
|
-
.replace(/^\[.+\s(.+?)
|
|
421
|
+
.replace(/^\[.+\s(.+?)]$/, '$1')
|
|
420
422
|
.toLowerCase();
|
|
421
423
|
};
|
|
422
424
|
|
|
@@ -741,7 +743,9 @@ exports.stackTraceFilter = function () {
|
|
|
741
743
|
if (is.node) {
|
|
742
744
|
cwd = process.cwd() + slash;
|
|
743
745
|
} else {
|
|
744
|
-
cwd = (typeof location === 'undefined'
|
|
746
|
+
cwd = (typeof location === 'undefined'
|
|
747
|
+
? window.location
|
|
748
|
+
: location).href.replace(/\/[^/]*$/, '/');
|
|
745
749
|
slash = '/';
|
|
746
750
|
}
|
|
747
751
|
|