mocha 3.1.2 → 3.4.2
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 +190 -0
- package/LICENSE +1 -1
- package/README.md +42 -3
- package/bin/_mocha +19 -2
- package/bin/mocha +3 -0
- package/lib/interfaces/common.js +1 -1
- package/lib/mocha.js +11 -3
- package/lib/reporters/html.js +4 -2
- package/lib/reporters/list.js +1 -1
- package/lib/reporters/xunit.js +1 -1
- package/lib/runnable.js +9 -4
- package/lib/runner.js +5 -6
- package/lib/utils.js +9 -4
- package/mocha.js +1236 -587
- package/package.json +31 -17
- package/bin/.eslintrc +0 -3
- package/lib/utils.js.orig +0 -804
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,193 @@
|
|
|
1
|
+
# 3.4.2 / 2017-05-24
|
|
2
|
+
|
|
3
|
+
## :bug: Fixes
|
|
4
|
+
|
|
5
|
+
- [#2802]: Remove call to deprecated os.tmpDir ([@makepanic])
|
|
6
|
+
- [#2820]: Eagerly set process.exitCode ([@chrisleck])
|
|
7
|
+
|
|
8
|
+
## :nut_and_bolt: Other
|
|
9
|
+
|
|
10
|
+
- [#2778]: Move linting into an npm script ([@Munter])
|
|
11
|
+
|
|
12
|
+
[@chrisleck]: https://github.com/chrisleck
|
|
13
|
+
[@makepanic]: https://github.com/makepanic
|
|
14
|
+
[@Munter]: https://github.com/Munter
|
|
15
|
+
|
|
16
|
+
[#2802]: https://github.com/mochajs/mocha/issues/2802
|
|
17
|
+
[#2820]: https://github.com/mochajs/mocha/pull/2820
|
|
18
|
+
|
|
19
|
+
# 3.4.1 / 2017-05-14
|
|
20
|
+
|
|
21
|
+
Fixed a publishing mishap with git's autocrlf settings.
|
|
22
|
+
|
|
23
|
+
# 3.4.0 / 2017-05-14
|
|
24
|
+
|
|
25
|
+
Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.
|
|
26
|
+
|
|
27
|
+
This week's highlights:
|
|
28
|
+
|
|
29
|
+
- `allowUncaught` added to commandline as `--allow-uncaught` (and bugfixed)
|
|
30
|
+
- warning-related Node flags
|
|
31
|
+
|
|
32
|
+
## :tada: Enhancements
|
|
33
|
+
|
|
34
|
+
- [#2793], [#2697]: add --allowUncaught to Node.js ([@lrowe])
|
|
35
|
+
- [#2733]: Add `--no-warnings` and `--trace-warnings` flags ([@sonicdoe])
|
|
36
|
+
|
|
37
|
+
## :bug: Fixes
|
|
38
|
+
|
|
39
|
+
- [#2793], [#2697]: fix broken allowUncaught ([@lrowe])
|
|
40
|
+
|
|
41
|
+
## :nut_and_bolt: Other
|
|
42
|
+
|
|
43
|
+
- [#2778]: Add license report and scan status ([@xizhao])
|
|
44
|
+
- [#2794]: no special case for macOS running Karma locally ([@boneskull])
|
|
45
|
+
- [#2795]: reverts use of semistandard directly ([#2648]) ([@boneskull])
|
|
46
|
+
|
|
47
|
+
[@lrowe]: https://github.com/lrowe
|
|
48
|
+
[@sonicdoe]: https://github.com/sonicdoe
|
|
49
|
+
[@xizhao]: https://github.com/xizhao
|
|
50
|
+
[@boneskull]: https://github.com/boneskull
|
|
51
|
+
|
|
52
|
+
[#2795]: https://github.com/mochajs/mocha/pull/2795
|
|
53
|
+
[#2733]: https://github.com/mochajs/mocha/pull/2733
|
|
54
|
+
[#2793]: https://github.com/mochajs/mocha/pull/2793
|
|
55
|
+
[#2697]: https://github.com/mochajs/mocha/pull/2697
|
|
56
|
+
[#2778]: https://github.com/mochajs/mocha/pull/2778
|
|
57
|
+
[#2794]: https://github.com/mochajs/mocha/pull/2794
|
|
58
|
+
|
|
59
|
+
# 3.3.0 / 2017-04-24
|
|
60
|
+
|
|
61
|
+
Thanks to all our contributors, maintainers, sponsors, and users! ❤️
|
|
62
|
+
|
|
63
|
+
As highlights:
|
|
64
|
+
|
|
65
|
+
- We've got coverage now!
|
|
66
|
+
- Testing is looking less flaky \o/.
|
|
67
|
+
- No more nitpicking about "mocha.js" build on PRs.
|
|
68
|
+
|
|
69
|
+
## :tada: Enhancements
|
|
70
|
+
|
|
71
|
+
- [#2659]: Adds support for loading reporter from an absolute or relative path ([@sul4bh])
|
|
72
|
+
- [#2769]: Support `--inspect-brk` on command-line ([@igwejk])
|
|
73
|
+
|
|
74
|
+
## :bug: Fixes
|
|
75
|
+
|
|
76
|
+
- [#2662]: Replace unicode chars w/ hex codes in HTML reporter ([@rotemdan])
|
|
77
|
+
|
|
78
|
+
## :mag: Coverage
|
|
79
|
+
|
|
80
|
+
- [#2672]: Add coverage for node tests ([@c089], [@Munter])
|
|
81
|
+
- [#2680]: Increase tests coverage for base reporter ([@epallerols])
|
|
82
|
+
- [#2690]: Increase tests coverage for doc reporter ([@craigtaub])
|
|
83
|
+
- [#2701]: Increase tests coverage for landing, min, tap and list reporters ([@craigtaub])
|
|
84
|
+
- [#2691]: Increase tests coverage for spec + dot reporters ([@craigtaub])
|
|
85
|
+
- [#2698]: Increase tests coverage for xunit reporter ([@craigtaub])
|
|
86
|
+
- [#2699]: Increase tests coverage for json-stream, markdown and progress reporters ([@craigtaub])
|
|
87
|
+
- [#2703]: Cover .some() function in utils.js with tests ([@seppevs])
|
|
88
|
+
- [#2773]: Add tests for loading reporters w/ relative/absolute paths ([@sul4bh])
|
|
89
|
+
|
|
90
|
+
## :nut_and_bolt: Other
|
|
91
|
+
|
|
92
|
+
- Remove bin/.eslintrc; ensure execs are linted ([@boneskull])
|
|
93
|
+
- [#2542]: Expand CONTRIBUTING.md ([@boneskull])
|
|
94
|
+
- [#2660]: Double timeouts on integration tests ([@Munter])
|
|
95
|
+
- [#2653]: Update copyright year ([@Scottkao85], [@Munter])
|
|
96
|
+
- [#2621]: Update dependencies to enable Greenkeeper ([@boneskull], [@greenkeeper])
|
|
97
|
+
- [#2625]: Use trusty container in travis-ci; use "artifacts" addon ([@boneskull])
|
|
98
|
+
- [#2670]: doc(CONTRIBUTING): fix link to org members ([@coderbyheart])
|
|
99
|
+
- Add Mocha propaganda to README.md ([@boneskull])
|
|
100
|
+
- [#2470]: Avoid test flake in "delay" test ([@boneskull])
|
|
101
|
+
- [#2675]: Limit browser concurrency on sauce ([@boneskull])
|
|
102
|
+
- [#2669]: Use temporary test-only build of mocha.js for browsers tests ([@Munter])
|
|
103
|
+
- Fix "projects" link in README.md ([@boneskull])
|
|
104
|
+
- [#2678]: Chore(Saucelabs): test on IE9, IE10 and IE11 ([@coderbyheart])
|
|
105
|
+
- [#2648]: Use `semistandard` directly ([@kt3k])
|
|
106
|
+
- [#2727]: Make the build reproducible ([@lamby])
|
|
107
|
+
|
|
108
|
+
[@boneskull]: https://github.com/boneskull
|
|
109
|
+
[@c089]: https://github.com/c089
|
|
110
|
+
[@coderbyheart]: https://github.com/coderbyheart
|
|
111
|
+
[@craigtaub]: https://github.com/craigtaub
|
|
112
|
+
[@epallerols]: https://github.com/epallerols
|
|
113
|
+
[@greenkeeper]: https://github.com/greenkeeper
|
|
114
|
+
[@igwejk]: https://github.com/igwejk
|
|
115
|
+
[@kt3k]: https://github.com/kt3k
|
|
116
|
+
[@lamby]: https://github.com/lamby
|
|
117
|
+
[@Munter]: https://github.com/Munter
|
|
118
|
+
[@rotemdan]: https://github.com/rotemdan
|
|
119
|
+
[@seppevs]: https://github.com/seppevs
|
|
120
|
+
[@sul4bh]: https://github.com/sul4bh
|
|
121
|
+
|
|
122
|
+
[#2470]: https://github.com/mochajs/mocha/pull/2470
|
|
123
|
+
[#2542]: https://github.com/mochajs/mocha/issues/2542
|
|
124
|
+
[#2621]: https://github.com/mochajs/mocha/pull/2621
|
|
125
|
+
[#2625]: https://github.com/mochajs/mocha/pull/2625
|
|
126
|
+
[#2648]: https://github.com/mochajs/mocha/pull/2648
|
|
127
|
+
[#2653]: https://github.com/mochajs/mocha/pull/2653
|
|
128
|
+
[#2659]: https://github.com/mochajs/mocha/pull/2659
|
|
129
|
+
[#2660]: https://github.com/mochajs/mocha/pull/2660
|
|
130
|
+
[#2662]: https://github.com/mochajs/mocha/pull/2662
|
|
131
|
+
[#2669]: https://github.com/mochajs/mocha/pull/2669
|
|
132
|
+
[#2670]: https://github.com/mochajs/mocha/pull/2670
|
|
133
|
+
[#2672]: https://github.com/mochajs/mocha/pull/2672
|
|
134
|
+
[#2675]: https://github.com/mochajs/mocha/pull/2675
|
|
135
|
+
[#2678]: https://github.com/mochajs/mocha/pull/2678
|
|
136
|
+
[#2680]: https://github.com/mochajs/mocha/pull/2680
|
|
137
|
+
[#2690]: https://github.com/mochajs/mocha/pull/2690
|
|
138
|
+
[#2691]: https://github.com/mochajs/mocha/pull/2691
|
|
139
|
+
[#2698]: https://github.com/mochajs/mocha/pull/2698
|
|
140
|
+
[#2699]: https://github.com/mochajs/mocha/pull/2699
|
|
141
|
+
[#2701]: https://github.com/mochajs/mocha/pull/2701
|
|
142
|
+
[#2703]: https://github.com/mochajs/mocha/pull/2703
|
|
143
|
+
[#2727]: https://github.com/mochajs/mocha/pull/2727
|
|
144
|
+
[#2769]: https://github.com/mochajs/mocha/pull/2769
|
|
145
|
+
[#2773]: https://github.com/mochajs/mocha/pull/2773
|
|
146
|
+
|
|
147
|
+
# 3.2.0 / 2016-11-24
|
|
148
|
+
|
|
149
|
+
## :newspaper: News
|
|
150
|
+
|
|
151
|
+
### Mocha is now a JS Foundation Project!
|
|
152
|
+
|
|
153
|
+
Mocha is proud to have joined the [JS Foundation](https://js.foundation). For more information, [read the announcement](https://js.foundation/announcements/2016/10/17/Linux-Foundation-Unites-JavaScript-Community-Open-Web-Development/).
|
|
154
|
+
|
|
155
|
+
### Contributor License Agreement
|
|
156
|
+
|
|
157
|
+
Under the foundation, all contributors to Mocha must sign the [JS Foundation CLA](https://js.foundation/CLA/) before their code can be merged. When sending a PR--if you have not already signed the CLA--a friendly bot will ask you to do so.
|
|
158
|
+
|
|
159
|
+
Mocha remains licensed under the [MIT license](https://github.com/mochajs/mocha/blob/master/LICENSE).
|
|
160
|
+
|
|
161
|
+
## :bug: Bug Fix
|
|
162
|
+
|
|
163
|
+
- [#2535]: Fix crash when `--watch` encounters broken symlinks ([@villesau])
|
|
164
|
+
- [#2593]: Fix (old) regression; incorrect symbol shown in `list` reporter ([@Aldaviva])
|
|
165
|
+
- [#2584]: Fix potential error when running XUnit reporter ([@vobujs])
|
|
166
|
+
|
|
167
|
+
## :tada: Enhancement
|
|
168
|
+
|
|
169
|
+
- [#2294]: Improve timeout error messaging ([@jeversmann], [@boneskull])
|
|
170
|
+
- [#2520]: Add info about `--inspect` flag to CLI help ([@ughitsaaron])
|
|
171
|
+
|
|
172
|
+
## :nut_and_bolt: Other
|
|
173
|
+
|
|
174
|
+
- [#2570]: Use [karma-mocha](https://npmjs.com/package/karma-mocha) proper ([@boneskull])
|
|
175
|
+
- Licenses updated to reflect new copyright, add link to license and browser matrix to `README.md` ([@boneskull], [@ScottFreeCode], [@dasilvacontin])
|
|
176
|
+
|
|
177
|
+
[#2294]: https://github.com/mochajs/mocha/issues/2294
|
|
178
|
+
[#2535]: https://github.com/mochajs/mocha/issues/2535
|
|
179
|
+
[#2520]: https://github.com/mochajs/mocha/pull/2520
|
|
180
|
+
[#2593]: https://github.com/mochajs/mocha/pull/2593
|
|
181
|
+
[#2584]: https://github.com/mochajs/mocha/issues/2584
|
|
182
|
+
[#2570]: https://github.com/mochajs/mocha/issues/2570
|
|
183
|
+
[@Aldaviva]: https://github.com/Aldaviva
|
|
184
|
+
[@jeversmann]: https://github.com/jeversmann
|
|
185
|
+
[@ughitsaaron]: https://github.com/ughitsaaron
|
|
186
|
+
[@villesau]: https://github.com/villesau
|
|
187
|
+
[@vobujs]: https://github.com/vobujs
|
|
188
|
+
|
|
189
|
+
Thanks to all our contributors, sponsors and backers! Keep on the lookout for a public roadmap and new contribution guide coming soon.
|
|
190
|
+
|
|
1
191
|
# 3.1.2 / 2016-10-10
|
|
2
192
|
|
|
3
193
|
## :bug: Bug Fix
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(The MIT License)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2011-
|
|
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,12 +1,49 @@
|
|
|
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
|
+
- Increase coverage against all interfaces (`exports` in particular). Ideally this becomes a "matrix" where we repeat sets of integration tests across all interfaces.
|
|
17
|
+
- 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.
|
|
18
|
+
2. Review current open pull requests
|
|
19
|
+
- We need individuals familiar with Mocha's codebase. Got questions? Ask them in [our chat room](https://gitter.im/mochajs/mocha).
|
|
20
|
+
- Pull requests **must** have supporting tests. The only exceptions are pure cosmetic or non-functional changes.
|
|
21
|
+
- Pull request contributors must sign the CLA.
|
|
22
|
+
3. Close old, inactive issues and pull requests
|
|
23
|
+
- A bot should do this. We need a bot. Got a bot?
|
|
24
|
+
4. Triage issues
|
|
25
|
+
- If we run into "critical" bugs, they need fixing.
|
|
26
|
+
- "Critical" means Mocha is broken w/o workarounds for a *large percentage* of users
|
|
27
|
+
- Otherwise: respond to issues, close new dupe issues, confirm bugs, ask for more info, etc.
|
|
28
|
+
|
|
29
|
+
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/).
|
|
30
|
+
|
|
31
|
+
*You needn't be a maintainer to submit a pull request for test coverage!*
|
|
32
|
+
|
|
33
|
+
-- @boneskull, *Jan 17 2016*
|
|
34
|
+
|
|
1
35
|
<br><br>
|
|
2
36
|
<p align="center">
|
|
3
37
|
<img src="https://cldup.com/xFVFxOioAU.svg" alt="Mocha test framework"/>
|
|
4
38
|
</p>
|
|
5
|
-
<br><br>
|
|
6
39
|
|
|
7
|
-
[](http://travis-ci.org/mochajs/mocha)
|
|
40
|
+
[](http://travis-ci.org/mochajs/mocha)
|
|
41
|
+
[](https://coveralls.io/github/mochajs/mocha)
|
|
42
|
+
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha?ref=badge_shield)
|
|
43
|
+
[](https://gitter.im/mochajs/mocha?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
8
44
|
[](#backers)
|
|
9
45
|
[](#sponsors)
|
|
46
|
+
<br><img alt="Mocha Browser Support h/t SauceLabs" src="https://saucelabs.com/browser-matrix/mochajs.svg" width="354">
|
|
10
47
|
|
|
11
48
|
Mocha is a simple, flexible, fun JavaScript test framework for node.js and the browser. For more information view the [documentation](http://mochajs.org).
|
|
12
49
|
|
|
@@ -81,4 +118,6 @@ Does your company use Mocha? Ask your manager or marketing team if your company
|
|
|
81
118
|
|
|
82
119
|
## License
|
|
83
120
|
|
|
84
|
-
MIT
|
|
121
|
+
[MIT](LICENSE)
|
|
122
|
+
|
|
123
|
+
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha?ref=badge_large)
|
package/bin/_mocha
CHANGED
|
@@ -90,10 +90,13 @@ program
|
|
|
90
90
|
.option('--preserve-symlinks', 'Instructs the module loader to preserve symbolic links when resolving and caching modules')
|
|
91
91
|
.option('--icu-data-dir', 'include ICU data')
|
|
92
92
|
.option('--inline-diffs', 'display actual/expected differences inline within each string')
|
|
93
|
+
.option('--inspect', 'activate devtools in chrome')
|
|
94
|
+
.option('--inspect-brk', 'activate devtools in chrome and break on the first line')
|
|
93
95
|
.option('--interfaces', 'display available interfaces')
|
|
94
96
|
.option('--no-deprecation', 'silence deprecation warnings')
|
|
95
97
|
.option('--no-exit', 'require a clean shutdown of the event loop: mocha will not call process.exit')
|
|
96
98
|
.option('--no-timeouts', 'disables timeouts, given implicitly with --debug')
|
|
99
|
+
.option('--no-warnings', 'silence all node process warnings')
|
|
97
100
|
.option('--opts <path>', 'specify opts path', 'test/mocha.opts')
|
|
98
101
|
.option('--perf-basic-prof', 'enable perf linux profiler (basic support)')
|
|
99
102
|
.option('--prof', 'log statistical profiling information')
|
|
@@ -104,9 +107,11 @@ program
|
|
|
104
107
|
.option('--throw-deprecation', 'throw an exception anytime a deprecated function is used')
|
|
105
108
|
.option('--trace', 'trace function calls')
|
|
106
109
|
.option('--trace-deprecation', 'show stack traces on deprecations')
|
|
110
|
+
.option('--trace-warnings', 'show stack traces on node process warnings')
|
|
107
111
|
.option('--use_strict', 'enforce strict mode')
|
|
108
112
|
.option('--watch-extensions <ext>,...', 'additional extensions to monitor with --watch', list, [])
|
|
109
|
-
.option('--delay', 'wait for async suite definition')
|
|
113
|
+
.option('--delay', 'wait for async suite definition')
|
|
114
|
+
.option('--allow-uncaught', 'enable uncaught errors to propagate');
|
|
110
115
|
|
|
111
116
|
program._name = 'mocha';
|
|
112
117
|
|
|
@@ -312,6 +317,12 @@ if (program.delay) {
|
|
|
312
317
|
mocha.delay();
|
|
313
318
|
}
|
|
314
319
|
|
|
320
|
+
// --allow-uncaught
|
|
321
|
+
|
|
322
|
+
if (program.allowUncaught) {
|
|
323
|
+
mocha.allowUncaught();
|
|
324
|
+
}
|
|
325
|
+
|
|
315
326
|
// --globals
|
|
316
327
|
|
|
317
328
|
mocha.globals(globals);
|
|
@@ -465,12 +476,18 @@ function exitLater (code) {
|
|
|
465
476
|
}
|
|
466
477
|
|
|
467
478
|
function exit (code) {
|
|
479
|
+
var clampedCode = Math.min(code, 255);
|
|
480
|
+
|
|
481
|
+
// Eagerly set the process's exit code in case stream.write doesn't
|
|
482
|
+
// execute its callback before the process terminates.
|
|
483
|
+
process.exitCode = clampedCode;
|
|
484
|
+
|
|
468
485
|
// flush output for Node.js Windows pipe bug
|
|
469
486
|
// https://github.com/joyent/node/issues/6247 is just one bug example
|
|
470
487
|
// https://github.com/visionmedia/mocha/issues/333 has a good discussion
|
|
471
488
|
function done () {
|
|
472
489
|
if (!(draining--)) {
|
|
473
|
-
process.exit(
|
|
490
|
+
process.exit(clampedCode);
|
|
474
491
|
}
|
|
475
492
|
}
|
|
476
493
|
|
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,10 +39,12 @@ 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':
|
package/lib/interfaces/common.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports = function (suites, context, mocha) {
|
|
|
16
16
|
* This is only present if flag --delay is passed into Mocha. It triggers
|
|
17
17
|
* root suite execution.
|
|
18
18
|
*
|
|
19
|
-
* @param {Suite} suite The root
|
|
19
|
+
* @param {Suite} suite The root suite.
|
|
20
20
|
* @return {Function} A function which runs the root suite
|
|
21
21
|
*/
|
|
22
22
|
runWithSuite: function runWithSuite (suite) {
|
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') {
|
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/reporters/list.js
CHANGED
|
@@ -42,7 +42,7 @@ function List (runner) {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
runner.on('pass', function (test) {
|
|
45
|
-
var fmt = color('checkmark', ' ' + Base.symbols.
|
|
45
|
+
var fmt = color('checkmark', ' ' + Base.symbols.ok) +
|
|
46
46
|
color('pass', ' %s: ') +
|
|
47
47
|
color(test.speed, '%dms');
|
|
48
48
|
cursor.CR();
|
package/lib/reporters/xunit.js
CHANGED
|
@@ -43,7 +43,7 @@ function XUnit (runner, options) {
|
|
|
43
43
|
var tests = [];
|
|
44
44
|
var self = this;
|
|
45
45
|
|
|
46
|
-
if (options.reporterOptions && options.reporterOptions.output) {
|
|
46
|
+
if (options && options.reporterOptions && options.reporterOptions.output) {
|
|
47
47
|
if (!fs.createWriteStream) {
|
|
48
48
|
throw new Error('file output not supported in browser');
|
|
49
49
|
}
|
package/lib/runnable.js
CHANGED
|
@@ -229,7 +229,8 @@ Runnable.prototype.resetTimeout = function () {
|
|
|
229
229
|
if (!self._enableTimeouts) {
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
|
-
self.callback(new Error('
|
|
232
|
+
self.callback(new Error('Timeout of ' + ms +
|
|
233
|
+
'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.'));
|
|
233
234
|
self.timedOut = true;
|
|
234
235
|
}, ms);
|
|
235
236
|
};
|
|
@@ -288,7 +289,8 @@ Runnable.prototype.run = function (fn) {
|
|
|
288
289
|
self.duration = new Date() - start;
|
|
289
290
|
finished = true;
|
|
290
291
|
if (!err && self.duration > ms && self._enableTimeouts) {
|
|
291
|
-
err = new Error('
|
|
292
|
+
err = new Error('Timeout of ' + ms +
|
|
293
|
+
'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.');
|
|
292
294
|
}
|
|
293
295
|
fn(err);
|
|
294
296
|
}
|
|
@@ -322,8 +324,11 @@ Runnable.prototype.run = function (fn) {
|
|
|
322
324
|
}
|
|
323
325
|
|
|
324
326
|
if (this.allowUncaught) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
+
if (this.isPending()) {
|
|
328
|
+
done();
|
|
329
|
+
} else {
|
|
330
|
+
callFn(this.fn);
|
|
331
|
+
}
|
|
327
332
|
return;
|
|
328
333
|
}
|
|
329
334
|
|
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();
|
package/lib/utils.js
CHANGED
|
@@ -16,6 +16,7 @@ var join = path.join;
|
|
|
16
16
|
var readdirSync = require('fs').readdirSync;
|
|
17
17
|
var statSync = require('fs').statSync;
|
|
18
18
|
var watchFile = require('fs').watchFile;
|
|
19
|
+
var lstatSync = require('fs').lstatSync;
|
|
19
20
|
var toISOString = require('./to-iso-string');
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -252,7 +253,7 @@ exports.files = function (dir, ext, ret) {
|
|
|
252
253
|
.filter(ignored)
|
|
253
254
|
.forEach(function (path) {
|
|
254
255
|
path = join(dir, path);
|
|
255
|
-
if (
|
|
256
|
+
if (lstatSync(path).isDirectory()) {
|
|
256
257
|
exports.files(path, ext, ret);
|
|
257
258
|
} else if (path.match(re)) {
|
|
258
259
|
ret.push(path);
|
|
@@ -321,7 +322,9 @@ exports.parseQuery = function (qs) {
|
|
|
321
322
|
var key = pair.slice(0, i);
|
|
322
323
|
var val = pair.slice(++i);
|
|
323
324
|
|
|
324
|
-
|
|
325
|
+
// Due to how the URLSearchParams API treats spaces
|
|
326
|
+
obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
|
|
327
|
+
|
|
325
328
|
return obj;
|
|
326
329
|
}, {});
|
|
327
330
|
};
|
|
@@ -415,7 +418,7 @@ var type = exports.type = function type (value) {
|
|
|
415
418
|
return 'buffer';
|
|
416
419
|
}
|
|
417
420
|
return Object.prototype.toString.call(value)
|
|
418
|
-
.replace(/^\[.+\s(.+?)
|
|
421
|
+
.replace(/^\[.+\s(.+?)]$/, '$1')
|
|
419
422
|
.toLowerCase();
|
|
420
423
|
};
|
|
421
424
|
|
|
@@ -740,7 +743,9 @@ exports.stackTraceFilter = function () {
|
|
|
740
743
|
if (is.node) {
|
|
741
744
|
cwd = process.cwd() + slash;
|
|
742
745
|
} else {
|
|
743
|
-
cwd = (typeof location === 'undefined'
|
|
746
|
+
cwd = (typeof location === 'undefined'
|
|
747
|
+
? window.location
|
|
748
|
+
: location).href.replace(/\/[^/]*$/, '/');
|
|
744
749
|
slash = '/';
|
|
745
750
|
}
|
|
746
751
|
|