zai-fca 1.0.7
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.
Potentially problematic release.
This version of zai-fca might be problematic. Click here for more details.
- package/.cache/replit/env/latest +56 -0
- package/.cache/replit/env/latest.json +1 -0
- package/.cache/replit/modules/nodejs-20.res +1 -0
- package/.cache/replit/modules/replit.res +1 -0
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/typescript/5.6/node_modules/.package-lock.json +178 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/index.d.ts +1365 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/package.json +25 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/README.md +48 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/index.d.ts +29 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/package.json +35 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/index.d.ts +2929 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/package.json +56 -0
- package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +1040 -0
- package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +385 -0
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +1933 -0
- package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +1549 -0
- package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +579 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +452 -0
- package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +4475 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +596 -0
- package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +476 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +865 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +124 -0
- package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +170 -0
- package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +931 -0
- package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +1275 -0
- package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +4396 -0
- package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +566 -0
- package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +1958 -0
- package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +2558 -0
- package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +543 -0
- package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +92 -0
- package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +3966 -0
- package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +402 -0
- package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +1001 -0
- package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +495 -0
- package/.cache/typescript/5.6/node_modules/@types/node/package.json +220 -0
- package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +200 -0
- package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +965 -0
- package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +1963 -0
- package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +117 -0
- package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +153 -0
- package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +589 -0
- package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +430 -0
- package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +153 -0
- package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +213 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +609 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +1726 -0
- package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +2248 -0
- package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +240 -0
- package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +1226 -0
- package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +197 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +92 -0
- package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +208 -0
- package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +972 -0
- package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +2371 -0
- package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +808 -0
- package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +976 -0
- package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +181 -0
- package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +745 -0
- package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +539 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/README.md +76 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/index.d.ts +57 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/package.json +50 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/index.d.ts +84 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/package.json +32 -0
- package/.cache/typescript/5.6/node_modules/@types/request/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/request/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/request/index.d.ts +395 -0
- package/.cache/typescript/5.6/node_modules/@types/request/package.json +70 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/index.d.ts +321 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/package.json +35 -0
- package/.cache/typescript/5.6/node_modules/asynckit/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/asynckit/README.md +233 -0
- package/.cache/typescript/5.6/node_modules/asynckit/bench.js +76 -0
- package/.cache/typescript/5.6/node_modules/asynckit/index.js +6 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/abort.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/async.js +34 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/defer.js +26 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/iterate.js +75 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/state.js +37 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/streamify.js +141 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/terminator.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/package.json +63 -0
- package/.cache/typescript/5.6/node_modules/asynckit/parallel.js +43 -0
- package/.cache/typescript/5.6/node_modules/asynckit/serial.js +17 -0
- package/.cache/typescript/5.6/node_modules/asynckit/serialOrdered.js +75 -0
- package/.cache/typescript/5.6/node_modules/asynckit/stream.js +21 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/License +19 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/Readme.md +138 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/package.json +25 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/yarn.lock +17 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/License +19 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/Makefile +7 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/Readme.md +141 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/package.json +27 -0
- package/.cache/typescript/5.6/node_modules/form-data/License +19 -0
- package/.cache/typescript/5.6/node_modules/form-data/Readme.md +350 -0
- package/.cache/typescript/5.6/node_modules/form-data/index.d.ts +51 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/browser.js +2 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/form_data.js +484 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/populate.js +10 -0
- package/.cache/typescript/5.6/node_modules/form-data/package.json +72 -0
- package/.cache/typescript/5.6/node_modules/mime-db/HISTORY.md +507 -0
- package/.cache/typescript/5.6/node_modules/mime-db/LICENSE +23 -0
- package/.cache/typescript/5.6/node_modules/mime-db/README.md +100 -0
- package/.cache/typescript/5.6/node_modules/mime-db/db.json +8519 -0
- package/.cache/typescript/5.6/node_modules/mime-db/index.js +12 -0
- package/.cache/typescript/5.6/node_modules/mime-db/package.json +60 -0
- package/.cache/typescript/5.6/node_modules/mime-types/HISTORY.md +397 -0
- package/.cache/typescript/5.6/node_modules/mime-types/LICENSE +23 -0
- package/.cache/typescript/5.6/node_modules/mime-types/README.md +113 -0
- package/.cache/typescript/5.6/node_modules/mime-types/index.js +188 -0
- package/.cache/typescript/5.6/node_modules/mime-types/package.json +44 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/README.md +584 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.d.ts +187 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.js +65 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/package.json +51 -0
- package/.cache/typescript/5.6/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.6/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.6/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/README.md +6 -0
- package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +31 -0
- package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +43 -0
- package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +36 -0
- package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +108 -0
- package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +34 -0
- package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +28 -0
- package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +255 -0
- package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +149 -0
- package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +61 -0
- package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +209 -0
- package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +39 -0
- package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +54 -0
- package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +108 -0
- package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +7 -0
- package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +15 -0
- package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +4 -0
- package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +71 -0
- package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +17 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +25 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/.cache/typescript/5.6/node_modules/undici-types/package.json +55 -0
- package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +33 -0
- package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +39 -0
- package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +60 -0
- package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +18 -0
- package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +222 -0
- package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +150 -0
- package/.cache/typescript/5.6/package-lock.json +190 -0
- package/.cache/typescript/5.6/package.json +1 -0
- package/.replit +4 -0
- package/.upm/store.json +1 -0
- package/LICENSE +21 -0
- package/README.md +289 -0
- package/index.js +460 -0
- package/package.json +45 -0
- package/src/Screenshot.js +83 -0
- package/src/addExternalModule.js +15 -0
- package/src/addUserToGroup.js +77 -0
- package/src/changeAdminStatus.js +47 -0
- package/src/changeArchivedStatus.js +41 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +65 -0
- package/src/changeBlockedStatus.js +36 -0
- package/src/changeGroupImage.js +106 -0
- package/src/changeNickname.js +45 -0
- package/src/changeThreadColor.js +61 -0
- package/src/changeThreadEmoji.js +41 -0
- package/src/createNewGroup.js +70 -0
- package/src/createPoll.js +59 -0
- package/src/createPost.js +277 -0
- package/src/deleteMessage.js +44 -0
- package/src/deleteThread.js +42 -0
- package/src/forwardAttachment.js +47 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +27 -0
- package/src/getFriendsList.js +73 -0
- package/src/getThreadHistory.js +537 -0
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +232 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +119 -0
- package/src/getUserID.js +61 -0
- package/src/getUserInfo.js +66 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/listenMqtt.js +827 -0
- package/src/listenMqtt.txt +827 -0
- package/src/logout.js +68 -0
- package/src/markAsDelivered.js +47 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +40 -0
- package/src/markAsSeen.js +48 -0
- package/src/muteThread.js +45 -0
- package/src/postFormData.txt +46 -0
- package/src/removeUserFromGroup.js +45 -0
- package/src/resolvePhotoUrl.js +36 -0
- package/src/searchForThread.js +42 -0
- package/src/sendMessage.js +329 -0
- package/src/sendTypingIndicator.js +70 -0
- package/src/setMessageReaction.js +109 -0
- package/src/setPostReaction.js +102 -0
- package/src/setTitle.js +70 -0
- package/src/shareContact.js +46 -0
- package/src/shareLink.js +62 -0
- package/src/threadColors.js +41 -0
- package/src/unfriend.js +42 -0
- package/src/unsendMessage.js +39 -0
- package/utils.js +2876 -0
@@ -0,0 +1,2929 @@
|
|
1
|
+
/**
|
2
|
+
* Mocha API
|
3
|
+
*
|
4
|
+
* @see https://mochajs.org/api/mocha
|
5
|
+
*/
|
6
|
+
declare class Mocha {
|
7
|
+
private _growl;
|
8
|
+
private _reporter;
|
9
|
+
private _ui;
|
10
|
+
|
11
|
+
constructor(options?: Mocha.MochaOptions);
|
12
|
+
|
13
|
+
suite: Mocha.Suite;
|
14
|
+
files: string[];
|
15
|
+
options: Mocha.MochaInstanceOptions;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Add test `file`.
|
19
|
+
*
|
20
|
+
* @see https://mochajs.org/api/mocha#addFile
|
21
|
+
*/
|
22
|
+
addFile(file: string): this;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Enable or disable bailing on the first failure.
|
26
|
+
*
|
27
|
+
* @see https://mochajs.org/api/mocha#bail
|
28
|
+
*/
|
29
|
+
bail(bail?: boolean): this;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Enables or disables whether or not to dispose after each test run.
|
33
|
+
* Disable this to ensure you can run the test suite multiple times.
|
34
|
+
* If disabled, be sure to dispose mocha when you're done to prevent memory leaks.
|
35
|
+
*
|
36
|
+
* @see https://mochajs.org/api/mocha#cleanReferencesAfterRun
|
37
|
+
*/
|
38
|
+
cleanReferencesAfterRun(clean?: boolean): this;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Manually dispose this mocha instance. Mark this instance as `disposed` and unable to run more tests.
|
42
|
+
* It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector.
|
43
|
+
*
|
44
|
+
* @see https://mochajs.org/api/mocha#dispose
|
45
|
+
*/
|
46
|
+
dispose(): void;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Set reporter to one of the built-in reporters.
|
50
|
+
*
|
51
|
+
* @see https://mochajs.org/api/mocha#reporter
|
52
|
+
*/
|
53
|
+
reporter(reporter: Mocha.Reporter, reporterOptions?: any): this;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter
|
57
|
+
* from a module path. Defaults to `"spec"`.
|
58
|
+
*
|
59
|
+
* @see https://mochajs.org/api/mocha#reporter
|
60
|
+
*/
|
61
|
+
reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this;
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Set test UI to one of the built-in test interfaces.
|
65
|
+
*
|
66
|
+
* @see https://mochajs.org/api/mocha#ui
|
67
|
+
*/
|
68
|
+
ui(name: Mocha.Interface): this;
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Set test UI to one of the built-in test interfaces or loads a test interface from a module
|
72
|
+
* path. Defaults to `"bdd"`.
|
73
|
+
*
|
74
|
+
* @see https://mochajs.org/api/mocha#ui
|
75
|
+
*/
|
76
|
+
ui(name?: string): this;
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Escape string and add it to grep as a RegExp.
|
80
|
+
*
|
81
|
+
* @see https://mochajs.org/api/mocha#fgrep
|
82
|
+
*/
|
83
|
+
fgrep(str: string): this;
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Add regexp to grep, if `re` is a string it is escaped.
|
87
|
+
*
|
88
|
+
* @see https://mochajs.org/api/mocha#grep
|
89
|
+
*/
|
90
|
+
grep(re: string | RegExp): this;
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Whether to activate dry-run mode.
|
94
|
+
*
|
95
|
+
* @param dryRun Whether to activate dry-run mode. Defaults to `true`.
|
96
|
+
*/
|
97
|
+
dryRun(dryRun?: boolean): this;
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Invert `.grep()` matches.
|
101
|
+
*
|
102
|
+
* @see https://mochajs.org/api/mocha#invert
|
103
|
+
*/
|
104
|
+
invert(): this;
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Enable global leak checking.
|
108
|
+
*
|
109
|
+
* @see https://mochajs.org/api/mocha#checkLeaks
|
110
|
+
*/
|
111
|
+
checkLeaks(): this;
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Display long stack-trace on failing
|
115
|
+
*
|
116
|
+
* @see https://mochajs.org/api/mocha#fullTrace
|
117
|
+
*/
|
118
|
+
fullTrace(): this;
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Enable growl support.
|
122
|
+
*
|
123
|
+
* @see https://mochajs.org/api/mocha#growl
|
124
|
+
*/
|
125
|
+
growl(): this;
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Ignore `globals` array or string.
|
129
|
+
*
|
130
|
+
* @see https://mochajs.org/api/mocha#globals
|
131
|
+
*/
|
132
|
+
globals(globals: string | readonly string[]): this;
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Set the timeout in milliseconds.
|
136
|
+
*
|
137
|
+
* @see https://mochajs.org/api/mocha#timeout
|
138
|
+
*/
|
139
|
+
timeout(timeout: string | number): this;
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Set the number of times to retry failed tests.
|
143
|
+
*
|
144
|
+
* @see https://mochajs.org/api/mocha#retries
|
145
|
+
*/
|
146
|
+
retries(n: number): this;
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Set slowness threshold in milliseconds.
|
150
|
+
*
|
151
|
+
* @see https://mochajs.org/api/mocha#slow
|
152
|
+
*/
|
153
|
+
slow(slow: string | number): this;
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Makes all tests async (accepting a callback)
|
157
|
+
*
|
158
|
+
* @see https://mochajs.org/api/mocha#asyncOnly.
|
159
|
+
*/
|
160
|
+
asyncOnly(): this;
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Disable syntax highlighting (in browser).
|
164
|
+
*
|
165
|
+
* @see https://mochajs.org/api/mocha#noHighlighting
|
166
|
+
*/
|
167
|
+
noHighlighting(): this;
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Enable uncaught errors to propagate (in browser).
|
171
|
+
*
|
172
|
+
* @see https://mochajs.org/api/mocha#allowUncaught
|
173
|
+
*/
|
174
|
+
allowUncaught(): boolean;
|
175
|
+
|
176
|
+
/**
|
177
|
+
* Delay root suite execution.
|
178
|
+
*
|
179
|
+
* @see https://mochajs.org/api/mocha#delay
|
180
|
+
*/
|
181
|
+
delay(): boolean;
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Fails test run if no tests encountered with exit-code 1.
|
185
|
+
*
|
186
|
+
* @see https://mochajs.org/api/mocha#failZero
|
187
|
+
*/
|
188
|
+
failZero(failZero?: boolean): this;
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Tests marked only fail the suite
|
192
|
+
*
|
193
|
+
* @see https://mochajs.org/api/mocha#forbidOnly
|
194
|
+
*/
|
195
|
+
forbidOnly(): boolean;
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Pending tests and tests marked skip fail the suite
|
199
|
+
*
|
200
|
+
* @see https://mochajs.org/api/mocha#forbidPending
|
201
|
+
*/
|
202
|
+
forbidPending(): boolean;
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Run tests and invoke `fn()` when complete.
|
206
|
+
*
|
207
|
+
* Note that `run` relies on Node's `require` to execute
|
208
|
+
* the test interface functions and will be subject to the
|
209
|
+
* cache - if the files are already in the `require` cache,
|
210
|
+
* they will effectively be skipped. Therefore, to run tests
|
211
|
+
* multiple times or to run tests in files that are already
|
212
|
+
* in the `require` cache, make sure to clear them from the
|
213
|
+
* cache first in whichever manner best suits your needs.
|
214
|
+
*
|
215
|
+
* @see https://mochajs.org/api/mocha#run
|
216
|
+
*/
|
217
|
+
run(fn?: (failures: number) => void): Mocha.Runner;
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Loads ESM (and CJS) test files asynchronously.
|
221
|
+
*
|
222
|
+
* @see https://mochajs.org/api/mocha#loadFilesAsync
|
223
|
+
*/
|
224
|
+
loadFilesAsync(): Promise<void>;
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Load registered files.
|
228
|
+
*
|
229
|
+
* @see https://mochajs.org/api/mocha#loadFiles
|
230
|
+
*/
|
231
|
+
protected loadFiles(fn?: () => void): void;
|
232
|
+
|
233
|
+
/**
|
234
|
+
* Unloads `files` from Node's `require` cache.
|
235
|
+
*
|
236
|
+
* This allows required files to be "freshly" reloaded, providing the ability
|
237
|
+
* to reuse a Mocha instance programmatically.
|
238
|
+
* Note: does not clear ESM module files from the cache
|
239
|
+
*/
|
240
|
+
unloadFiles(): this;
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Toggles parallel mode.
|
244
|
+
*
|
245
|
+
* Must be run before calling `run`. Changes the `Runner` class to
|
246
|
+
* use; also enables lazy file loading if not already done so.
|
247
|
+
*
|
248
|
+
* @see https://mochajs.org/api/mocha#parallelMode
|
249
|
+
*/
|
250
|
+
parallelMode(enabled?: boolean): this;
|
251
|
+
|
252
|
+
/**
|
253
|
+
* Assigns hooks to the root suite.
|
254
|
+
*
|
255
|
+
* @see https://mochajs.org/api/mocha#rootHooks
|
256
|
+
*/
|
257
|
+
rootHooks(hooks: Mocha.RootHookObject): this;
|
258
|
+
|
259
|
+
/**
|
260
|
+
* Configures one or more global setup fixtures.
|
261
|
+
* If given no parameters, unsets any previously-set fixtures.
|
262
|
+
*
|
263
|
+
* @see https://mochajs.org/api/mocha#globalSetup
|
264
|
+
*/
|
265
|
+
globalSetup: Mocha.HookFunction;
|
266
|
+
|
267
|
+
/**
|
268
|
+
* Configures one or more global teardown fixtures.
|
269
|
+
* If given no parameters, unsets any previously-set fixtures.
|
270
|
+
*
|
271
|
+
* @see https://mochajs.org/api/mocha#globalTeardown
|
272
|
+
*/
|
273
|
+
globalTeardown: Mocha.HookFunction;
|
274
|
+
|
275
|
+
/**
|
276
|
+
* Returns `true` if one or more global setup fixtures have been supplied
|
277
|
+
*
|
278
|
+
* @see https://mochajs.org/api/mocha#hasGlobalSetupFixtures
|
279
|
+
*/
|
280
|
+
hasGlobalSetupFixtures(): boolean;
|
281
|
+
|
282
|
+
/**
|
283
|
+
* Returns `true` if one or more global teardown fixtures have been supplied
|
284
|
+
*
|
285
|
+
* @see https://mochajs.org/api/mocha#hasGlobalTeardownFixtures
|
286
|
+
*/
|
287
|
+
hasGlobalTeardownFixtures(): boolean;
|
288
|
+
|
289
|
+
/**
|
290
|
+
* Toggle execution of any global setup fixture(s)
|
291
|
+
*
|
292
|
+
* @see https://mochajs.org/api/mocha#enableGlobalSetup
|
293
|
+
*/
|
294
|
+
enableGlobalSetup(enabled: boolean): this;
|
295
|
+
|
296
|
+
/**
|
297
|
+
* Toggle execution of any global teardown fixture(s)
|
298
|
+
*
|
299
|
+
* @see https://mochajs.org/api/mocha#enableGlobalTeardown
|
300
|
+
*/
|
301
|
+
enableGlobalTeardown(enabled: boolean): this;
|
302
|
+
}
|
303
|
+
|
304
|
+
declare namespace Mocha {
|
305
|
+
namespace utils {
|
306
|
+
/**
|
307
|
+
* Compute a slug from the given `str`.
|
308
|
+
*
|
309
|
+
* @see https://mochajs.org/api/module-utils.html#.slug
|
310
|
+
*/
|
311
|
+
function slug(str: string): string;
|
312
|
+
|
313
|
+
/**
|
314
|
+
* Strip the function definition from `str`, and re-indent for pre whitespace.
|
315
|
+
*
|
316
|
+
* @see https://mochajs.org/api/module-utils.html#.clean
|
317
|
+
*/
|
318
|
+
function clean(str: string): string;
|
319
|
+
|
320
|
+
/**
|
321
|
+
* Highlight the given string of `js`.
|
322
|
+
*/
|
323
|
+
function highlight(js: string): string;
|
324
|
+
|
325
|
+
/**
|
326
|
+
* Takes some variable and asks `Object.prototype.toString()` what it thinks it is.
|
327
|
+
*/
|
328
|
+
function type(value: any): string;
|
329
|
+
|
330
|
+
/**
|
331
|
+
* Stringify `value`. Different behavior depending on type of value:
|
332
|
+
*
|
333
|
+
* - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
|
334
|
+
* - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
|
335
|
+
* - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively.
|
336
|
+
* - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()`
|
337
|
+
*
|
338
|
+
* @see https://mochajs.org/api/module-utils.html#.stringify
|
339
|
+
*/
|
340
|
+
function stringify(value: any): string;
|
341
|
+
|
342
|
+
/**
|
343
|
+
* Return a new Thing that has the keys in sorted order. Recursive.
|
344
|
+
*
|
345
|
+
* If the Thing...
|
346
|
+
* - has already been seen, return string `'[Circular]'`
|
347
|
+
* - is `undefined`, return string `'[undefined]'`
|
348
|
+
* - is `null`, return value `null`
|
349
|
+
* - is some other primitive, return the value
|
350
|
+
* - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method
|
351
|
+
* - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again.
|
352
|
+
* - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively.
|
353
|
+
*
|
354
|
+
* @see https://mochajs.org/api/module-utils.html#.canonicalize
|
355
|
+
*/
|
356
|
+
function canonicalize(value: any, stack: any[], typeHint: string): any;
|
357
|
+
|
358
|
+
/**
|
359
|
+
* Generate an undefined error with a message warning the user.
|
360
|
+
*
|
361
|
+
* @see https://mochajs.org/api/module-utils.html#.undefinedError
|
362
|
+
*/
|
363
|
+
function undefinedError(): Error;
|
364
|
+
|
365
|
+
/**
|
366
|
+
* Generate an undefined error if `err` is not defined.
|
367
|
+
*
|
368
|
+
* @see https://mochajs.org/api/module-utils.html#.getError
|
369
|
+
*/
|
370
|
+
function getError(err: Error | undefined): Error;
|
371
|
+
|
372
|
+
/**
|
373
|
+
* When invoking this function you get a filter function that get the Error.stack as an
|
374
|
+
* input, and return a prettify output. (i.e: strip Mocha and internal node functions from
|
375
|
+
* stack trace).
|
376
|
+
*
|
377
|
+
* @see https://mochajs.org/api/module-utils.html#.stackTraceFilter
|
378
|
+
*/
|
379
|
+
function stackTraceFilter(): (stack: string) => string;
|
380
|
+
}
|
381
|
+
|
382
|
+
namespace interfaces {
|
383
|
+
function bdd(suite: Suite): void;
|
384
|
+
function tdd(suite: Suite): void;
|
385
|
+
function qunit(suite: Suite): void;
|
386
|
+
function exports(suite: Suite): void;
|
387
|
+
}
|
388
|
+
|
389
|
+
// #region Test interface augmentations
|
390
|
+
|
391
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
392
|
+
interface HookFunction<T extends void | Hook = void> {
|
393
|
+
/**
|
394
|
+
* [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the
|
395
|
+
* function is used as the name of the hook.
|
396
|
+
*
|
397
|
+
* - _Only available when invoked via the mocha CLI._
|
398
|
+
*/
|
399
|
+
(fn: Func): T;
|
400
|
+
|
401
|
+
/**
|
402
|
+
* [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the
|
403
|
+
* function is used as the name of the hook.
|
404
|
+
*
|
405
|
+
* - _Only available when invoked via the mocha CLI._
|
406
|
+
*/
|
407
|
+
(fn: AsyncFunc): T;
|
408
|
+
|
409
|
+
/**
|
410
|
+
* [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`.
|
411
|
+
*
|
412
|
+
* - _Only available when invoked via the mocha CLI._
|
413
|
+
*/
|
414
|
+
(name: string, fn?: Func): T;
|
415
|
+
|
416
|
+
/**
|
417
|
+
* [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`.
|
418
|
+
*
|
419
|
+
* - _Only available when invoked via the mocha CLI._
|
420
|
+
*/
|
421
|
+
(name: string, fn?: AsyncFunc): T;
|
422
|
+
}
|
423
|
+
|
424
|
+
interface SuiteFunction {
|
425
|
+
/**
|
426
|
+
* [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing
|
427
|
+
* nested suites.
|
428
|
+
*
|
429
|
+
* - _Only available when invoked via the mocha CLI._
|
430
|
+
*/
|
431
|
+
(title: string, fn: (this: Suite) => void): Suite;
|
432
|
+
|
433
|
+
/**
|
434
|
+
* [qunit] Describe a "suite" with the given `title`.
|
435
|
+
*
|
436
|
+
* - _Only available when invoked via the mocha CLI._
|
437
|
+
*/
|
438
|
+
(title: string): Suite;
|
439
|
+
|
440
|
+
/**
|
441
|
+
* [bdd, tdd, qunit] Indicates this suite should be executed exclusively.
|
442
|
+
*
|
443
|
+
* - _Only available when invoked via the mocha CLI._
|
444
|
+
*/
|
445
|
+
only: ExclusiveSuiteFunction;
|
446
|
+
|
447
|
+
/**
|
448
|
+
* [bdd, tdd] Indicates this suite should not be executed.
|
449
|
+
*
|
450
|
+
* - _Only available when invoked via the mocha CLI._
|
451
|
+
*/
|
452
|
+
skip: PendingSuiteFunction;
|
453
|
+
}
|
454
|
+
|
455
|
+
interface ExclusiveSuiteFunction {
|
456
|
+
/**
|
457
|
+
* [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing
|
458
|
+
* nested suites. Indicates this suite should be executed exclusively.
|
459
|
+
*
|
460
|
+
* - _Only available when invoked via the mocha CLI._
|
461
|
+
*/
|
462
|
+
(title: string, fn: (this: Suite) => void): Suite;
|
463
|
+
|
464
|
+
/**
|
465
|
+
* [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed
|
466
|
+
* exclusively.
|
467
|
+
*
|
468
|
+
* - _Only available when invoked via the mocha CLI._
|
469
|
+
*/
|
470
|
+
(title: string): Suite;
|
471
|
+
}
|
472
|
+
|
473
|
+
/**
|
474
|
+
* [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing
|
475
|
+
* nested suites. Indicates this suite should not be executed.
|
476
|
+
*
|
477
|
+
* - _Only available when invoked via the mocha CLI._
|
478
|
+
*
|
479
|
+
* @returns [bdd] `Suite`
|
480
|
+
* @returns [tdd] `void`
|
481
|
+
*/
|
482
|
+
interface PendingSuiteFunction {
|
483
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
484
|
+
(title: string, fn: (this: Suite) => void): Suite | void;
|
485
|
+
}
|
486
|
+
|
487
|
+
interface TestFunction {
|
488
|
+
/**
|
489
|
+
* Describe a specification or test-case with the given callback `fn` acting as a thunk.
|
490
|
+
* The name of the function is used as the name of the test.
|
491
|
+
*
|
492
|
+
* - _Only available when invoked via the mocha CLI._
|
493
|
+
*/
|
494
|
+
(fn: Func): Test;
|
495
|
+
|
496
|
+
/**
|
497
|
+
* Describe a specification or test-case with the given callback `fn` acting as a thunk.
|
498
|
+
* The name of the function is used as the name of the test.
|
499
|
+
*
|
500
|
+
* - _Only available when invoked via the mocha CLI._
|
501
|
+
*/
|
502
|
+
(fn: AsyncFunc): Test;
|
503
|
+
|
504
|
+
/**
|
505
|
+
* Describe a specification or test-case with the given `title` and callback `fn` acting
|
506
|
+
* as a thunk.
|
507
|
+
*
|
508
|
+
* - _Only available when invoked via the mocha CLI._
|
509
|
+
*/
|
510
|
+
(title: string, fn?: Func): Test;
|
511
|
+
|
512
|
+
/**
|
513
|
+
* Describe a specification or test-case with the given `title` and callback `fn` acting
|
514
|
+
* as a thunk.
|
515
|
+
*
|
516
|
+
* - _Only available when invoked via the mocha CLI._
|
517
|
+
*/
|
518
|
+
(title: string, fn?: AsyncFunc): Test;
|
519
|
+
|
520
|
+
/**
|
521
|
+
* Indicates this test should be executed exclusively.
|
522
|
+
*
|
523
|
+
* - _Only available when invoked via the mocha CLI._
|
524
|
+
*/
|
525
|
+
only: ExclusiveTestFunction;
|
526
|
+
|
527
|
+
/**
|
528
|
+
* Indicates this test should not be executed.
|
529
|
+
*
|
530
|
+
* - _Only available when invoked via the mocha CLI._
|
531
|
+
*/
|
532
|
+
skip: PendingTestFunction;
|
533
|
+
|
534
|
+
/**
|
535
|
+
* Number of attempts to retry.
|
536
|
+
*
|
537
|
+
* - _Only available when invoked via the mocha CLI._
|
538
|
+
*/
|
539
|
+
retries(n: number): void;
|
540
|
+
}
|
541
|
+
|
542
|
+
interface ExclusiveTestFunction {
|
543
|
+
/**
|
544
|
+
* [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn`
|
545
|
+
* acting as a thunk. The name of the function is used as the name of the test. Indicates
|
546
|
+
* this test should be executed exclusively.
|
547
|
+
*
|
548
|
+
* - _Only available when invoked via the mocha CLI._
|
549
|
+
*/
|
550
|
+
(fn: Func): Test;
|
551
|
+
|
552
|
+
/**
|
553
|
+
* [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn`
|
554
|
+
* acting as a thunk. The name of the function is used as the name of the test. Indicates
|
555
|
+
* this test should be executed exclusively.
|
556
|
+
*
|
557
|
+
* - _Only available when invoked via the mocha CLI._
|
558
|
+
*/
|
559
|
+
(fn: AsyncFunc): Test;
|
560
|
+
|
561
|
+
/**
|
562
|
+
* [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and
|
563
|
+
* callback `fn` acting as a thunk. Indicates this test should be executed exclusively.
|
564
|
+
*
|
565
|
+
* - _Only available when invoked via the mocha CLI._
|
566
|
+
*/
|
567
|
+
(title: string, fn?: Func): Test;
|
568
|
+
|
569
|
+
/**
|
570
|
+
* [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and
|
571
|
+
* callback `fn` acting as a thunk. Indicates this test should be executed exclusively.
|
572
|
+
*
|
573
|
+
* - _Only available when invoked via the mocha CLI._
|
574
|
+
*/
|
575
|
+
(title: string, fn?: AsyncFunc): Test;
|
576
|
+
}
|
577
|
+
|
578
|
+
interface PendingTestFunction {
|
579
|
+
/**
|
580
|
+
* [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn`
|
581
|
+
* acting as a thunk. The name of the function is used as the name of the test. Indicates
|
582
|
+
* this test should not be executed.
|
583
|
+
*
|
584
|
+
* - _Only available when invoked via the mocha CLI._
|
585
|
+
*/
|
586
|
+
(fn: Func): Test;
|
587
|
+
|
588
|
+
/**
|
589
|
+
* [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn`
|
590
|
+
* acting as a thunk. The name of the function is used as the name of the test. Indicates
|
591
|
+
* this test should not be executed.
|
592
|
+
*
|
593
|
+
* - _Only available when invoked via the mocha CLI._
|
594
|
+
*/
|
595
|
+
(fn: AsyncFunc): Test;
|
596
|
+
|
597
|
+
/**
|
598
|
+
* [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and
|
599
|
+
* callback `fn` acting as a thunk. Indicates this test should not be executed.
|
600
|
+
*
|
601
|
+
* - _Only available when invoked via the mocha CLI._
|
602
|
+
*/
|
603
|
+
(title: string, fn?: Func): Test;
|
604
|
+
|
605
|
+
/**
|
606
|
+
* [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and
|
607
|
+
* callback `fn` acting as a thunk. Indicates this test should not be executed.
|
608
|
+
*
|
609
|
+
* - _Only available when invoked via the mocha CLI._
|
610
|
+
*/
|
611
|
+
(title: string, fn?: AsyncFunc): Test;
|
612
|
+
}
|
613
|
+
|
614
|
+
/**
|
615
|
+
* Execute after each test case.
|
616
|
+
*
|
617
|
+
* - _Only available when invoked via the mocha CLI._
|
618
|
+
*
|
619
|
+
* @see https://mochajs.org/api/global.html#afterEach
|
620
|
+
*/
|
621
|
+
let afterEach: HookFunction<Hook>;
|
622
|
+
|
623
|
+
/**
|
624
|
+
* Execute after running tests.
|
625
|
+
*
|
626
|
+
* - _Only available when invoked via the mocha CLI._
|
627
|
+
*
|
628
|
+
* @see https://mochajs.org/api/global.html#after
|
629
|
+
*/
|
630
|
+
let after: HookFunction<Hook>;
|
631
|
+
|
632
|
+
/**
|
633
|
+
* Execute before each test case.
|
634
|
+
*
|
635
|
+
* - _Only available when invoked via the mocha CLI._
|
636
|
+
*
|
637
|
+
* @see https://mochajs.org/api/global.html#beforeEach
|
638
|
+
*/
|
639
|
+
let beforeEach: HookFunction<Hook>;
|
640
|
+
|
641
|
+
/**
|
642
|
+
* Execute before running tests.
|
643
|
+
*
|
644
|
+
* - _Only available when invoked via the mocha CLI._
|
645
|
+
*
|
646
|
+
* @see https://mochajs.org/api/global.html#before
|
647
|
+
*/
|
648
|
+
let before: HookFunction<Hook>;
|
649
|
+
|
650
|
+
/**
|
651
|
+
* Describe a "suite" containing nested suites and tests.
|
652
|
+
*
|
653
|
+
* - _Only available when invoked via the mocha CLI._
|
654
|
+
*/
|
655
|
+
let describe: SuiteFunction;
|
656
|
+
|
657
|
+
/**
|
658
|
+
* Describe a pending suite.
|
659
|
+
*
|
660
|
+
* - _Only available when invoked via the mocha CLI._
|
661
|
+
*/
|
662
|
+
let xdescribe: PendingSuiteFunction;
|
663
|
+
|
664
|
+
/**
|
665
|
+
* Describes a test case.
|
666
|
+
*
|
667
|
+
* - _Only available when invoked via the mocha CLI._
|
668
|
+
*/
|
669
|
+
let it: TestFunction;
|
670
|
+
|
671
|
+
/**
|
672
|
+
* Describes a pending test case.
|
673
|
+
*
|
674
|
+
* - _Only available when invoked via the mocha CLI._
|
675
|
+
*/
|
676
|
+
let xit: PendingTestFunction;
|
677
|
+
|
678
|
+
/**
|
679
|
+
* Execute before each test case.
|
680
|
+
*
|
681
|
+
* - _Only available when invoked via the mocha CLI._
|
682
|
+
*
|
683
|
+
* @see https://mochajs.org/api/global.html#beforeEach
|
684
|
+
*/
|
685
|
+
let setup: HookFunction;
|
686
|
+
|
687
|
+
/**
|
688
|
+
* Execute before running tests.
|
689
|
+
*
|
690
|
+
* - _Only available when invoked via the mocha CLI._
|
691
|
+
*
|
692
|
+
* @see https://mochajs.org/api/global.html#before
|
693
|
+
*/
|
694
|
+
let suiteSetup: HookFunction;
|
695
|
+
|
696
|
+
/**
|
697
|
+
* Execute after running tests.
|
698
|
+
*
|
699
|
+
* - _Only available when invoked via the mocha CLI._
|
700
|
+
*
|
701
|
+
* @see https://mochajs.org/api/global.html#after
|
702
|
+
*/
|
703
|
+
let suiteTeardown: HookFunction;
|
704
|
+
|
705
|
+
/**
|
706
|
+
* Describe a "suite" containing nested suites and tests.
|
707
|
+
*
|
708
|
+
* - _Only available when invoked via the mocha CLI._
|
709
|
+
*/
|
710
|
+
let suite: SuiteFunction;
|
711
|
+
|
712
|
+
/**
|
713
|
+
* Execute after each test case.
|
714
|
+
*
|
715
|
+
* - _Only available when invoked via the mocha CLI._
|
716
|
+
*
|
717
|
+
* @see https://mochajs.org/api/global.html#afterEach
|
718
|
+
*/
|
719
|
+
let teardown: HookFunction;
|
720
|
+
|
721
|
+
/**
|
722
|
+
* Describes a test case.
|
723
|
+
*
|
724
|
+
* - _Only available when invoked via the mocha CLI._
|
725
|
+
*/
|
726
|
+
let test: TestFunction;
|
727
|
+
|
728
|
+
/**
|
729
|
+
* Triggers root suite execution.
|
730
|
+
*
|
731
|
+
* - _Only available if flag --delay is passed into Mocha._
|
732
|
+
* - _Only available when invoked via the mocha CLI._
|
733
|
+
*
|
734
|
+
* @see https://mochajs.org/api/global.html#runWithSuite
|
735
|
+
*/
|
736
|
+
function run(): void;
|
737
|
+
|
738
|
+
// #endregion Test interface augmentations
|
739
|
+
|
740
|
+
namespace reporters {
|
741
|
+
/**
|
742
|
+
* Initialize a new `Base` reporter.
|
743
|
+
*
|
744
|
+
* All other reporters generally inherit from this reporter, providing stats such as test duration,
|
745
|
+
* number of tests passed / failed, etc.
|
746
|
+
*
|
747
|
+
* @see https://mochajs.org/api/Mocha.reporters.Base.html
|
748
|
+
*/
|
749
|
+
class Base {
|
750
|
+
constructor(runner: Runner, options?: MochaOptions);
|
751
|
+
|
752
|
+
/**
|
753
|
+
* Test run statistics
|
754
|
+
*/
|
755
|
+
stats: Stats;
|
756
|
+
|
757
|
+
/**
|
758
|
+
* Test failures
|
759
|
+
*/
|
760
|
+
failures: Test[];
|
761
|
+
|
762
|
+
/**
|
763
|
+
* The configured runner
|
764
|
+
*/
|
765
|
+
runner: Runner;
|
766
|
+
|
767
|
+
/**
|
768
|
+
* Output common epilogue used by many of the bundled reporters.
|
769
|
+
*
|
770
|
+
* @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue
|
771
|
+
*/
|
772
|
+
epilogue(): void;
|
773
|
+
|
774
|
+
done?(failures: number, fn?: (failures: number) => void): void;
|
775
|
+
|
776
|
+
static consoleLog: (...data: any[]) => void;
|
777
|
+
}
|
778
|
+
|
779
|
+
namespace Base {
|
780
|
+
/**
|
781
|
+
* Enables coloring by default
|
782
|
+
*
|
783
|
+
* @see https://mochajs.org/api/module-base#.useColors
|
784
|
+
*/
|
785
|
+
let useColors: boolean;
|
786
|
+
|
787
|
+
/**
|
788
|
+
* Inline diffs instead of +/-
|
789
|
+
*
|
790
|
+
* @see https://mochajs.org/api/module-base#.inlineDiffs
|
791
|
+
*/
|
792
|
+
let inlineDiffs: boolean;
|
793
|
+
|
794
|
+
/**
|
795
|
+
* Default color map
|
796
|
+
*
|
797
|
+
* @see https://mochajs.org/api/module-base#.colors
|
798
|
+
*/
|
799
|
+
const colors: ColorMap;
|
800
|
+
|
801
|
+
/**
|
802
|
+
* Default color map
|
803
|
+
*
|
804
|
+
* @see https://mochajs.org/api/module-base#.colors
|
805
|
+
*/
|
806
|
+
interface ColorMap {
|
807
|
+
// added by Base
|
808
|
+
pass: number;
|
809
|
+
fail: number;
|
810
|
+
"bright pass": number;
|
811
|
+
"bright fail": number;
|
812
|
+
"bright yellow": number;
|
813
|
+
pending: number;
|
814
|
+
suite: number;
|
815
|
+
"error title": number;
|
816
|
+
"error message": number;
|
817
|
+
"error stack": number;
|
818
|
+
checkmark: number;
|
819
|
+
fast: number;
|
820
|
+
medium: number;
|
821
|
+
slow: number;
|
822
|
+
green: number;
|
823
|
+
light: number;
|
824
|
+
"diff gutter": number;
|
825
|
+
"diff added": number;
|
826
|
+
"diff removed": number;
|
827
|
+
|
828
|
+
// added by Progress
|
829
|
+
progress: number;
|
830
|
+
|
831
|
+
// added by Landing
|
832
|
+
plane: number;
|
833
|
+
"plane crash": number;
|
834
|
+
runway: number;
|
835
|
+
|
836
|
+
[key: string]: number;
|
837
|
+
}
|
838
|
+
|
839
|
+
/**
|
840
|
+
* Default symbol map
|
841
|
+
*
|
842
|
+
* @see https://mochajs.org/api/module-base#.symbols
|
843
|
+
*/
|
844
|
+
const symbols: SymbolMap;
|
845
|
+
|
846
|
+
/**
|
847
|
+
* Default symbol map
|
848
|
+
*
|
849
|
+
* @see https://mochajs.org/api/module-base#.symbols
|
850
|
+
*/
|
851
|
+
interface SymbolMap {
|
852
|
+
ok: string;
|
853
|
+
err: string;
|
854
|
+
dot: string;
|
855
|
+
comma: string;
|
856
|
+
bang: string;
|
857
|
+
[key: string]: string;
|
858
|
+
}
|
859
|
+
|
860
|
+
/**
|
861
|
+
* Color `str` with the given `type` (from `colors`)
|
862
|
+
*
|
863
|
+
* @see https://mochajs.org/api/module-base#.color
|
864
|
+
*/
|
865
|
+
function color(type: string, str: string): string;
|
866
|
+
|
867
|
+
/**
|
868
|
+
* Expose terminal window size
|
869
|
+
*
|
870
|
+
* @see https://mochajs.org/api/module-base#.window
|
871
|
+
*/
|
872
|
+
const window: {
|
873
|
+
width: number;
|
874
|
+
};
|
875
|
+
|
876
|
+
/**
|
877
|
+
* ANSI TTY control sequences common among reporters.
|
878
|
+
*
|
879
|
+
* @see https://mochajs.org/api/module-base#.cursor
|
880
|
+
*/
|
881
|
+
namespace cursor {
|
882
|
+
/**
|
883
|
+
* Hides the cursor
|
884
|
+
*/
|
885
|
+
function hide(): void;
|
886
|
+
|
887
|
+
/**
|
888
|
+
* Shows the cursor
|
889
|
+
*/
|
890
|
+
function show(): void;
|
891
|
+
|
892
|
+
/**
|
893
|
+
* Deletes the current line
|
894
|
+
*/
|
895
|
+
function deleteLine(): void;
|
896
|
+
|
897
|
+
/**
|
898
|
+
* Moves to the beginning of the line
|
899
|
+
*/
|
900
|
+
function beginningOfLine(): void;
|
901
|
+
|
902
|
+
/**
|
903
|
+
* Clears the line and moves to the beginning of the line.
|
904
|
+
*/
|
905
|
+
function CR(): void;
|
906
|
+
}
|
907
|
+
|
908
|
+
/**
|
909
|
+
* Returns a diff between two strings with colored ANSI output.
|
910
|
+
*
|
911
|
+
* @see https://mochajs.org/api/module-base#.generateDiff
|
912
|
+
*/
|
913
|
+
function generateDiff(actual: string, expected: string): string;
|
914
|
+
|
915
|
+
/**
|
916
|
+
* Output the given `failures` as a list.
|
917
|
+
*
|
918
|
+
* @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1
|
919
|
+
*/
|
920
|
+
function list(failures: Test[]): void;
|
921
|
+
}
|
922
|
+
|
923
|
+
/**
|
924
|
+
* Initialize a new `Dot` matrix test reporter.
|
925
|
+
*
|
926
|
+
* @see https://mochajs.org/api/Mocha.reporters.Dot.html
|
927
|
+
*/
|
928
|
+
class Dot extends Base {}
|
929
|
+
|
930
|
+
/**
|
931
|
+
* Initialize a new `Doc` reporter.
|
932
|
+
*
|
933
|
+
* @see https://mochajs.org/api/Mocha.reporters.Doc.html
|
934
|
+
*/
|
935
|
+
class Doc extends Base {}
|
936
|
+
|
937
|
+
/**
|
938
|
+
* Initialize a new `TAP` test reporter.
|
939
|
+
*
|
940
|
+
* @see https://mochajs.org/api/Mocha.reporters.TAP.html
|
941
|
+
*/
|
942
|
+
class TAP extends Base {}
|
943
|
+
|
944
|
+
/**
|
945
|
+
* Initialize a new `JSON` reporter
|
946
|
+
*
|
947
|
+
* @see https://mochajs.org/api/Mocha.reporters.JSON.html
|
948
|
+
*/
|
949
|
+
class JSON extends Base {}
|
950
|
+
|
951
|
+
/**
|
952
|
+
* Initialize a new `HTML` reporter.
|
953
|
+
*
|
954
|
+
* - _This reporter cannot be used on the console._
|
955
|
+
*
|
956
|
+
* @see https://mochajs.org/api/Mocha.reporters.HTML.html
|
957
|
+
*/
|
958
|
+
class HTML extends Base {
|
959
|
+
/**
|
960
|
+
* Provide suite URL.
|
961
|
+
*
|
962
|
+
* @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL
|
963
|
+
*/
|
964
|
+
suiteURL(suite: Suite): string;
|
965
|
+
|
966
|
+
/**
|
967
|
+
* Provide test URL.
|
968
|
+
*
|
969
|
+
* @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL
|
970
|
+
*/
|
971
|
+
testURL(test: Test): string;
|
972
|
+
|
973
|
+
/**
|
974
|
+
* Adds code toggle functionality for the provided test's list element.
|
975
|
+
*
|
976
|
+
* @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle
|
977
|
+
*/
|
978
|
+
addCodeToggle(el: HTMLLIElement, contents: string): void;
|
979
|
+
}
|
980
|
+
|
981
|
+
/**
|
982
|
+
* Initialize a new `List` test reporter.
|
983
|
+
*
|
984
|
+
* @see https://mochajs.org/api/Mocha.reporters.List.html
|
985
|
+
*/
|
986
|
+
class List extends Base {}
|
987
|
+
|
988
|
+
/**
|
989
|
+
* Initialize a new `Min` minimal test reporter (best used with --watch).
|
990
|
+
*
|
991
|
+
* @see https://mochajs.org/api/Mocha.reporters.Min.html
|
992
|
+
*/
|
993
|
+
class Min extends Base {}
|
994
|
+
|
995
|
+
/**
|
996
|
+
* Initialize a new `Spec` test reporter.
|
997
|
+
*
|
998
|
+
* @see https://mochajs.org/api/Mocha.reporters.Spec.html
|
999
|
+
*/
|
1000
|
+
class Spec extends Base {}
|
1001
|
+
|
1002
|
+
/**
|
1003
|
+
* Initialize a new `NyanCat` test reporter.
|
1004
|
+
*
|
1005
|
+
* @see https://mochajs.org/api/Mocha.reporters.Nyan.html
|
1006
|
+
*/
|
1007
|
+
class Nyan extends Base {
|
1008
|
+
private colorIndex;
|
1009
|
+
private numberOfLines;
|
1010
|
+
private rainbowColors;
|
1011
|
+
private scoreboardWidth;
|
1012
|
+
private tick;
|
1013
|
+
private trajectories;
|
1014
|
+
private trajectoryWidthMax;
|
1015
|
+
private draw;
|
1016
|
+
private drawScoreboard;
|
1017
|
+
private appendRainbow;
|
1018
|
+
private drawRainbow;
|
1019
|
+
private drawNyanCat;
|
1020
|
+
private face;
|
1021
|
+
private cursorUp;
|
1022
|
+
private cursorDown;
|
1023
|
+
private generateColors;
|
1024
|
+
private rainbowify;
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
/**
|
1028
|
+
* Initialize a new `XUnit` test reporter.
|
1029
|
+
*
|
1030
|
+
* @see https://mochajs.org/api/Mocha.reporters.XUnit.html
|
1031
|
+
*/
|
1032
|
+
class XUnit extends Base {
|
1033
|
+
constructor(runner: Runner, options?: XUnit.MochaOptions);
|
1034
|
+
|
1035
|
+
/**
|
1036
|
+
* Override done to close the stream (if it's a file).
|
1037
|
+
*
|
1038
|
+
* @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done
|
1039
|
+
*/
|
1040
|
+
done(failures: number, fn: (failures: number) => void): void;
|
1041
|
+
|
1042
|
+
/**
|
1043
|
+
* Write out the given line.
|
1044
|
+
*
|
1045
|
+
* @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write
|
1046
|
+
*/
|
1047
|
+
write(line: string): void;
|
1048
|
+
|
1049
|
+
/**
|
1050
|
+
* Output tag for the given `test.`
|
1051
|
+
*
|
1052
|
+
* @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test
|
1053
|
+
*/
|
1054
|
+
test(test: Test): void;
|
1055
|
+
}
|
1056
|
+
|
1057
|
+
namespace XUnit {
|
1058
|
+
interface MochaOptions extends Mocha.MochaOptions {
|
1059
|
+
reporterOptions?: ReporterOptions | undefined;
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
interface ReporterOptions {
|
1063
|
+
output?: string | undefined;
|
1064
|
+
suiteName?: string | undefined;
|
1065
|
+
}
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
/**
|
1069
|
+
* Initialize a new `Markdown` test reporter.
|
1070
|
+
*
|
1071
|
+
* @see https://mochajs.org/api/Mocha.reporters.Markdown.html
|
1072
|
+
*/
|
1073
|
+
class Markdown extends Base {}
|
1074
|
+
|
1075
|
+
/**
|
1076
|
+
* Initialize a new `Progress` bar test reporter.
|
1077
|
+
*
|
1078
|
+
* @see https://mochajs.org/api/Mocha.reporters.Progress.html
|
1079
|
+
*/
|
1080
|
+
class Progress extends Base {
|
1081
|
+
constructor(runner: Runner, options?: Progress.MochaOptions);
|
1082
|
+
}
|
1083
|
+
|
1084
|
+
namespace Progress {
|
1085
|
+
interface MochaOptions extends Mocha.MochaOptions {
|
1086
|
+
reporterOptions?: ReporterOptions | undefined;
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
interface ReporterOptions {
|
1090
|
+
open?: string | undefined;
|
1091
|
+
complete?: string | undefined;
|
1092
|
+
incomplete?: string | undefined;
|
1093
|
+
close?: string | undefined;
|
1094
|
+
verbose?: boolean | undefined;
|
1095
|
+
}
|
1096
|
+
}
|
1097
|
+
|
1098
|
+
/**
|
1099
|
+
* Initialize a new `Landing` reporter.
|
1100
|
+
*
|
1101
|
+
* @see https://mochajs.org/api/Mocha.reporters.Landing.html
|
1102
|
+
*/
|
1103
|
+
class Landing extends Base {}
|
1104
|
+
|
1105
|
+
/**
|
1106
|
+
* Initialize a new `JSONStream` test reporter.
|
1107
|
+
*
|
1108
|
+
* @see https://mochajs.org/api/Mocha.reporters.JSONStream.html
|
1109
|
+
*/
|
1110
|
+
class JSONStream extends Base {}
|
1111
|
+
|
1112
|
+
// value-only aliases
|
1113
|
+
const base: typeof Base;
|
1114
|
+
const dot: typeof Dot;
|
1115
|
+
const doc: typeof Doc;
|
1116
|
+
const tap: typeof TAP;
|
1117
|
+
const json: typeof JSON;
|
1118
|
+
const html: typeof HTML;
|
1119
|
+
const list: typeof List;
|
1120
|
+
const spec: typeof Spec;
|
1121
|
+
const nyan: typeof Nyan;
|
1122
|
+
const xunit: typeof XUnit;
|
1123
|
+
const markdown: typeof Markdown;
|
1124
|
+
const progress: typeof Progress;
|
1125
|
+
const landing: typeof Landing;
|
1126
|
+
// NOTE: not possible to type this correctly:
|
1127
|
+
// const "json-stream": typeof JSONStream;
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
/**
|
1131
|
+
* Initialize a new `Runnable` with the given `title` and callback `fn`.
|
1132
|
+
*
|
1133
|
+
* @see https://mochajs.org/api/Runnable.html
|
1134
|
+
*/
|
1135
|
+
class Runnable {
|
1136
|
+
private _slow;
|
1137
|
+
private _retries;
|
1138
|
+
private _currentRetry;
|
1139
|
+
private _timeout;
|
1140
|
+
private _timeoutError;
|
1141
|
+
|
1142
|
+
constructor(title: string, fn?: Func | AsyncFunc);
|
1143
|
+
|
1144
|
+
id: string;
|
1145
|
+
title: string;
|
1146
|
+
fn: Func | AsyncFunc | undefined;
|
1147
|
+
body: string;
|
1148
|
+
async: boolean;
|
1149
|
+
sync: boolean;
|
1150
|
+
timedOut: boolean;
|
1151
|
+
pending: boolean;
|
1152
|
+
duration?: number | undefined;
|
1153
|
+
parent?: Suite | undefined;
|
1154
|
+
state?: "failed" | "passed" | "pending" | undefined;
|
1155
|
+
timer?: any;
|
1156
|
+
ctx?: Context | undefined;
|
1157
|
+
callback?: Done | undefined;
|
1158
|
+
allowUncaught?: boolean | undefined;
|
1159
|
+
file?: string | undefined;
|
1160
|
+
|
1161
|
+
/**
|
1162
|
+
* Get test timeout.
|
1163
|
+
*
|
1164
|
+
* @see https://mochajs.org/api/Runnable.html#timeout
|
1165
|
+
*/
|
1166
|
+
timeout(): number;
|
1167
|
+
|
1168
|
+
/**
|
1169
|
+
* Set test timeout.
|
1170
|
+
*
|
1171
|
+
* @see https://mochajs.org/api/Runnable.html#timeout
|
1172
|
+
*/
|
1173
|
+
timeout(ms: string | number): this;
|
1174
|
+
|
1175
|
+
/**
|
1176
|
+
* Get test slowness threshold.
|
1177
|
+
*
|
1178
|
+
* @see https://mochajs.org/api/Runnable.html#slow
|
1179
|
+
*/
|
1180
|
+
slow(): number;
|
1181
|
+
|
1182
|
+
/**
|
1183
|
+
* Set test slowness threshold.
|
1184
|
+
*
|
1185
|
+
* @see https://mochajs.org/api/Runnable.html#slow
|
1186
|
+
*/
|
1187
|
+
slow(ms: string | number): this;
|
1188
|
+
|
1189
|
+
/**
|
1190
|
+
* Halt and mark as pending.
|
1191
|
+
*/
|
1192
|
+
skip(): never;
|
1193
|
+
|
1194
|
+
/**
|
1195
|
+
* Check if this runnable or its parent suite is marked as pending.
|
1196
|
+
*
|
1197
|
+
* @see https://mochajs.org/api/Runnable.html#isPending
|
1198
|
+
*/
|
1199
|
+
isPending(): boolean;
|
1200
|
+
|
1201
|
+
/**
|
1202
|
+
* Return `true` if this Runnable has failed.
|
1203
|
+
*/
|
1204
|
+
isFailed(): boolean;
|
1205
|
+
|
1206
|
+
/**
|
1207
|
+
* Return `true` if this Runnable has passed.
|
1208
|
+
*/
|
1209
|
+
isPassed(): boolean;
|
1210
|
+
|
1211
|
+
/**
|
1212
|
+
* Set or get number of retries.
|
1213
|
+
*
|
1214
|
+
* @see https://mochajs.org/api/Runnable.html#retries
|
1215
|
+
*/
|
1216
|
+
retries(): number;
|
1217
|
+
|
1218
|
+
/**
|
1219
|
+
* Set or get number of retries.
|
1220
|
+
*
|
1221
|
+
* @see https://mochajs.org/api/Runnable.html#retries
|
1222
|
+
*/
|
1223
|
+
retries(n: number): void;
|
1224
|
+
|
1225
|
+
/**
|
1226
|
+
* Set or get current retry
|
1227
|
+
*
|
1228
|
+
* @see https://mochajs.org/api/Runnable.html#currentRetry
|
1229
|
+
*/
|
1230
|
+
protected currentRetry(): number;
|
1231
|
+
|
1232
|
+
/**
|
1233
|
+
* Set or get current retry
|
1234
|
+
*
|
1235
|
+
* @see https://mochajs.org/api/Runnable.html#currentRetry
|
1236
|
+
*/
|
1237
|
+
protected currentRetry(n: number): void;
|
1238
|
+
|
1239
|
+
/**
|
1240
|
+
* Return the full title generated by recursively concatenating the parent's full title.
|
1241
|
+
*/
|
1242
|
+
fullTitle(): string;
|
1243
|
+
|
1244
|
+
/**
|
1245
|
+
* Return the title path generated by concatenating the parent's title path with the title.
|
1246
|
+
*/
|
1247
|
+
titlePath(): string[];
|
1248
|
+
|
1249
|
+
/**
|
1250
|
+
* Clear the timeout.
|
1251
|
+
*
|
1252
|
+
* @see https://mochajs.org/api/Runnable.html#clearTimeout
|
1253
|
+
*/
|
1254
|
+
clearTimeout(): void;
|
1255
|
+
|
1256
|
+
/**
|
1257
|
+
* Inspect the runnable void of private properties.
|
1258
|
+
*
|
1259
|
+
* @see https://mochajs.org/api/Runnable.html#inspect
|
1260
|
+
*/
|
1261
|
+
inspect(): string;
|
1262
|
+
|
1263
|
+
/**
|
1264
|
+
* Reset the timeout.
|
1265
|
+
*
|
1266
|
+
* @see https://mochajs.org/api/Runnable.html#resetTimeout
|
1267
|
+
*/
|
1268
|
+
resetTimeout(): void;
|
1269
|
+
|
1270
|
+
/**
|
1271
|
+
* Get a list of whitelisted globals for this test run.
|
1272
|
+
*
|
1273
|
+
* @see https://mochajs.org/api/Runnable.html#globals
|
1274
|
+
*/
|
1275
|
+
globals(): string[];
|
1276
|
+
|
1277
|
+
/**
|
1278
|
+
* Set a list of whitelisted globals for this test run.
|
1279
|
+
*
|
1280
|
+
* @see https://mochajs.org/api/Runnable.html#globals
|
1281
|
+
*/
|
1282
|
+
globals(globals: readonly string[]): void;
|
1283
|
+
|
1284
|
+
/**
|
1285
|
+
* Run the test and invoke `fn(err)`.
|
1286
|
+
*
|
1287
|
+
* @see https://mochajs.org/api/Runnable.html#run
|
1288
|
+
*/
|
1289
|
+
run(fn: Done): void;
|
1290
|
+
}
|
1291
|
+
|
1292
|
+
// #region Runnable "error" event
|
1293
|
+
interface Runnable extends NodeJS.EventEmitter {
|
1294
|
+
on(event: "error", listener: (error: any) => void): this;
|
1295
|
+
once(event: "error", listener: (error: any) => void): this;
|
1296
|
+
addListener(event: "error", listener: (error: any) => void): this;
|
1297
|
+
removeListener(event: "error", listener: (error: any) => void): this;
|
1298
|
+
prependListener(event: "error", listener: (error: any) => void): this;
|
1299
|
+
prependOnceListener(event: "error", listener: (error: any) => void): this;
|
1300
|
+
emit(name: "error", error: any): boolean;
|
1301
|
+
}
|
1302
|
+
// #endregion Runnable "error" event
|
1303
|
+
// #region Runnable untyped events
|
1304
|
+
interface Runnable extends NodeJS.EventEmitter {
|
1305
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
1306
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
1307
|
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
1308
|
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
1309
|
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
1310
|
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
1311
|
+
emit(name: string, ...args: any[]): boolean;
|
1312
|
+
}
|
1313
|
+
// #endregion Runnable untyped events
|
1314
|
+
|
1315
|
+
/**
|
1316
|
+
* Test context
|
1317
|
+
*
|
1318
|
+
* @see https://mochajs.org/api/module-Context.html#~Context
|
1319
|
+
*/
|
1320
|
+
class Context {
|
1321
|
+
private _runnable;
|
1322
|
+
|
1323
|
+
test?: Runnable | undefined;
|
1324
|
+
currentTest?: Test | undefined;
|
1325
|
+
|
1326
|
+
/**
|
1327
|
+
* Get the context `Runnable`.
|
1328
|
+
*/
|
1329
|
+
runnable(): Runnable;
|
1330
|
+
|
1331
|
+
/**
|
1332
|
+
* Set the context `Runnable`.
|
1333
|
+
*/
|
1334
|
+
runnable(runnable: Runnable): this;
|
1335
|
+
|
1336
|
+
/**
|
1337
|
+
* Get test timeout.
|
1338
|
+
*/
|
1339
|
+
timeout(): number;
|
1340
|
+
|
1341
|
+
/**
|
1342
|
+
* Set test timeout.
|
1343
|
+
*/
|
1344
|
+
timeout(ms: string | number): this;
|
1345
|
+
|
1346
|
+
/**
|
1347
|
+
* Get test slowness threshold.
|
1348
|
+
*/
|
1349
|
+
slow(): number;
|
1350
|
+
|
1351
|
+
/**
|
1352
|
+
* Set test slowness threshold.
|
1353
|
+
*/
|
1354
|
+
slow(ms: string | number): this;
|
1355
|
+
|
1356
|
+
/**
|
1357
|
+
* Mark a test as skipped.
|
1358
|
+
*/
|
1359
|
+
skip(): never;
|
1360
|
+
|
1361
|
+
/**
|
1362
|
+
* Get the number of allowed retries on failed tests.
|
1363
|
+
*/
|
1364
|
+
retries(): number;
|
1365
|
+
|
1366
|
+
/**
|
1367
|
+
* Set the number of allowed retries on failed tests.
|
1368
|
+
*/
|
1369
|
+
retries(n: number): this;
|
1370
|
+
|
1371
|
+
[key: string]: any;
|
1372
|
+
}
|
1373
|
+
|
1374
|
+
interface RunnerConstants {
|
1375
|
+
readonly EVENT_HOOK_BEGIN: "hook";
|
1376
|
+
readonly EVENT_HOOK_END: "hook end";
|
1377
|
+
readonly EVENT_RUN_BEGIN: "start";
|
1378
|
+
readonly EVENT_DELAY_BEGIN: "waiting";
|
1379
|
+
readonly EVENT_DELAY_END: "ready";
|
1380
|
+
readonly EVENT_RUN_END: "end";
|
1381
|
+
readonly EVENT_SUITE_BEGIN: "suite";
|
1382
|
+
readonly EVENT_SUITE_END: "suite end";
|
1383
|
+
readonly EVENT_TEST_BEGIN: "test";
|
1384
|
+
readonly EVENT_TEST_END: "test end";
|
1385
|
+
readonly EVENT_TEST_FAIL: "fail";
|
1386
|
+
readonly EVENT_TEST_PASS: "pass";
|
1387
|
+
readonly EVENT_TEST_PENDING: "pending";
|
1388
|
+
readonly EVENT_TEST_RETRY: "retry";
|
1389
|
+
readonly STATE_IDLE: "idle";
|
1390
|
+
readonly STATE_RUNNING: "running";
|
1391
|
+
readonly STATE_STOPPED: "stopped";
|
1392
|
+
}
|
1393
|
+
|
1394
|
+
interface RunnerOptions {
|
1395
|
+
/** Whether to delay execution of root suite until ready. */
|
1396
|
+
delay?: boolean;
|
1397
|
+
|
1398
|
+
/** Whether to report tests without running them. */
|
1399
|
+
dryRun?: boolean;
|
1400
|
+
|
1401
|
+
/** Whether to clean references to test fns and hooks when a suite is done. */
|
1402
|
+
cleanReferencesAfterRun?: boolean;
|
1403
|
+
}
|
1404
|
+
|
1405
|
+
/**
|
1406
|
+
* Initialize a `Runner` for the given `suite`.
|
1407
|
+
*
|
1408
|
+
* @see https://mochajs.org/api/Mocha.Runner.html
|
1409
|
+
*/
|
1410
|
+
class Runner {
|
1411
|
+
private _globals;
|
1412
|
+
private _abort;
|
1413
|
+
private _delay;
|
1414
|
+
private _defaultGrep;
|
1415
|
+
private next;
|
1416
|
+
private hookErr;
|
1417
|
+
private prevGlobalsLength;
|
1418
|
+
private nextSuite;
|
1419
|
+
|
1420
|
+
static readonly constants: RunnerConstants;
|
1421
|
+
|
1422
|
+
/**
|
1423
|
+
* Initialize a `Runner` at the Root Suite, which represents a hierarchy of Suites and Tests.
|
1424
|
+
*
|
1425
|
+
* @param suite Root suite
|
1426
|
+
* @param optionsOrDelay Options. If boolean (deprecated), whether or not to delay execution of root suite until ready.
|
1427
|
+
*/
|
1428
|
+
constructor(suite: Suite, optionsOrDelay?: RunnerOptions | boolean);
|
1429
|
+
|
1430
|
+
suite: Suite;
|
1431
|
+
started: boolean;
|
1432
|
+
total: number;
|
1433
|
+
failures: number;
|
1434
|
+
asyncOnly?: boolean | undefined;
|
1435
|
+
allowUncaught?: boolean | undefined;
|
1436
|
+
fullStackTrace?: boolean | undefined;
|
1437
|
+
forbidOnly?: boolean | undefined;
|
1438
|
+
forbidPending?: boolean | undefined;
|
1439
|
+
checkLeaks?: boolean | undefined;
|
1440
|
+
test?: Test | undefined;
|
1441
|
+
currentRunnable?: Runnable | undefined;
|
1442
|
+
stats?: Stats | undefined; // added by reporters
|
1443
|
+
|
1444
|
+
/**
|
1445
|
+
* Removes all event handlers set during a run on this instance.
|
1446
|
+
* Remark: this does *not* clean/dispose the tests or suites themselves.
|
1447
|
+
*
|
1448
|
+
* @see https://mochajs.org/api/runner#dispose
|
1449
|
+
*/
|
1450
|
+
dispose(): void;
|
1451
|
+
|
1452
|
+
/**
|
1453
|
+
* Run tests with full titles matching `re`. Updates runner.total
|
1454
|
+
* with number of tests matched.
|
1455
|
+
*
|
1456
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep
|
1457
|
+
*/
|
1458
|
+
grep(re: RegExp, invert: boolean): this;
|
1459
|
+
|
1460
|
+
/**
|
1461
|
+
* Returns the number of tests matching the grep search for the
|
1462
|
+
* given suite.
|
1463
|
+
*
|
1464
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal
|
1465
|
+
*/
|
1466
|
+
grepTotal(suite: Suite): number;
|
1467
|
+
|
1468
|
+
/**
|
1469
|
+
* Gets the allowed globals.
|
1470
|
+
*
|
1471
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals
|
1472
|
+
*/
|
1473
|
+
globals(): string[];
|
1474
|
+
|
1475
|
+
/**
|
1476
|
+
* Allow the given `arr` of globals.
|
1477
|
+
*
|
1478
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals
|
1479
|
+
*/
|
1480
|
+
globals(arr: readonly string[]): this;
|
1481
|
+
|
1482
|
+
/**
|
1483
|
+
* Run the root suite and invoke `fn(failures)` on completion.
|
1484
|
+
*
|
1485
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run
|
1486
|
+
*/
|
1487
|
+
run(fn?: (failures: number) => void): this;
|
1488
|
+
|
1489
|
+
/**
|
1490
|
+
* Cleanly abort execution.
|
1491
|
+
*
|
1492
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort
|
1493
|
+
*/
|
1494
|
+
abort(): this;
|
1495
|
+
|
1496
|
+
/**
|
1497
|
+
* Handle uncaught exceptions.
|
1498
|
+
*
|
1499
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#uncaught
|
1500
|
+
*/
|
1501
|
+
uncaught(err: any): void;
|
1502
|
+
|
1503
|
+
/**
|
1504
|
+
* Wrapper for setImmediate, process.nextTick, or browser polyfill.
|
1505
|
+
*/
|
1506
|
+
protected static immediately(callback: Function): void;
|
1507
|
+
|
1508
|
+
/**
|
1509
|
+
* Return a list of global properties.
|
1510
|
+
*
|
1511
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#globalProps
|
1512
|
+
*/
|
1513
|
+
protected globalProps(): string[];
|
1514
|
+
|
1515
|
+
/**
|
1516
|
+
* Check for global variable leaks.
|
1517
|
+
*
|
1518
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals
|
1519
|
+
*/
|
1520
|
+
protected checkGlobals(test: Test): void;
|
1521
|
+
|
1522
|
+
/**
|
1523
|
+
* Fail the given `test`.
|
1524
|
+
*
|
1525
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#fail
|
1526
|
+
*/
|
1527
|
+
protected fail(test: Test, err: any): void;
|
1528
|
+
|
1529
|
+
/**
|
1530
|
+
* Fail the given `hook` with `err`.
|
1531
|
+
*
|
1532
|
+
* Hook failures work in the following pattern:
|
1533
|
+
* - If bail, then exit
|
1534
|
+
* - Failed `before` hook skips all tests in a suite and subsuites,
|
1535
|
+
* but jumps to corresponding `after` hook
|
1536
|
+
* - Failed `before each` hook skips remaining tests in a
|
1537
|
+
* suite and jumps to corresponding `after each` hook,
|
1538
|
+
* which is run only once
|
1539
|
+
* - Failed `after` hook does not alter
|
1540
|
+
* execution order
|
1541
|
+
* - Failed `after each` hook skips remaining tests in a
|
1542
|
+
* suite and subsuites, but executes other `after each`
|
1543
|
+
* hooks
|
1544
|
+
*
|
1545
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#failHook
|
1546
|
+
*/
|
1547
|
+
protected failHook(hook: Hook, err: any): void;
|
1548
|
+
|
1549
|
+
/**
|
1550
|
+
* Run hook `name` callbacks and then invoke `fn()`.
|
1551
|
+
*
|
1552
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#hook
|
1553
|
+
*/
|
1554
|
+
protected hook(name: string, fn: () => void): void;
|
1555
|
+
|
1556
|
+
/**
|
1557
|
+
* Run hook `name` for the given array of `suites`
|
1558
|
+
* in order, and callback `fn(err, errSuite)`.
|
1559
|
+
*
|
1560
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#hooks
|
1561
|
+
*/
|
1562
|
+
protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void;
|
1563
|
+
|
1564
|
+
/**
|
1565
|
+
* Run hooks from the top level down.
|
1566
|
+
*
|
1567
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#hookUp
|
1568
|
+
*/
|
1569
|
+
protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void;
|
1570
|
+
|
1571
|
+
/**
|
1572
|
+
* Run hooks from the bottom up.
|
1573
|
+
*
|
1574
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#hookDown
|
1575
|
+
*/
|
1576
|
+
protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void;
|
1577
|
+
|
1578
|
+
/**
|
1579
|
+
* Return an array of parent Suites from closest to furthest.
|
1580
|
+
*
|
1581
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#parents
|
1582
|
+
*/
|
1583
|
+
protected parents(): Suite[];
|
1584
|
+
|
1585
|
+
/**
|
1586
|
+
* Run the current test and callback `fn(err)`.
|
1587
|
+
*
|
1588
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#runTest
|
1589
|
+
*/
|
1590
|
+
protected runTest(fn: Done): any;
|
1591
|
+
|
1592
|
+
/**
|
1593
|
+
* Run tests in the given `suite` and invoke the callback `fn()` when complete.
|
1594
|
+
*
|
1595
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#runTests
|
1596
|
+
*/
|
1597
|
+
protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void;
|
1598
|
+
|
1599
|
+
/**
|
1600
|
+
* Run the given `suite` and invoke the callback `fn()` when complete.
|
1601
|
+
*
|
1602
|
+
* @see https://mochajs.org/api/Mocha.Runner.html#runSuite
|
1603
|
+
*/
|
1604
|
+
protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void;
|
1605
|
+
}
|
1606
|
+
|
1607
|
+
// #region Runner "waiting" event
|
1608
|
+
interface Runner {
|
1609
|
+
on(event: "waiting", listener: (rootSuite: Suite) => void): this;
|
1610
|
+
once(event: "waiting", listener: (rootSuite: Suite) => void): this;
|
1611
|
+
addListener(event: "waiting", listener: (rootSuite: Suite) => void): this;
|
1612
|
+
removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this;
|
1613
|
+
prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this;
|
1614
|
+
prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this;
|
1615
|
+
emit(name: "waiting", rootSuite: Suite): boolean;
|
1616
|
+
}
|
1617
|
+
// #endregion Runner "waiting" event
|
1618
|
+
// #region Runner "start" event
|
1619
|
+
interface Runner extends NodeJS.EventEmitter {
|
1620
|
+
on(event: "start", listener: () => void): this;
|
1621
|
+
once(event: "start", listener: () => void): this;
|
1622
|
+
addListener(event: "start", listener: () => void): this;
|
1623
|
+
removeListener(event: "start", listener: () => void): this;
|
1624
|
+
prependListener(event: "start", listener: () => void): this;
|
1625
|
+
prependOnceListener(event: "start", listener: () => void): this;
|
1626
|
+
emit(name: "start"): boolean;
|
1627
|
+
}
|
1628
|
+
// #endregion Runner "start" event
|
1629
|
+
// #region Runner "end" event
|
1630
|
+
interface Runner extends NodeJS.EventEmitter {
|
1631
|
+
on(event: "end", listener: () => void): this;
|
1632
|
+
once(event: "end", listener: () => void): this;
|
1633
|
+
addListener(event: "end", listener: () => void): this;
|
1634
|
+
removeListener(event: "end", listener: () => void): this;
|
1635
|
+
prependListener(event: "end", listener: () => void): this;
|
1636
|
+
prependOnceListener(event: "end", listener: () => void): this;
|
1637
|
+
emit(name: "end"): boolean;
|
1638
|
+
}
|
1639
|
+
// #endregion Runner "end" event
|
1640
|
+
// #region Runner "suite" event
|
1641
|
+
interface Runner extends NodeJS.EventEmitter {
|
1642
|
+
on(event: "suite", listener: (suite: Suite) => void): this;
|
1643
|
+
once(event: "suite", listener: (suite: Suite) => void): this;
|
1644
|
+
addListener(event: "suite", listener: (suite: Suite) => void): this;
|
1645
|
+
removeListener(event: "suite", listener: (suite: Suite) => void): this;
|
1646
|
+
prependListener(event: "suite", listener: (suite: Suite) => void): this;
|
1647
|
+
prependOnceListener(event: "suite", listener: (suite: Suite) => void): this;
|
1648
|
+
emit(name: "suite", suite: Suite): boolean;
|
1649
|
+
}
|
1650
|
+
// #endregion Runner "suite" event
|
1651
|
+
// #region Runner "suite end" event
|
1652
|
+
interface Runner extends NodeJS.EventEmitter {
|
1653
|
+
on(event: "suite end", listener: (suite: Suite) => void): this;
|
1654
|
+
once(event: "suite end", listener: (suite: Suite) => void): this;
|
1655
|
+
addListener(event: "suite end", listener: (suite: Suite) => void): this;
|
1656
|
+
removeListener(event: "suite end", listener: (suite: Suite) => void): this;
|
1657
|
+
prependListener(event: "suite end", listener: (suite: Suite) => void): this;
|
1658
|
+
prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this;
|
1659
|
+
emit(name: "suite end", suite: Suite): boolean;
|
1660
|
+
}
|
1661
|
+
// #endregion Runner "suite end" event
|
1662
|
+
// #region Runner "test" event
|
1663
|
+
interface Runner extends NodeJS.EventEmitter {
|
1664
|
+
on(event: "test", listener: (test: Test) => void): this;
|
1665
|
+
once(event: "test", listener: (test: Test) => void): this;
|
1666
|
+
addListener(event: "test", listener: (test: Test) => void): this;
|
1667
|
+
removeListener(event: "test", listener: (test: Test) => void): this;
|
1668
|
+
prependListener(event: "test", listener: (test: Test) => void): this;
|
1669
|
+
prependOnceListener(event: "test", listener: (test: Test) => void): this;
|
1670
|
+
emit(name: "test", test: Test): boolean;
|
1671
|
+
}
|
1672
|
+
// #endregion Runner "test" event
|
1673
|
+
// #region Runner "test end" event
|
1674
|
+
interface Runner extends NodeJS.EventEmitter {
|
1675
|
+
on(event: "test end", listener: (test: Test) => void): this;
|
1676
|
+
once(event: "test end", listener: (test: Test) => void): this;
|
1677
|
+
addListener(event: "test end", listener: (test: Test) => void): this;
|
1678
|
+
removeListener(event: "test end", listener: (test: Test) => void): this;
|
1679
|
+
prependListener(event: "test end", listener: (test: Test) => void): this;
|
1680
|
+
prependOnceListener(event: "test end", listener: (test: Test) => void): this;
|
1681
|
+
emit(name: "test end", test: Test): boolean;
|
1682
|
+
}
|
1683
|
+
// #endregion Runner "test end" event
|
1684
|
+
// #region Runner "hook" event
|
1685
|
+
interface Runner extends NodeJS.EventEmitter {
|
1686
|
+
on(event: "hook", listener: (hook: Hook) => void): this;
|
1687
|
+
once(event: "hook", listener: (hook: Hook) => void): this;
|
1688
|
+
addListener(event: "hook", listener: (hook: Hook) => void): this;
|
1689
|
+
removeListener(event: "hook", listener: (hook: Hook) => void): this;
|
1690
|
+
prependListener(event: "hook", listener: (hook: Hook) => void): this;
|
1691
|
+
prependOnceListener(event: "hook", listener: (hook: Hook) => void): this;
|
1692
|
+
emit(name: "hook", hook: Hook): boolean;
|
1693
|
+
}
|
1694
|
+
// #endregion Runner "hook" event
|
1695
|
+
// #region Runner "hook end" event
|
1696
|
+
interface Runner extends NodeJS.EventEmitter {
|
1697
|
+
on(event: "hook end", listener: (hook: Hook) => void): this;
|
1698
|
+
once(event: "hook end", listener: (hook: Hook) => void): this;
|
1699
|
+
addListener(event: "hook end", listener: (hook: Hook) => void): this;
|
1700
|
+
removeListener(event: "hook end", listener: (hook: Hook) => void): this;
|
1701
|
+
prependListener(event: "hook end", listener: (hook: Hook) => void): this;
|
1702
|
+
prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this;
|
1703
|
+
emit(name: "hook end", hook: Hook): boolean;
|
1704
|
+
}
|
1705
|
+
// #endregion Runner "hook end" event
|
1706
|
+
// #region Runner "pass" event
|
1707
|
+
interface Runner extends NodeJS.EventEmitter {
|
1708
|
+
on(event: "pass", listener: (test: Test) => void): this;
|
1709
|
+
once(event: "pass", listener: (test: Test) => void): this;
|
1710
|
+
addListener(event: "pass", listener: (test: Test) => void): this;
|
1711
|
+
removeListener(event: "pass", listener: (test: Test) => void): this;
|
1712
|
+
prependListener(event: "pass", listener: (test: Test) => void): this;
|
1713
|
+
prependOnceListener(event: "pass", listener: (test: Test) => void): this;
|
1714
|
+
emit(name: "pass", test: Test): boolean;
|
1715
|
+
}
|
1716
|
+
// #endregion Runner "pass" event
|
1717
|
+
// #region Runner "fail" event
|
1718
|
+
interface Runner extends NodeJS.EventEmitter {
|
1719
|
+
on(event: "fail", listener: (test: Test, err: any) => void): this;
|
1720
|
+
once(event: "fail", listener: (test: Test, err: any) => void): this;
|
1721
|
+
addListener(event: "fail", listener: (test: Test, err: any) => void): this;
|
1722
|
+
removeListener(event: "fail", listener: (test: Test, err: any) => void): this;
|
1723
|
+
prependListener(event: "fail", listener: (test: Test, err: any) => void): this;
|
1724
|
+
prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this;
|
1725
|
+
emit(name: "fail", test: Test, err: any): boolean;
|
1726
|
+
}
|
1727
|
+
// #endregion Runner "fail" event
|
1728
|
+
// #region Runner "pending" event
|
1729
|
+
interface Runner extends NodeJS.EventEmitter {
|
1730
|
+
on(event: "pending", listener: (test: Test) => void): this;
|
1731
|
+
once(event: "pending", listener: (test: Test) => void): this;
|
1732
|
+
addListener(event: "pending", listener: (test: Test) => void): this;
|
1733
|
+
removeListener(event: "pending", listener: (test: Test) => void): this;
|
1734
|
+
prependListener(event: "pending", listener: (test: Test) => void): this;
|
1735
|
+
prependOnceListener(event: "pending", listener: (test: Test) => void): this;
|
1736
|
+
emit(name: "pending", test: Test): boolean;
|
1737
|
+
}
|
1738
|
+
// #endregion Runner "pending" event
|
1739
|
+
// #region Runner untyped events
|
1740
|
+
interface Runner extends NodeJS.EventEmitter {
|
1741
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
1742
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
1743
|
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
1744
|
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
1745
|
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
1746
|
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
1747
|
+
emit(name: string, ...args: any[]): boolean;
|
1748
|
+
}
|
1749
|
+
// #endregion Runner untyped events
|
1750
|
+
|
1751
|
+
interface SuiteConstants {
|
1752
|
+
readonly EVENT_FILE_POST_REQUIRE: "post-require";
|
1753
|
+
readonly EVENT_FILE_PRE_REQUIRE: "pre-require";
|
1754
|
+
readonly EVENT_FILE_REQUIRE: "require";
|
1755
|
+
readonly EVENT_ROOT_SUITE_RUN: "run";
|
1756
|
+
|
1757
|
+
readonly HOOK_TYPE_AFTER_ALL: "afterAll";
|
1758
|
+
readonly HOOK_TYPE_AFTER_EACH: "afterEach";
|
1759
|
+
readonly HOOK_TYPE_BEFORE_ALL: "beforeAll";
|
1760
|
+
readonly HOOK_TYPE_BEFORE_EACH: "beforeEach";
|
1761
|
+
|
1762
|
+
readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: "afterAll";
|
1763
|
+
readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: "afterEach";
|
1764
|
+
readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: "beforeAll";
|
1765
|
+
readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: "beforeEach";
|
1766
|
+
readonly EVENT_SUITE_ADD_SUITE: "suite";
|
1767
|
+
readonly EVENT_SUITE_ADD_TEST: "test";
|
1768
|
+
}
|
1769
|
+
|
1770
|
+
/**
|
1771
|
+
* Initialize a new `Suite` with the given `title` and `ctx`.
|
1772
|
+
*
|
1773
|
+
* @see https://mochajs.org/api/Mocha.Suite.html
|
1774
|
+
*/
|
1775
|
+
class Suite {
|
1776
|
+
private _beforeEach;
|
1777
|
+
private _beforeAll;
|
1778
|
+
private _afterEach;
|
1779
|
+
private _afterAll;
|
1780
|
+
private _timeout;
|
1781
|
+
private _slow;
|
1782
|
+
private _bail;
|
1783
|
+
private _retries;
|
1784
|
+
private _onlyTests;
|
1785
|
+
private _onlySuites;
|
1786
|
+
|
1787
|
+
static readonly constants: SuiteConstants;
|
1788
|
+
|
1789
|
+
constructor(title: string, parentContext?: Context);
|
1790
|
+
|
1791
|
+
ctx: Context;
|
1792
|
+
suites: Suite[];
|
1793
|
+
tests: Test[];
|
1794
|
+
pending: boolean;
|
1795
|
+
file?: string | undefined;
|
1796
|
+
root: boolean;
|
1797
|
+
delayed: boolean;
|
1798
|
+
parent: Suite | undefined;
|
1799
|
+
title: string;
|
1800
|
+
|
1801
|
+
/**
|
1802
|
+
* Create a new `Suite` with the given `title` and parent `Suite`. When a suite
|
1803
|
+
* with the same title is already present, that suite is returned to provide
|
1804
|
+
* nicer reporter and more flexible meta-testing.
|
1805
|
+
*
|
1806
|
+
* @see https://mochajs.org/api/mocha#.exports.create
|
1807
|
+
*/
|
1808
|
+
static create(parent: Suite, title: string): Suite;
|
1809
|
+
|
1810
|
+
/**
|
1811
|
+
* Return a clone of this `Suite`.
|
1812
|
+
*
|
1813
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#clone
|
1814
|
+
*/
|
1815
|
+
clone(): Suite;
|
1816
|
+
|
1817
|
+
/**
|
1818
|
+
* Get timeout `ms`.
|
1819
|
+
*
|
1820
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#timeout
|
1821
|
+
*/
|
1822
|
+
timeout(): number;
|
1823
|
+
|
1824
|
+
/**
|
1825
|
+
* Set timeout `ms` or short-hand such as "2s".
|
1826
|
+
*
|
1827
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#timeout
|
1828
|
+
*/
|
1829
|
+
timeout(ms: string | number): this;
|
1830
|
+
|
1831
|
+
/**
|
1832
|
+
* Get number of times to retry a failed test.
|
1833
|
+
*
|
1834
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#retries
|
1835
|
+
*/
|
1836
|
+
retries(): number;
|
1837
|
+
|
1838
|
+
/**
|
1839
|
+
* Set number of times to retry a failed test.
|
1840
|
+
*
|
1841
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#retries
|
1842
|
+
*/
|
1843
|
+
retries(n: string | number): this;
|
1844
|
+
|
1845
|
+
/**
|
1846
|
+
* Get slow `ms`.
|
1847
|
+
*
|
1848
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#slow
|
1849
|
+
*/
|
1850
|
+
slow(): number;
|
1851
|
+
|
1852
|
+
/**
|
1853
|
+
* Set slow `ms` or short-hand such as "2s".
|
1854
|
+
*
|
1855
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#slow
|
1856
|
+
*/
|
1857
|
+
slow(ms: string | number): this;
|
1858
|
+
|
1859
|
+
/**
|
1860
|
+
* Get whether to bail after first error.
|
1861
|
+
*
|
1862
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#bail
|
1863
|
+
*/
|
1864
|
+
bail(): boolean;
|
1865
|
+
|
1866
|
+
/**
|
1867
|
+
* Set whether to bail after first error.
|
1868
|
+
*
|
1869
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#bail
|
1870
|
+
*/
|
1871
|
+
bail(bail: boolean): this;
|
1872
|
+
|
1873
|
+
/**
|
1874
|
+
* Check if this suite or its parent suite is marked as pending.
|
1875
|
+
*
|
1876
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#isPending
|
1877
|
+
*/
|
1878
|
+
isPending(): boolean;
|
1879
|
+
|
1880
|
+
/**
|
1881
|
+
* Run `fn(test[, done])` before running tests.
|
1882
|
+
*
|
1883
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
|
1884
|
+
*/
|
1885
|
+
beforeAll(fn?: Func): this;
|
1886
|
+
|
1887
|
+
/**
|
1888
|
+
* Run `fn(test[, done])` before running tests.
|
1889
|
+
*
|
1890
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
|
1891
|
+
*/
|
1892
|
+
beforeAll(fn?: AsyncFunc): this;
|
1893
|
+
|
1894
|
+
/**
|
1895
|
+
* Run `fn(test[, done])` before running tests.
|
1896
|
+
*
|
1897
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
|
1898
|
+
*/
|
1899
|
+
beforeAll(title: string, fn?: Func): this;
|
1900
|
+
|
1901
|
+
/**
|
1902
|
+
* Run `fn(test[, done])` before running tests.
|
1903
|
+
*
|
1904
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
|
1905
|
+
*/
|
1906
|
+
beforeAll(title: string, fn?: AsyncFunc): this;
|
1907
|
+
|
1908
|
+
/**
|
1909
|
+
* Run `fn(test[, done])` after running tests.
|
1910
|
+
*
|
1911
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#afterAll
|
1912
|
+
*/
|
1913
|
+
afterAll(fn?: Func): this;
|
1914
|
+
|
1915
|
+
/**
|
1916
|
+
* Run `fn(test[, done])` after running tests.
|
1917
|
+
*
|
1918
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#afterAll
|
1919
|
+
*/
|
1920
|
+
afterAll(fn?: AsyncFunc): this;
|
1921
|
+
|
1922
|
+
/**
|
1923
|
+
* Run `fn(test[, done])` after running tests.
|
1924
|
+
*
|
1925
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#afterAll
|
1926
|
+
*/
|
1927
|
+
afterAll(title: string, fn?: Func): this;
|
1928
|
+
|
1929
|
+
/**
|
1930
|
+
* Run `fn(test[, done])` after running tests.
|
1931
|
+
*
|
1932
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#afterAll
|
1933
|
+
*/
|
1934
|
+
afterAll(title: string, fn?: AsyncFunc): this;
|
1935
|
+
|
1936
|
+
/**
|
1937
|
+
* Run `fn(test[, done])` before each test case.
|
1938
|
+
*
|
1939
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
|
1940
|
+
*/
|
1941
|
+
beforeEach(fn?: Func): this;
|
1942
|
+
|
1943
|
+
/**
|
1944
|
+
* Run `fn(test[, done])` before each test case.
|
1945
|
+
*
|
1946
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
|
1947
|
+
*/
|
1948
|
+
beforeEach(fn?: AsyncFunc): this;
|
1949
|
+
|
1950
|
+
/**
|
1951
|
+
* Run `fn(test[, done])` before each test case.
|
1952
|
+
*
|
1953
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
|
1954
|
+
*/
|
1955
|
+
beforeEach(title: string, fn?: Func): this;
|
1956
|
+
|
1957
|
+
/**
|
1958
|
+
* Run `fn(test[, done])` before each test case.
|
1959
|
+
*
|
1960
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
|
1961
|
+
*/
|
1962
|
+
beforeEach(title: string, fn?: AsyncFunc): this;
|
1963
|
+
|
1964
|
+
/**
|
1965
|
+
* Run `fn(test[, done])` after each test case.
|
1966
|
+
*
|
1967
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#afterEach
|
1968
|
+
*/
|
1969
|
+
afterEach(fn?: Func): this;
|
1970
|
+
|
1971
|
+
/**
|
1972
|
+
* Run `fn(test[, done])` after each test case.
|
1973
|
+
*
|
1974
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#afterEach
|
1975
|
+
*/
|
1976
|
+
afterEach(fn?: AsyncFunc): this;
|
1977
|
+
|
1978
|
+
/**
|
1979
|
+
* Run `fn(test[, done])` after each test case.
|
1980
|
+
*
|
1981
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#afterEach
|
1982
|
+
*/
|
1983
|
+
afterEach(title: string, fn?: Func): this;
|
1984
|
+
|
1985
|
+
/**
|
1986
|
+
* Run `fn(test[, done])` after each test case.
|
1987
|
+
*
|
1988
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#afterEach
|
1989
|
+
*/
|
1990
|
+
afterEach(title: string, fn?: AsyncFunc): this;
|
1991
|
+
|
1992
|
+
/**
|
1993
|
+
* Add a test `suite`.
|
1994
|
+
*
|
1995
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#addSuite
|
1996
|
+
*/
|
1997
|
+
addSuite(suite: Suite): this;
|
1998
|
+
|
1999
|
+
/**
|
2000
|
+
* Add a `test` to this suite.
|
2001
|
+
*
|
2002
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#addTest
|
2003
|
+
*/
|
2004
|
+
addTest(test: Test): this;
|
2005
|
+
|
2006
|
+
/**
|
2007
|
+
* Cleans all references from this suite and all child suites.
|
2008
|
+
*
|
2009
|
+
* https://mochajs.org/api/suite#dispose
|
2010
|
+
*/
|
2011
|
+
dispose(): void;
|
2012
|
+
|
2013
|
+
/**
|
2014
|
+
* Return the full title generated by recursively concatenating the parent's
|
2015
|
+
* full title.
|
2016
|
+
*
|
2017
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle
|
2018
|
+
*/
|
2019
|
+
fullTitle(): string;
|
2020
|
+
|
2021
|
+
/**
|
2022
|
+
* Return the title path generated by recursively concatenating the parent's
|
2023
|
+
* title path.
|
2024
|
+
*
|
2025
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath
|
2026
|
+
*/
|
2027
|
+
titlePath(): string[];
|
2028
|
+
|
2029
|
+
/**
|
2030
|
+
* Return the total number of tests.
|
2031
|
+
*
|
2032
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total
|
2033
|
+
*/
|
2034
|
+
total(): number;
|
2035
|
+
|
2036
|
+
/**
|
2037
|
+
* Iterates through each suite recursively to find all tests. Applies a
|
2038
|
+
* function in the format `fn(test)`.
|
2039
|
+
*
|
2040
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#eachTest
|
2041
|
+
*/
|
2042
|
+
eachTest(fn: (test: Test) => void): this;
|
2043
|
+
|
2044
|
+
/**
|
2045
|
+
* This will run the root suite if we happen to be running in delayed mode.
|
2046
|
+
*
|
2047
|
+
* @see https://mochajs.org/api/Mocha.Suite.html#run
|
2048
|
+
*/
|
2049
|
+
run(): void;
|
2050
|
+
|
2051
|
+
/**
|
2052
|
+
* Generic hook-creator.
|
2053
|
+
*/
|
2054
|
+
protected _createHook(title: string, fn?: Func | AsyncFunc): Hook;
|
2055
|
+
}
|
2056
|
+
|
2057
|
+
// #region Suite "beforeAll" event
|
2058
|
+
interface Suite extends NodeJS.EventEmitter {
|
2059
|
+
on(event: "beforeAll", listener: (hook: Hook) => void): this;
|
2060
|
+
once(event: "beforeAll", listener: (hook: Hook) => void): this;
|
2061
|
+
addListener(event: "beforeAll", listener: (hook: Hook) => void): this;
|
2062
|
+
removeListener(event: "beforeAll", listener: (hook: Hook) => void): this;
|
2063
|
+
prependListener(event: "beforeAll", listener: (hook: Hook) => void): this;
|
2064
|
+
prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this;
|
2065
|
+
emit(name: "beforeAll", hook: Hook): boolean;
|
2066
|
+
}
|
2067
|
+
// #endregion Suite "beforeAll" event
|
2068
|
+
// #region Suite "afterAll" event
|
2069
|
+
interface Suite extends NodeJS.EventEmitter {
|
2070
|
+
on(event: "afterAll", listener: (hook: Hook) => void): this;
|
2071
|
+
once(event: "afterAll", listener: (hook: Hook) => void): this;
|
2072
|
+
addListener(event: "afterAll", listener: (hook: Hook) => void): this;
|
2073
|
+
removeListener(event: "afterAll", listener: (hook: Hook) => void): this;
|
2074
|
+
prependListener(event: "afterAll", listener: (hook: Hook) => void): this;
|
2075
|
+
prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this;
|
2076
|
+
emit(name: "afterAll", hook: Hook): boolean;
|
2077
|
+
}
|
2078
|
+
// #endregion Suite "afterAll" event
|
2079
|
+
// #region Suite "beforeEach" event
|
2080
|
+
interface Suite extends NodeJS.EventEmitter {
|
2081
|
+
on(event: "beforeEach", listener: (hook: Hook) => void): this;
|
2082
|
+
once(event: "beforeEach", listener: (hook: Hook) => void): this;
|
2083
|
+
addListener(event: "beforeEach", listener: (hook: Hook) => void): this;
|
2084
|
+
removeListener(event: "beforeEach", listener: (hook: Hook) => void): this;
|
2085
|
+
prependListener(event: "beforeEach", listener: (hook: Hook) => void): this;
|
2086
|
+
prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this;
|
2087
|
+
emit(name: "beforeEach", hook: Hook): boolean;
|
2088
|
+
}
|
2089
|
+
// #endregion Suite "beforeEach" event
|
2090
|
+
// #region Suite "afterEach" event
|
2091
|
+
interface Suite extends NodeJS.EventEmitter {
|
2092
|
+
on(event: "afterEach", listener: (hook: Hook) => void): this;
|
2093
|
+
once(event: "afterEach", listener: (hook: Hook) => void): this;
|
2094
|
+
addListener(event: "afterEach", listener: (hook: Hook) => void): this;
|
2095
|
+
removeListener(event: "afterEach", listener: (hook: Hook) => void): this;
|
2096
|
+
prependListener(event: "afterEach", listener: (hook: Hook) => void): this;
|
2097
|
+
prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this;
|
2098
|
+
emit(name: "afterEach", hook: Hook): boolean;
|
2099
|
+
}
|
2100
|
+
// #endregion Suite "afterEach" event
|
2101
|
+
// #region Suite "suite" event
|
2102
|
+
interface Suite extends NodeJS.EventEmitter {
|
2103
|
+
on(event: "suite", listener: (suite: Suite) => void): this;
|
2104
|
+
once(event: "suite", listener: (suite: Suite) => void): this;
|
2105
|
+
addListener(event: "suite", listener: (suite: Suite) => void): this;
|
2106
|
+
removeListener(event: "suite", listener: (suite: Suite) => void): this;
|
2107
|
+
prependListener(event: "suite", listener: (suite: Suite) => void): this;
|
2108
|
+
prependOnceListener(event: "suite", listener: (suite: Suite) => void): this;
|
2109
|
+
emit(name: "suite", suite: Suite): boolean;
|
2110
|
+
}
|
2111
|
+
// #endregion Suite "suite" event
|
2112
|
+
// #region Suite "test" event
|
2113
|
+
interface Suite {
|
2114
|
+
on(event: "test", listener: (test: Test) => void): this;
|
2115
|
+
once(event: "test", listener: (test: Test) => void): this;
|
2116
|
+
addListener(event: "test", listener: (test: Test) => void): this;
|
2117
|
+
removeListener(event: "test", listener: (test: Test) => void): this;
|
2118
|
+
prependListener(event: "test", listener: (test: Test) => void): this;
|
2119
|
+
prependOnceListener(event: "test", listener: (test: Test) => void): this;
|
2120
|
+
emit(name: "test", test: Test): boolean;
|
2121
|
+
}
|
2122
|
+
// #endregion Suite "test" event
|
2123
|
+
// #region Suite "run" event
|
2124
|
+
interface Suite extends NodeJS.EventEmitter {
|
2125
|
+
on(event: "run", listener: () => void): this;
|
2126
|
+
once(event: "run", listener: () => void): this;
|
2127
|
+
addListener(event: "run", listener: () => void): this;
|
2128
|
+
removeListener(event: "run", listener: () => void): this;
|
2129
|
+
prependListener(event: "run", listener: () => void): this;
|
2130
|
+
prependOnceListener(event: "run", listener: () => void): this;
|
2131
|
+
emit(name: "run"): boolean;
|
2132
|
+
}
|
2133
|
+
// #endregion Suite "run" event
|
2134
|
+
// #region Suite "pre-require" event
|
2135
|
+
interface Suite extends NodeJS.EventEmitter {
|
2136
|
+
on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
|
2137
|
+
once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
|
2138
|
+
addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
|
2139
|
+
removeListener(
|
2140
|
+
event: "pre-require",
|
2141
|
+
listener: (context: MochaGlobals, file: string, mocha: Mocha) => void,
|
2142
|
+
): this;
|
2143
|
+
prependListener(
|
2144
|
+
event: "pre-require",
|
2145
|
+
listener: (context: MochaGlobals, file: string, mocha: Mocha) => void,
|
2146
|
+
): this;
|
2147
|
+
prependOnceListener(
|
2148
|
+
event: "pre-require",
|
2149
|
+
listener: (context: MochaGlobals, file: string, mocha: Mocha) => void,
|
2150
|
+
): this;
|
2151
|
+
emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean;
|
2152
|
+
}
|
2153
|
+
// #endregion Suite "pre-require" event
|
2154
|
+
// #region Suite "require" event
|
2155
|
+
interface Suite extends NodeJS.EventEmitter {
|
2156
|
+
on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
|
2157
|
+
once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
|
2158
|
+
addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
|
2159
|
+
removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
|
2160
|
+
prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
|
2161
|
+
prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
|
2162
|
+
emit(name: "require", module: any, file: string, mocha: Mocha): boolean;
|
2163
|
+
}
|
2164
|
+
// #endregion Suite "require" event
|
2165
|
+
// #region Suite "post-require" event
|
2166
|
+
interface Suite extends NodeJS.EventEmitter {
|
2167
|
+
on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
|
2168
|
+
once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
|
2169
|
+
addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
|
2170
|
+
removeListener(
|
2171
|
+
event: "post-require",
|
2172
|
+
listener: (context: MochaGlobals, file: string, mocha: Mocha) => void,
|
2173
|
+
): this;
|
2174
|
+
prependListener(
|
2175
|
+
event: "post-require",
|
2176
|
+
listener: (context: MochaGlobals, file: string, mocha: Mocha) => void,
|
2177
|
+
): this;
|
2178
|
+
prependOnceListener(
|
2179
|
+
event: "post-require",
|
2180
|
+
listener: (context: MochaGlobals, file: string, mocha: Mocha) => void,
|
2181
|
+
): this;
|
2182
|
+
emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean;
|
2183
|
+
}
|
2184
|
+
// #endregion Suite "post-require" event
|
2185
|
+
// #region Suite untyped events
|
2186
|
+
interface Suite extends NodeJS.EventEmitter {
|
2187
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
2188
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
2189
|
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
2190
|
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
2191
|
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
2192
|
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
2193
|
+
emit(name: string, ...args: any[]): boolean;
|
2194
|
+
}
|
2195
|
+
// #endregion Runner untyped events
|
2196
|
+
|
2197
|
+
/**
|
2198
|
+
* Initialize a new `Hook` with the given `title` and callback `fn`
|
2199
|
+
*
|
2200
|
+
* @see https://mochajs.org/api/Hook.html
|
2201
|
+
*/
|
2202
|
+
class Hook extends Runnable {
|
2203
|
+
private _error;
|
2204
|
+
|
2205
|
+
type: "hook";
|
2206
|
+
originalTitle?: string | undefined; // added by Runner
|
2207
|
+
|
2208
|
+
/**
|
2209
|
+
* Get the test `err`.
|
2210
|
+
*
|
2211
|
+
* @see https://mochajs.org/api/Hook.html#error
|
2212
|
+
*/
|
2213
|
+
error(): any;
|
2214
|
+
|
2215
|
+
/**
|
2216
|
+
* Set the test `err`.
|
2217
|
+
*
|
2218
|
+
* @see https://mochajs.org/api/Hook.html#error
|
2219
|
+
*/
|
2220
|
+
error(err: any): void;
|
2221
|
+
}
|
2222
|
+
|
2223
|
+
/**
|
2224
|
+
* An alternative way to define root hooks that works with parallel runs.
|
2225
|
+
*
|
2226
|
+
* Root hooks work with any interface, but the property names do not change.
|
2227
|
+
* In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach.
|
2228
|
+
*
|
2229
|
+
* As with other hooks, `this` refers to to the current context object.
|
2230
|
+
*
|
2231
|
+
* @see https://mochajs.org/#root-hook-plugins
|
2232
|
+
*/
|
2233
|
+
interface RootHookObject {
|
2234
|
+
/**
|
2235
|
+
* In serial mode, run after all tests end, once only.
|
2236
|
+
* In parallel mode, run after all tests end, for each file.
|
2237
|
+
*/
|
2238
|
+
afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[] | undefined;
|
2239
|
+
/**
|
2240
|
+
* In serial mode (Mocha's default), before all tests begin, once only.
|
2241
|
+
* In parallel mode, run before all tests begin, for each file.
|
2242
|
+
*/
|
2243
|
+
beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[] | undefined;
|
2244
|
+
/**
|
2245
|
+
* In both modes, run after every test.
|
2246
|
+
*/
|
2247
|
+
afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[] | undefined;
|
2248
|
+
/**
|
2249
|
+
* In both modes, run before each test.
|
2250
|
+
*/
|
2251
|
+
beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[] | undefined;
|
2252
|
+
}
|
2253
|
+
|
2254
|
+
/**
|
2255
|
+
* Initialize a new `Test` with the given `title` and callback `fn`.
|
2256
|
+
*
|
2257
|
+
* @see https://mochajs.org/api/Test.html
|
2258
|
+
*/
|
2259
|
+
class Test extends Runnable {
|
2260
|
+
type: "test";
|
2261
|
+
speed?: "slow" | "medium" | "fast" | undefined; // added by reporters
|
2262
|
+
err?: Error | undefined; // added by reporters
|
2263
|
+
clone(): Test;
|
2264
|
+
}
|
2265
|
+
|
2266
|
+
/**
|
2267
|
+
* Test statistics
|
2268
|
+
*/
|
2269
|
+
interface Stats {
|
2270
|
+
suites: number;
|
2271
|
+
tests: number;
|
2272
|
+
passes: number;
|
2273
|
+
pending: number;
|
2274
|
+
failures: number;
|
2275
|
+
start?: Date | undefined;
|
2276
|
+
end?: Date | undefined;
|
2277
|
+
duration?: number | undefined;
|
2278
|
+
}
|
2279
|
+
|
2280
|
+
type TestInterface = (suite: Suite) => void;
|
2281
|
+
|
2282
|
+
interface ReporterConstructor {
|
2283
|
+
new(runner: Runner, options: MochaOptions): reporters.Base;
|
2284
|
+
}
|
2285
|
+
|
2286
|
+
type Done = (err?: any) => void;
|
2287
|
+
|
2288
|
+
/**
|
2289
|
+
* Callback function used for tests and hooks.
|
2290
|
+
*/
|
2291
|
+
type Func = (this: Context, done: Done) => void;
|
2292
|
+
|
2293
|
+
/**
|
2294
|
+
* Async callback function used for tests and hooks.
|
2295
|
+
*/
|
2296
|
+
type AsyncFunc = (this: Context) => PromiseLike<any>;
|
2297
|
+
|
2298
|
+
/**
|
2299
|
+
* Options to pass to Mocha.
|
2300
|
+
*/
|
2301
|
+
interface MochaOptions {
|
2302
|
+
/** Propagate uncaught errors? */
|
2303
|
+
allowUncaught?: boolean | undefined;
|
2304
|
+
|
2305
|
+
/** Force `done` callback or promise? */
|
2306
|
+
asyncOnly?: boolean | undefined;
|
2307
|
+
|
2308
|
+
/** bail on the first test failure. */
|
2309
|
+
bail?: boolean | undefined;
|
2310
|
+
|
2311
|
+
/** Check for global variable leaks? */
|
2312
|
+
checkLeaks?: boolean | undefined;
|
2313
|
+
|
2314
|
+
/** Color TTY output from reporter */
|
2315
|
+
color?: boolean | undefined;
|
2316
|
+
|
2317
|
+
/** Delay root suite execution? */
|
2318
|
+
delay?: boolean | undefined;
|
2319
|
+
|
2320
|
+
/** Show diff on failure? */
|
2321
|
+
diff?: boolean | undefined;
|
2322
|
+
|
2323
|
+
/** Report tests without running them? */
|
2324
|
+
dryRun?: boolean | undefined;
|
2325
|
+
|
2326
|
+
/** Fail test run if zero tests encountered. */
|
2327
|
+
failZero?: boolean | undefined;
|
2328
|
+
|
2329
|
+
/** Test filter given string. */
|
2330
|
+
fgrep?: string | undefined;
|
2331
|
+
|
2332
|
+
/** Tests marked `only` fail the suite? */
|
2333
|
+
forbidOnly?: boolean | undefined;
|
2334
|
+
|
2335
|
+
/** Pending tests fail the suite? */
|
2336
|
+
forbidPending?: boolean | undefined;
|
2337
|
+
|
2338
|
+
/** Full stacktrace upon failure? */
|
2339
|
+
fullTrace?: boolean | undefined;
|
2340
|
+
|
2341
|
+
/** Variables expected in global scope. */
|
2342
|
+
globals?: string[] | undefined;
|
2343
|
+
|
2344
|
+
/** Test filter given regular expression. */
|
2345
|
+
grep?: string | RegExp | undefined;
|
2346
|
+
|
2347
|
+
/** Enable desktop notifications? */
|
2348
|
+
growl?: boolean | undefined;
|
2349
|
+
|
2350
|
+
/** Display inline diffs? */
|
2351
|
+
inlineDiffs?: boolean | undefined;
|
2352
|
+
|
2353
|
+
/** Invert test filter matches? */
|
2354
|
+
invert?: boolean | undefined;
|
2355
|
+
|
2356
|
+
/** Disable syntax highlighting? */
|
2357
|
+
noHighlighting?: boolean | undefined;
|
2358
|
+
|
2359
|
+
/** Reporter name or constructor. */
|
2360
|
+
reporter?: string | ReporterConstructor | undefined;
|
2361
|
+
|
2362
|
+
/** Reporter settings object. */
|
2363
|
+
reporterOptions?: any;
|
2364
|
+
|
2365
|
+
/** Number of times to retry failed tests. */
|
2366
|
+
retries?: number | undefined;
|
2367
|
+
|
2368
|
+
/** Slow threshold value. */
|
2369
|
+
slow?: number | undefined;
|
2370
|
+
|
2371
|
+
/** Timeout threshold value. */
|
2372
|
+
timeout?: number | string | undefined;
|
2373
|
+
|
2374
|
+
/** Interface name. */
|
2375
|
+
ui?: Interface | undefined;
|
2376
|
+
|
2377
|
+
/** Run jobs in parallel */
|
2378
|
+
parallel?: boolean | undefined;
|
2379
|
+
|
2380
|
+
/** Max number of worker processes for parallel runs. */
|
2381
|
+
jobs?: number | undefined;
|
2382
|
+
|
2383
|
+
/** Hooks to bootstrap the root suite with. */
|
2384
|
+
rootHooks?: RootHookObject | undefined;
|
2385
|
+
|
2386
|
+
/** Pathname of `rootHooks` plugin for parallel runs. */
|
2387
|
+
require?: string[] | undefined;
|
2388
|
+
|
2389
|
+
/** Should be `true` if `Mocha` process is running in a worker process. */
|
2390
|
+
isWorker?: boolean | undefined;
|
2391
|
+
}
|
2392
|
+
|
2393
|
+
interface MochaInstanceOptions extends MochaOptions {
|
2394
|
+
files?: string[] | undefined;
|
2395
|
+
}
|
2396
|
+
|
2397
|
+
/**
|
2398
|
+
* Variables added to the global scope by Mocha when run in the CLI.
|
2399
|
+
*/
|
2400
|
+
interface MochaGlobals {
|
2401
|
+
/**
|
2402
|
+
* Execute before running tests.
|
2403
|
+
*
|
2404
|
+
* - _Only available when invoked via the mocha CLI._
|
2405
|
+
*
|
2406
|
+
* @see https://mochajs.org/api/global.html#before
|
2407
|
+
*/
|
2408
|
+
before: HookFunction;
|
2409
|
+
|
2410
|
+
/**
|
2411
|
+
* Execute after running tests.
|
2412
|
+
*
|
2413
|
+
* - _Only available when invoked via the mocha CLI._
|
2414
|
+
*
|
2415
|
+
* @see https://mochajs.org/api/global.html#after
|
2416
|
+
*/
|
2417
|
+
after: HookFunction;
|
2418
|
+
|
2419
|
+
/**
|
2420
|
+
* Execute before each test case.
|
2421
|
+
*
|
2422
|
+
* - _Only available when invoked via the mocha CLI._
|
2423
|
+
*
|
2424
|
+
* @see https://mochajs.org/api/global.html#beforeEach
|
2425
|
+
*/
|
2426
|
+
beforeEach: HookFunction;
|
2427
|
+
|
2428
|
+
/**
|
2429
|
+
* Execute after each test case.
|
2430
|
+
*
|
2431
|
+
* - _Only available when invoked via the mocha CLI._
|
2432
|
+
*
|
2433
|
+
* @see https://mochajs.org/api/global.html#afterEach
|
2434
|
+
*/
|
2435
|
+
afterEach: HookFunction;
|
2436
|
+
|
2437
|
+
/**
|
2438
|
+
* Describe a "suite" containing nested suites and tests.
|
2439
|
+
*
|
2440
|
+
* - _Only available when invoked via the mocha CLI._
|
2441
|
+
*/
|
2442
|
+
describe: SuiteFunction;
|
2443
|
+
|
2444
|
+
/**
|
2445
|
+
* Describe a "suite" containing nested suites and tests.
|
2446
|
+
*
|
2447
|
+
* - _Only available when invoked via the mocha CLI._
|
2448
|
+
*/
|
2449
|
+
context: SuiteFunction;
|
2450
|
+
|
2451
|
+
/**
|
2452
|
+
* Pending suite.
|
2453
|
+
*
|
2454
|
+
* - _Only available when invoked via the mocha CLI._
|
2455
|
+
*/
|
2456
|
+
xdescribe: PendingSuiteFunction;
|
2457
|
+
|
2458
|
+
/**
|
2459
|
+
* Pending suite.
|
2460
|
+
*
|
2461
|
+
* - _Only available when invoked via the mocha CLI._
|
2462
|
+
*/
|
2463
|
+
xcontext: PendingSuiteFunction;
|
2464
|
+
|
2465
|
+
/**
|
2466
|
+
* Describes a test case.
|
2467
|
+
*
|
2468
|
+
* - _Only available when invoked via the mocha CLI._
|
2469
|
+
*/
|
2470
|
+
it: TestFunction;
|
2471
|
+
|
2472
|
+
/**
|
2473
|
+
* Describes a test case.
|
2474
|
+
*
|
2475
|
+
* - _Only available when invoked via the mocha CLI._
|
2476
|
+
*/
|
2477
|
+
specify: TestFunction;
|
2478
|
+
|
2479
|
+
/**
|
2480
|
+
* Describes a pending test case.
|
2481
|
+
*
|
2482
|
+
* - _Only available when invoked via the mocha CLI._
|
2483
|
+
*/
|
2484
|
+
xit: PendingTestFunction;
|
2485
|
+
|
2486
|
+
/**
|
2487
|
+
* Describes a pending test case.
|
2488
|
+
*
|
2489
|
+
* - _Only available when invoked via the mocha CLI._
|
2490
|
+
*/
|
2491
|
+
xspecify: PendingTestFunction;
|
2492
|
+
|
2493
|
+
/**
|
2494
|
+
* Execute before running tests.
|
2495
|
+
*
|
2496
|
+
* - _Only available when invoked via the mocha CLI._
|
2497
|
+
*
|
2498
|
+
* @see https://mochajs.org/api/global.html#before
|
2499
|
+
*/
|
2500
|
+
suiteSetup: HookFunction;
|
2501
|
+
|
2502
|
+
/**
|
2503
|
+
* Execute after running tests.
|
2504
|
+
*
|
2505
|
+
* - _Only available when invoked via the mocha CLI._
|
2506
|
+
*
|
2507
|
+
* @see https://mochajs.org/api/global.html#after
|
2508
|
+
*/
|
2509
|
+
suiteTeardown: HookFunction;
|
2510
|
+
|
2511
|
+
/**
|
2512
|
+
* Execute before each test case.
|
2513
|
+
*
|
2514
|
+
* - _Only available when invoked via the mocha CLI._
|
2515
|
+
*
|
2516
|
+
* @see https://mochajs.org/api/global.html#beforeEach
|
2517
|
+
*/
|
2518
|
+
setup: HookFunction;
|
2519
|
+
|
2520
|
+
/**
|
2521
|
+
* Execute after each test case.
|
2522
|
+
*
|
2523
|
+
* - _Only available when invoked via the mocha CLI._
|
2524
|
+
*
|
2525
|
+
* @see https://mochajs.org/api/global.html#afterEach
|
2526
|
+
*/
|
2527
|
+
teardown: HookFunction;
|
2528
|
+
|
2529
|
+
/**
|
2530
|
+
* Describe a "suite" containing nested suites and tests.
|
2531
|
+
*
|
2532
|
+
* - _Only available when invoked via the mocha CLI._
|
2533
|
+
*/
|
2534
|
+
suite: SuiteFunction;
|
2535
|
+
|
2536
|
+
/**
|
2537
|
+
* Describes a test case.
|
2538
|
+
*
|
2539
|
+
* - _Only available when invoked via the mocha CLI._
|
2540
|
+
*/
|
2541
|
+
test: TestFunction;
|
2542
|
+
|
2543
|
+
run: typeof run;
|
2544
|
+
}
|
2545
|
+
|
2546
|
+
/**
|
2547
|
+
* Third-party declarations that want to add new entries to the `Reporter` union can
|
2548
|
+
* contribute names here.
|
2549
|
+
*/
|
2550
|
+
interface ReporterContributions {
|
2551
|
+
Base: never;
|
2552
|
+
base: never;
|
2553
|
+
Dot: never;
|
2554
|
+
dot: never;
|
2555
|
+
TAP: never;
|
2556
|
+
tap: never;
|
2557
|
+
JSON: never;
|
2558
|
+
json: never;
|
2559
|
+
HTML: never;
|
2560
|
+
html: never;
|
2561
|
+
List: never;
|
2562
|
+
list: never;
|
2563
|
+
Min: never;
|
2564
|
+
min: never;
|
2565
|
+
Spec: never;
|
2566
|
+
spec: never;
|
2567
|
+
Nyan: never;
|
2568
|
+
nyan: never;
|
2569
|
+
XUnit: never;
|
2570
|
+
xunit: never;
|
2571
|
+
Markdown: never;
|
2572
|
+
markdown: never;
|
2573
|
+
Progress: never;
|
2574
|
+
progress: never;
|
2575
|
+
Landing: never;
|
2576
|
+
landing: never;
|
2577
|
+
JSONStream: never;
|
2578
|
+
"json-stream": never;
|
2579
|
+
}
|
2580
|
+
|
2581
|
+
type Reporter = keyof ReporterContributions;
|
2582
|
+
|
2583
|
+
/**
|
2584
|
+
* Third-party declarations that want to add new entries to the `Interface` union can
|
2585
|
+
* contribute names here.
|
2586
|
+
*/
|
2587
|
+
interface InterfaceContributions {
|
2588
|
+
bdd: never;
|
2589
|
+
tdd: never;
|
2590
|
+
qunit: never;
|
2591
|
+
exports: never;
|
2592
|
+
}
|
2593
|
+
|
2594
|
+
type Interface = keyof InterfaceContributions;
|
2595
|
+
}
|
2596
|
+
|
2597
|
+
// #region Test interface augmentations
|
2598
|
+
|
2599
|
+
/**
|
2600
|
+
* Triggers root suite execution.
|
2601
|
+
*
|
2602
|
+
* - _Only available if flag --delay is passed into Mocha._
|
2603
|
+
* - _Only available when invoked via the mocha CLI._
|
2604
|
+
*
|
2605
|
+
* @see https://mochajs.org/api/global.html#runWithSuite
|
2606
|
+
*/
|
2607
|
+
declare function run(): void;
|
2608
|
+
|
2609
|
+
/**
|
2610
|
+
* Execute before running tests.
|
2611
|
+
*
|
2612
|
+
* - _Only available when invoked via the mocha CLI._
|
2613
|
+
*
|
2614
|
+
* @see https://mochajs.org/api/global.html#before
|
2615
|
+
*/
|
2616
|
+
declare var before: Mocha.HookFunction<Mocha.Hook>;
|
2617
|
+
|
2618
|
+
/**
|
2619
|
+
* Execute before running tests.
|
2620
|
+
*
|
2621
|
+
* - _Only available when invoked via the mocha CLI._
|
2622
|
+
*
|
2623
|
+
* @see https://mochajs.org/api/global.html#before
|
2624
|
+
*/
|
2625
|
+
declare var suiteSetup: Mocha.HookFunction;
|
2626
|
+
|
2627
|
+
/**
|
2628
|
+
* Execute after running tests.
|
2629
|
+
*
|
2630
|
+
* - _Only available when invoked via the mocha CLI._
|
2631
|
+
*
|
2632
|
+
* @see https://mochajs.org/api/global.html#after
|
2633
|
+
*/
|
2634
|
+
declare var after: Mocha.HookFunction<Mocha.Hook>;
|
2635
|
+
|
2636
|
+
/**
|
2637
|
+
* Execute after running tests.
|
2638
|
+
*
|
2639
|
+
* - _Only available when invoked via the mocha CLI._
|
2640
|
+
*
|
2641
|
+
* @see https://mochajs.org/api/global.html#after
|
2642
|
+
*/
|
2643
|
+
declare var suiteTeardown: Mocha.HookFunction;
|
2644
|
+
|
2645
|
+
/**
|
2646
|
+
* Execute before each test case.
|
2647
|
+
*
|
2648
|
+
* - _Only available when invoked via the mocha CLI._
|
2649
|
+
*
|
2650
|
+
* @see https://mochajs.org/api/global.html#beforeEach
|
2651
|
+
*/
|
2652
|
+
declare var beforeEach: Mocha.HookFunction<Mocha.Hook>;
|
2653
|
+
|
2654
|
+
/**
|
2655
|
+
* Execute before each test case.
|
2656
|
+
*
|
2657
|
+
* - _Only available when invoked via the mocha CLI._
|
2658
|
+
*
|
2659
|
+
* @see https://mochajs.org/api/global.html#beforeEach
|
2660
|
+
*/
|
2661
|
+
declare var setup: Mocha.HookFunction;
|
2662
|
+
|
2663
|
+
/**
|
2664
|
+
* Execute after each test case.
|
2665
|
+
*
|
2666
|
+
* - _Only available when invoked via the mocha CLI._
|
2667
|
+
*
|
2668
|
+
* @see https://mochajs.org/api/global.html#afterEach
|
2669
|
+
*/
|
2670
|
+
declare var afterEach: Mocha.HookFunction<Mocha.Hook>;
|
2671
|
+
|
2672
|
+
/**
|
2673
|
+
* Execute after each test case.
|
2674
|
+
*
|
2675
|
+
* - _Only available when invoked via the mocha CLI._
|
2676
|
+
*
|
2677
|
+
* @see https://mochajs.org/api/global.html#afterEach
|
2678
|
+
*/
|
2679
|
+
declare var teardown: Mocha.HookFunction;
|
2680
|
+
|
2681
|
+
/**
|
2682
|
+
* Describe a "suite" containing nested suites and tests.
|
2683
|
+
*
|
2684
|
+
* - _Only available when invoked via the mocha CLI._
|
2685
|
+
*/
|
2686
|
+
declare var describe: Mocha.SuiteFunction;
|
2687
|
+
|
2688
|
+
/**
|
2689
|
+
* Describe a "suite" containing nested suites and tests.
|
2690
|
+
*
|
2691
|
+
* - _Only available when invoked via the mocha CLI._
|
2692
|
+
*/
|
2693
|
+
declare var context: Mocha.SuiteFunction;
|
2694
|
+
|
2695
|
+
/**
|
2696
|
+
* Describe a "suite" containing nested suites and tests.
|
2697
|
+
*
|
2698
|
+
* - _Only available when invoked via the mocha CLI._
|
2699
|
+
*/
|
2700
|
+
declare var suite: Mocha.SuiteFunction;
|
2701
|
+
|
2702
|
+
/**
|
2703
|
+
* Pending suite.
|
2704
|
+
*
|
2705
|
+
* - _Only available when invoked via the mocha CLI._
|
2706
|
+
*/
|
2707
|
+
declare var xdescribe: Mocha.PendingSuiteFunction;
|
2708
|
+
|
2709
|
+
/**
|
2710
|
+
* Pending suite.
|
2711
|
+
*
|
2712
|
+
* - _Only available when invoked via the mocha CLI._
|
2713
|
+
*/
|
2714
|
+
declare var xcontext: Mocha.PendingSuiteFunction;
|
2715
|
+
|
2716
|
+
/**
|
2717
|
+
* Describes a test case.
|
2718
|
+
*
|
2719
|
+
* - _Only available when invoked via the mocha CLI._
|
2720
|
+
*/
|
2721
|
+
declare var it: Mocha.TestFunction;
|
2722
|
+
|
2723
|
+
/**
|
2724
|
+
* Describes a test case.
|
2725
|
+
*
|
2726
|
+
* - _Only available when invoked via the mocha CLI._
|
2727
|
+
*/
|
2728
|
+
declare var specify: Mocha.TestFunction;
|
2729
|
+
|
2730
|
+
/**
|
2731
|
+
* Describes a test case.
|
2732
|
+
*
|
2733
|
+
* - _Only available when invoked via the mocha CLI._
|
2734
|
+
*/
|
2735
|
+
declare var test: Mocha.TestFunction;
|
2736
|
+
|
2737
|
+
/**
|
2738
|
+
* Describes a pending test case.
|
2739
|
+
*
|
2740
|
+
* - _Only available when invoked via the mocha CLI._
|
2741
|
+
*/
|
2742
|
+
declare var xit: Mocha.PendingTestFunction;
|
2743
|
+
|
2744
|
+
/**
|
2745
|
+
* Describes a pending test case.
|
2746
|
+
*
|
2747
|
+
* - _Only available when invoked via the mocha CLI._
|
2748
|
+
*/
|
2749
|
+
declare var xspecify: Mocha.PendingTestFunction;
|
2750
|
+
|
2751
|
+
// #endregion Test interface augmentations
|
2752
|
+
|
2753
|
+
// #region Reporter augmentations
|
2754
|
+
|
2755
|
+
// Forward declaration for `HTMLLIElement` from lib.dom.d.ts.
|
2756
|
+
// Required by Mocha.reporters.HTML.
|
2757
|
+
// NOTE: Mocha *must not* have a direct dependency on DOM types.
|
2758
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
2759
|
+
interface HTMLLIElement {}
|
2760
|
+
|
2761
|
+
// Augments the DOM `Window` object when lib.dom.d.ts is loaded.
|
2762
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
2763
|
+
interface Window extends Mocha.MochaGlobals {}
|
2764
|
+
|
2765
|
+
declare namespace NodeJS {
|
2766
|
+
// Forward declaration for `NodeJS.EventEmitter` from node.d.ts.
|
2767
|
+
// Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite.
|
2768
|
+
// NOTE: Mocha *must not* have a direct dependency on @types/node.
|
2769
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
2770
|
+
interface EventEmitter {}
|
2771
|
+
|
2772
|
+
// Augments NodeJS's `global` object when node.d.ts is loaded
|
2773
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
2774
|
+
interface Global extends Mocha.MochaGlobals {}
|
2775
|
+
}
|
2776
|
+
|
2777
|
+
// #endregion Reporter augmentations
|
2778
|
+
|
2779
|
+
// #region Browser augmentations
|
2780
|
+
|
2781
|
+
/**
|
2782
|
+
* Mocha global.
|
2783
|
+
*
|
2784
|
+
* - _Only supported in the browser._
|
2785
|
+
*/
|
2786
|
+
declare const mocha: BrowserMocha;
|
2787
|
+
|
2788
|
+
interface BrowserMocha extends Mocha {
|
2789
|
+
/**
|
2790
|
+
* Function to allow assertion libraries to throw errors directly into mocha.
|
2791
|
+
* This is useful when running tests in a browser because window.onerror will
|
2792
|
+
* only receive the 'message' attribute of the Error.
|
2793
|
+
*
|
2794
|
+
* - _Only supported in the browser._
|
2795
|
+
*/
|
2796
|
+
throwError(err: any): never;
|
2797
|
+
|
2798
|
+
/**
|
2799
|
+
* Setup mocha with the given settings options.
|
2800
|
+
*
|
2801
|
+
* - _Only supported in the browser._
|
2802
|
+
*/
|
2803
|
+
setup(opts?: Mocha.Interface | Mocha.MochaOptions): this;
|
2804
|
+
}
|
2805
|
+
|
2806
|
+
// #endregion Browser augmentations
|
2807
|
+
|
2808
|
+
declare module "mocha" {
|
2809
|
+
export = Mocha;
|
2810
|
+
}
|
2811
|
+
|
2812
|
+
declare module "mocha/lib/stats-collector" {
|
2813
|
+
export = createStatsCollector;
|
2814
|
+
|
2815
|
+
/**
|
2816
|
+
* Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`.
|
2817
|
+
*/
|
2818
|
+
function createStatsCollector(runner: Mocha.Runner): void;
|
2819
|
+
}
|
2820
|
+
|
2821
|
+
declare module "mocha/lib/interfaces/common" {
|
2822
|
+
export = common;
|
2823
|
+
|
2824
|
+
function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions;
|
2825
|
+
|
2826
|
+
namespace common {
|
2827
|
+
interface CommonFunctions {
|
2828
|
+
/**
|
2829
|
+
* This is only present if flag --delay is passed into Mocha. It triggers
|
2830
|
+
* root suite execution.
|
2831
|
+
*/
|
2832
|
+
runWithSuite(suite: Mocha.Suite): () => void;
|
2833
|
+
|
2834
|
+
/**
|
2835
|
+
* Execute before running tests.
|
2836
|
+
*/
|
2837
|
+
before(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
2838
|
+
|
2839
|
+
/**
|
2840
|
+
* Execute before running tests.
|
2841
|
+
*/
|
2842
|
+
before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
2843
|
+
|
2844
|
+
/**
|
2845
|
+
* Execute after running tests.
|
2846
|
+
*/
|
2847
|
+
after(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
2848
|
+
|
2849
|
+
/**
|
2850
|
+
* Execute after running tests.
|
2851
|
+
*/
|
2852
|
+
after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
2853
|
+
|
2854
|
+
/**
|
2855
|
+
* Execute before each test case.
|
2856
|
+
*/
|
2857
|
+
beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
2858
|
+
|
2859
|
+
/**
|
2860
|
+
* Execute before each test case.
|
2861
|
+
*/
|
2862
|
+
beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
2863
|
+
|
2864
|
+
/**
|
2865
|
+
* Execute after each test case.
|
2866
|
+
*/
|
2867
|
+
afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
2868
|
+
|
2869
|
+
/**
|
2870
|
+
* Execute after each test case.
|
2871
|
+
*/
|
2872
|
+
afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
|
2873
|
+
|
2874
|
+
suite: SuiteFunctions;
|
2875
|
+
test: TestFunctions;
|
2876
|
+
}
|
2877
|
+
|
2878
|
+
interface CreateOptions {
|
2879
|
+
/** Title of suite */
|
2880
|
+
title: string;
|
2881
|
+
|
2882
|
+
/** Suite function */
|
2883
|
+
fn?: ((this: Mocha.Suite) => void) | undefined;
|
2884
|
+
|
2885
|
+
/** Is suite pending? */
|
2886
|
+
pending?: boolean | undefined;
|
2887
|
+
|
2888
|
+
/** Filepath where this Suite resides */
|
2889
|
+
file?: string | undefined;
|
2890
|
+
|
2891
|
+
/** Is suite exclusive? */
|
2892
|
+
isOnly?: boolean | undefined;
|
2893
|
+
}
|
2894
|
+
|
2895
|
+
interface SuiteFunctions {
|
2896
|
+
/**
|
2897
|
+
* Create an exclusive Suite; convenience function
|
2898
|
+
*/
|
2899
|
+
only(opts: CreateOptions): Mocha.Suite;
|
2900
|
+
|
2901
|
+
/**
|
2902
|
+
* Create a Suite, but skip it; convenience function
|
2903
|
+
*/
|
2904
|
+
skip(opts: CreateOptions): Mocha.Suite;
|
2905
|
+
|
2906
|
+
/**
|
2907
|
+
* Creates a suite.
|
2908
|
+
*/
|
2909
|
+
create(opts: CreateOptions): Mocha.Suite;
|
2910
|
+
}
|
2911
|
+
|
2912
|
+
interface TestFunctions {
|
2913
|
+
/**
|
2914
|
+
* Exclusive test-case.
|
2915
|
+
*/
|
2916
|
+
only(mocha: Mocha, test: Mocha.Test): Mocha.Test;
|
2917
|
+
|
2918
|
+
/**
|
2919
|
+
* Pending test case.
|
2920
|
+
*/
|
2921
|
+
skip(title: string): void;
|
2922
|
+
|
2923
|
+
/**
|
2924
|
+
* Number of retry attempts
|
2925
|
+
*/
|
2926
|
+
retries(n: number): void;
|
2927
|
+
}
|
2928
|
+
}
|
2929
|
+
}
|