typespeed 2.3.6 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/app/src/config-development.json +3 -2
  2. package/app/src/test-socket.class.ts +56 -0
  3. package/app/src/views/socket.html +23 -0
  4. package/dist/introduction/decorator/example-import.class.js +17 -0
  5. package/dist/introduction/decorator/main-app.js +14 -0
  6. package/dist/introduction/decorator/main-decorator.js +127 -0
  7. package/dist/introduction/decorator/main-import.js +1 -0
  8. package/dist/introduction/decorator/main-reflect.js +38 -0
  9. package/dist/introduction/web-services/db-init.js +33 -0
  10. package/dist/introduction/web-services/db-singleton.js +49 -0
  11. package/dist/introduction/web-services/http-if.js +12 -0
  12. package/dist/introduction/web-services/http-init.js +7 -0
  13. package/dist/introduction/web-services/http-router.js +23 -0
  14. package/dist/{database.decorator.js → src/database.decorator.js} +2 -4
  15. package/dist/{default → src/default}/express-server.class.js +20 -5
  16. package/dist/{default → src/default}/rabbitmq.class.js +3 -3
  17. package/dist/{default → src/default}/redis.class.js +1 -1
  18. package/dist/src/default/socket-io.class.js +64 -0
  19. package/dist/{typespeed.js → src/typespeed.js} +6 -3
  20. package/dist/typespeed.d.ts +19 -1
  21. package/package.json +8 -8
  22. package/src/database.decorator.ts +2 -4
  23. package/src/default/express-server.class.ts +18 -7
  24. package/src/default/rabbitmq.class.ts +3 -3
  25. package/src/default/redis.class.ts +1 -1
  26. package/src/default/socket-io.class.ts +68 -0
  27. package/src/factory/server-factory.class.ts +1 -1
  28. package/src/typespeed.d.ts +19 -1
  29. package/src/typespeed.ts +7 -4
  30. package/test/socket.test.ts +60 -0
  31. package/tsconfig.json +2 -1
  32. package/app/node_modules/.package-lock.json +0 -134
  33. package/app/node_modules/@types/body-parser/LICENSE +0 -21
  34. package/app/node_modules/@types/body-parser/README.md +0 -16
  35. package/app/node_modules/@types/body-parser/index.d.ts +0 -107
  36. package/app/node_modules/@types/body-parser/package.json +0 -58
  37. package/app/node_modules/@types/connect/LICENSE +0 -21
  38. package/app/node_modules/@types/connect/README.md +0 -16
  39. package/app/node_modules/@types/connect/index.d.ts +0 -93
  40. package/app/node_modules/@types/connect/package.json +0 -32
  41. package/app/node_modules/@types/express/LICENSE +0 -21
  42. package/app/node_modules/@types/express/README.md +0 -16
  43. package/app/node_modules/@types/express/index.d.ts +0 -136
  44. package/app/node_modules/@types/express/package.json +0 -45
  45. package/app/node_modules/@types/express-serve-static-core/LICENSE +0 -21
  46. package/app/node_modules/@types/express-serve-static-core/README.md +0 -16
  47. package/app/node_modules/@types/express-serve-static-core/index.d.ts +0 -1281
  48. package/app/node_modules/@types/express-serve-static-core/package.json +0 -55
  49. package/app/node_modules/@types/mime/LICENSE +0 -21
  50. package/app/node_modules/@types/mime/Mime.d.ts +0 -10
  51. package/app/node_modules/@types/mime/README.md +0 -16
  52. package/app/node_modules/@types/mime/index.d.ts +0 -35
  53. package/app/node_modules/@types/mime/lite.d.ts +0 -7
  54. package/app/node_modules/@types/mime/package.json +0 -29
  55. package/app/node_modules/@types/node/LICENSE +0 -21
  56. package/app/node_modules/@types/node/README.md +0 -16
  57. package/app/node_modules/@types/node/assert/strict.d.ts +0 -8
  58. package/app/node_modules/@types/node/assert.d.ts +0 -961
  59. package/app/node_modules/@types/node/async_hooks.d.ts +0 -518
  60. package/app/node_modules/@types/node/buffer.d.ts +0 -2323
  61. package/app/node_modules/@types/node/child_process.d.ts +0 -1399
  62. package/app/node_modules/@types/node/cluster.d.ts +0 -410
  63. package/app/node_modules/@types/node/console.d.ts +0 -412
  64. package/app/node_modules/@types/node/constants.d.ts +0 -18
  65. package/app/node_modules/@types/node/crypto.d.ts +0 -3973
  66. package/app/node_modules/@types/node/dgram.d.ts +0 -545
  67. package/app/node_modules/@types/node/diagnostics_channel.d.ts +0 -192
  68. package/app/node_modules/@types/node/dns/promises.d.ts +0 -370
  69. package/app/node_modules/@types/node/dns.d.ts +0 -660
  70. package/app/node_modules/@types/node/dom-events.d.ts +0 -126
  71. package/app/node_modules/@types/node/domain.d.ts +0 -170
  72. package/app/node_modules/@types/node/events.d.ts +0 -682
  73. package/app/node_modules/@types/node/fs/promises.d.ts +0 -1159
  74. package/app/node_modules/@types/node/fs.d.ts +0 -3976
  75. package/app/node_modules/@types/node/globals.d.ts +0 -303
  76. package/app/node_modules/@types/node/globals.global.d.ts +0 -1
  77. package/app/node_modules/@types/node/http.d.ts +0 -1714
  78. package/app/node_modules/@types/node/http2.d.ts +0 -2133
  79. package/app/node_modules/@types/node/https.d.ts +0 -542
  80. package/app/node_modules/@types/node/index.d.ts +0 -134
  81. package/app/node_modules/@types/node/inspector.d.ts +0 -2741
  82. package/app/node_modules/@types/node/module.d.ts +0 -115
  83. package/app/node_modules/@types/node/net.d.ts +0 -883
  84. package/app/node_modules/@types/node/os.d.ts +0 -473
  85. package/app/node_modules/@types/node/package.json +0 -237
  86. package/app/node_modules/@types/node/path.d.ts +0 -191
  87. package/app/node_modules/@types/node/perf_hooks.d.ts +0 -625
  88. package/app/node_modules/@types/node/process.d.ts +0 -1488
  89. package/app/node_modules/@types/node/punycode.d.ts +0 -117
  90. package/app/node_modules/@types/node/querystring.d.ts +0 -131
  91. package/app/node_modules/@types/node/readline/promises.d.ts +0 -143
  92. package/app/node_modules/@types/node/readline.d.ts +0 -653
  93. package/app/node_modules/@types/node/repl.d.ts +0 -424
  94. package/app/node_modules/@types/node/stream/consumers.d.ts +0 -12
  95. package/app/node_modules/@types/node/stream/promises.d.ts +0 -42
  96. package/app/node_modules/@types/node/stream/web.d.ts +0 -330
  97. package/app/node_modules/@types/node/stream.d.ts +0 -1440
  98. package/app/node_modules/@types/node/string_decoder.d.ts +0 -67
  99. package/app/node_modules/@types/node/test.d.ts +0 -783
  100. package/app/node_modules/@types/node/timers/promises.d.ts +0 -93
  101. package/app/node_modules/@types/node/timers.d.ts +0 -101
  102. package/app/node_modules/@types/node/tls.d.ts +0 -1111
  103. package/app/node_modules/@types/node/trace_events.d.ts +0 -171
  104. package/app/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  105. package/app/node_modules/@types/node/ts4.8/assert.d.ts +0 -961
  106. package/app/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -518
  107. package/app/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2323
  108. package/app/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1399
  109. package/app/node_modules/@types/node/ts4.8/cluster.d.ts +0 -410
  110. package/app/node_modules/@types/node/ts4.8/console.d.ts +0 -412
  111. package/app/node_modules/@types/node/ts4.8/constants.d.ts +0 -18
  112. package/app/node_modules/@types/node/ts4.8/crypto.d.ts +0 -3972
  113. package/app/node_modules/@types/node/ts4.8/dgram.d.ts +0 -545
  114. package/app/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -192
  115. package/app/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -370
  116. package/app/node_modules/@types/node/ts4.8/dns.d.ts +0 -660
  117. package/app/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -126
  118. package/app/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  119. package/app/node_modules/@types/node/ts4.8/events.d.ts +0 -682
  120. package/app/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1138
  121. package/app/node_modules/@types/node/ts4.8/fs.d.ts +0 -3875
  122. package/app/node_modules/@types/node/ts4.8/globals.d.ts +0 -302
  123. package/app/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  124. package/app/node_modules/@types/node/ts4.8/http.d.ts +0 -1651
  125. package/app/node_modules/@types/node/ts4.8/http2.d.ts +0 -2133
  126. package/app/node_modules/@types/node/ts4.8/https.d.ts +0 -542
  127. package/app/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  128. package/app/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2741
  129. package/app/node_modules/@types/node/ts4.8/module.d.ts +0 -115
  130. package/app/node_modules/@types/node/ts4.8/net.d.ts +0 -883
  131. package/app/node_modules/@types/node/ts4.8/os.d.ts +0 -473
  132. package/app/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  133. package/app/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -625
  134. package/app/node_modules/@types/node/ts4.8/process.d.ts +0 -1488
  135. package/app/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  136. package/app/node_modules/@types/node/ts4.8/querystring.d.ts +0 -131
  137. package/app/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -143
  138. package/app/node_modules/@types/node/ts4.8/readline.d.ts +0 -653
  139. package/app/node_modules/@types/node/ts4.8/repl.d.ts +0 -424
  140. package/app/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  141. package/app/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -42
  142. package/app/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -330
  143. package/app/node_modules/@types/node/ts4.8/stream.d.ts +0 -1440
  144. package/app/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  145. package/app/node_modules/@types/node/ts4.8/test.d.ts +0 -784
  146. package/app/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  147. package/app/node_modules/@types/node/ts4.8/timers.d.ts +0 -94
  148. package/app/node_modules/@types/node/ts4.8/tls.d.ts +0 -1111
  149. package/app/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -171
  150. package/app/node_modules/@types/node/ts4.8/tty.d.ts +0 -206
  151. package/app/node_modules/@types/node/ts4.8/url.d.ts +0 -902
  152. package/app/node_modules/@types/node/ts4.8/util.d.ts +0 -2017
  153. package/app/node_modules/@types/node/ts4.8/v8.d.ts +0 -541
  154. package/app/node_modules/@types/node/ts4.8/vm.d.ts +0 -644
  155. package/app/node_modules/@types/node/ts4.8/wasi.d.ts +0 -158
  156. package/app/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -695
  157. package/app/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  158. package/app/node_modules/@types/node/tty.d.ts +0 -206
  159. package/app/node_modules/@types/node/url.d.ts +0 -902
  160. package/app/node_modules/@types/node/util.d.ts +0 -2017
  161. package/app/node_modules/@types/node/v8.d.ts +0 -541
  162. package/app/node_modules/@types/node/vm.d.ts +0 -644
  163. package/app/node_modules/@types/node/wasi.d.ts +0 -158
  164. package/app/node_modules/@types/node/worker_threads.d.ts +0 -695
  165. package/app/node_modules/@types/node/zlib.d.ts +0 -517
  166. package/app/node_modules/@types/qs/LICENSE +0 -21
  167. package/app/node_modules/@types/qs/README.md +0 -16
  168. package/app/node_modules/@types/qs/index.d.ts +0 -62
  169. package/app/node_modules/@types/qs/package.json +0 -65
  170. package/app/node_modules/@types/range-parser/LICENSE +0 -21
  171. package/app/node_modules/@types/range-parser/README.md +0 -55
  172. package/app/node_modules/@types/range-parser/index.d.ts +0 -35
  173. package/app/node_modules/@types/range-parser/package.json +0 -25
  174. package/app/node_modules/@types/send/LICENSE +0 -21
  175. package/app/node_modules/@types/send/README.md +0 -16
  176. package/app/node_modules/@types/send/index.d.ts +0 -231
  177. package/app/node_modules/@types/send/package.json +0 -33
  178. package/app/node_modules/@types/serve-static/LICENSE +0 -21
  179. package/app/node_modules/@types/serve-static/README.md +0 -16
  180. package/app/node_modules/@types/serve-static/index.d.ts +0 -113
  181. package/app/node_modules/@types/serve-static/package.json +0 -38
  182. package/app/node_modules/colors/LICENSE +0 -25
  183. package/app/node_modules/colors/README.md +0 -221
  184. package/app/node_modules/colors/examples/normal-usage.js +0 -82
  185. package/app/node_modules/colors/examples/safe-string.js +0 -79
  186. package/app/node_modules/colors/index.d.ts +0 -136
  187. package/app/node_modules/colors/lib/colors.js +0 -211
  188. package/app/node_modules/colors/lib/custom/trap.js +0 -46
  189. package/app/node_modules/colors/lib/custom/zalgo.js +0 -110
  190. package/app/node_modules/colors/lib/extendStringPrototype.js +0 -110
  191. package/app/node_modules/colors/lib/index.js +0 -13
  192. package/app/node_modules/colors/lib/maps/america.js +0 -10
  193. package/app/node_modules/colors/lib/maps/rainbow.js +0 -12
  194. package/app/node_modules/colors/lib/maps/random.js +0 -11
  195. package/app/node_modules/colors/lib/maps/zebra.js +0 -5
  196. package/app/node_modules/colors/lib/styles.js +0 -95
  197. package/app/node_modules/colors/lib/system/has-flag.js +0 -35
  198. package/app/node_modules/colors/lib/system/supports-colors.js +0 -151
  199. package/app/node_modules/colors/package.json +0 -45
  200. package/app/node_modules/colors/safe.d.ts +0 -48
  201. package/app/node_modules/colors/safe.js +0 -10
  202. package/app/node_modules/colors/themes/generic-logging.js +0 -12
  203. package/app/node_modules/dateformat/LICENSE +0 -20
  204. package/app/node_modules/dateformat/Readme.md +0 -204
  205. package/app/node_modules/dateformat/lib/dateformat.js +0 -1
  206. package/app/node_modules/dateformat/package.json +0 -38
  207. package/app/node_modules/mkdirp/CHANGELOG.md +0 -15
  208. package/app/node_modules/mkdirp/LICENSE +0 -21
  209. package/app/node_modules/mkdirp/bin/cmd.js +0 -68
  210. package/app/node_modules/mkdirp/index.js +0 -31
  211. package/app/node_modules/mkdirp/lib/find-made.js +0 -29
  212. package/app/node_modules/mkdirp/lib/mkdirp-manual.js +0 -64
  213. package/app/node_modules/mkdirp/lib/mkdirp-native.js +0 -39
  214. package/app/node_modules/mkdirp/lib/opts-arg.js +0 -23
  215. package/app/node_modules/mkdirp/lib/path-arg.js +0 -29
  216. package/app/node_modules/mkdirp/lib/use-native.js +0 -10
  217. package/app/node_modules/mkdirp/package.json +0 -44
  218. package/app/node_modules/mkdirp/readme.markdown +0 -266
  219. package/app/node_modules/tinytim/.travis.yml +0 -5
  220. package/app/node_modules/tinytim/README.md +0 -212
  221. package/app/node_modules/tinytim/index.js +0 -1
  222. package/app/node_modules/tinytim/lib/index.js +0 -55
  223. package/app/node_modules/tinytim/lib/tinytim.js +0 -50
  224. package/app/node_modules/tinytim/package.json +0 -24
  225. package/app/node_modules/tinytim/test/files/html.tim +0 -1
  226. package/app/node_modules/tinytim/test/files/string.tim +0 -1
  227. package/app/node_modules/tinytim/test/files/string2.tim +0 -1
  228. package/app/node_modules/tinytim/test/render-file-replace.js +0 -39
  229. package/app/node_modules/tinytim/test/render-replace.js +0 -94
  230. package/app/node_modules/tinytim/test/tim-replace.js +0 -95
  231. package/app/node_modules/tracer/README.md +0 -747
  232. package/app/node_modules/tracer/lib/color_console.js +0 -15
  233. package/app/node_modules/tracer/lib/console.js +0 -165
  234. package/app/node_modules/tracer/lib/dailyfile.js +0 -92
  235. package/app/node_modules/tracer/lib/index.js +0 -10
  236. package/app/node_modules/tracer/lib/settings.js +0 -25
  237. package/app/node_modules/tracer/lib/utils.js +0 -58
  238. package/app/node_modules/tracer/package.json +0 -53
  239. package/app/node_modules/tracer/types/index.d.ts +0 -189
  240. package/dist/scaffold/templates/front-page.class.ts.tpl +0 -12
  241. package/dist/scaffold/templates/main.ts.tpl +0 -13
  242. package/dist/scaffold/templates/nodemon.json.tpl +0 -7
  243. package/dist/scaffold/templates/package.json.tpl +0 -16
  244. package/dist/scaffold/templates/tsconfig.json.tpl +0 -20
  245. /package/dist/{core.decorator.js → src/core.decorator.js} +0 -0
  246. /package/dist/{default → src/default}/default-authentication.class.js +0 -0
  247. /package/dist/{default → src/default}/log-default.class.js +0 -0
  248. /package/dist/{default → src/default}/node-cache.class.js +0 -0
  249. /package/dist/{default → src/default}/pages/404.html +0 -0
  250. /package/dist/{default → src/default}/pages/500.html +0 -0
  251. /package/dist/{default → src/default}/read-write-db.class.js +0 -0
  252. /package/dist/{factory → src/factory}/authentication-factory.class.js +0 -0
  253. /package/dist/{factory → src/factory}/cache-factory.class.js +0 -0
  254. /package/dist/{factory → src/factory}/data-source-factory.class.js +0 -0
  255. /package/dist/{factory → src/factory}/log-factory.class.js +0 -0
  256. /package/dist/{factory → src/factory}/server-factory.class.js +0 -0
  257. /package/dist/{route.decorator.js → src/route.decorator.js} +0 -0
  258. /package/dist/{scaffold → src/scaffold}/command.js +0 -0
@@ -1,783 +0,0 @@
1
- /**
2
- * The `node:test` module provides a standalone testing module.
3
- * @see [source](https://github.com/nodejs/node/blob/v18.x/lib/test.js)
4
- */
5
- declare module 'node:test' {
6
- /**
7
- * Programmatically start the test runner.
8
- * @since v18.9.0
9
- * @param options Configuration options for running tests.
10
- * @returns A {@link TestsStream} that emits events about the test execution.
11
- */
12
- function run(options?: RunOptions): TestsStream;
13
- /**
14
- * The `test()` function is the value imported from the test module. Each invocation of this
15
- * function results in reporting the test to the {@link TestsStream}.
16
- *
17
- * The {@link TestContext} object passed to the fn argument can be used to perform actions
18
- * related to the current test. Examples include skipping the test, adding additional
19
- * diagnostic information, or creating subtests.
20
- *
21
- * `test()` returns a {@link Promise} that resolves once the test completes. The return value
22
- * can usually be discarded for top level tests. However, the return value from subtests should
23
- * be used to prevent the parent test from finishing first and cancelling the subtest as shown
24
- * in the following example.
25
- *
26
- * ```js
27
- * test('top level test', async (t) => {
28
- * // The setTimeout() in the following subtest would cause it to outlive its
29
- * // parent test if 'await' is removed on the next line. Once the parent test
30
- * // completes, it will cancel any outstanding subtests.
31
- * await t.test('longer running subtest', async (t) => {
32
- * return new Promise((resolve, reject) => {
33
- * setTimeout(resolve, 1000);
34
- * });
35
- * });
36
- * });
37
- * ```
38
- * @since v18.0.0
39
- * @param name The name of the test, which is displayed when reporting test results.
40
- * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
41
- * @param options Configuration options for the test
42
- * @param fn The function under test. The first argument to this function is a
43
- * {@link TestContext} object. If the test uses callbacks, the callback function is
44
- * passed as the second argument. Default: A no-op function.
45
- * @returns A {@link Promise} resolved with `undefined` once the test completes.
46
- */
47
- function test(name?: string, fn?: TestFn): Promise<void>;
48
- function test(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
49
- function test(options?: TestOptions, fn?: TestFn): Promise<void>;
50
- function test(fn?: TestFn): Promise<void>;
51
- namespace test {
52
- export {
53
- after,
54
- afterEach,
55
- before,
56
- beforeEach,
57
- describe,
58
- it,
59
- run,
60
- mock,
61
- test
62
- };
63
- }
64
- /**
65
- * @since v18.6.0
66
- * @param name The name of the suite, which is displayed when reporting suite results.
67
- * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
68
- * @param options Configuration options for the suite
69
- * @param fn The function under suite. Default: A no-op function.
70
- */
71
- function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void;
72
- function describe(name?: string, fn?: SuiteFn): void;
73
- function describe(options?: TestOptions, fn?: SuiteFn): void;
74
- function describe(fn?: SuiteFn): void;
75
- namespace describe {
76
- // Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`.
77
- function skip(name?: string, options?: TestOptions, fn?: SuiteFn): void;
78
- function skip(name?: string, fn?: SuiteFn): void;
79
- function skip(options?: TestOptions, fn?: SuiteFn): void;
80
- function skip(fn?: SuiteFn): void;
81
-
82
- // Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`.
83
- function todo(name?: string, options?: TestOptions, fn?: SuiteFn): void;
84
- function todo(name?: string, fn?: SuiteFn): void;
85
- function todo(options?: TestOptions, fn?: SuiteFn): void;
86
- function todo(fn?: SuiteFn): void;
87
-
88
- /**
89
- * Shorthand for marking a suite as `only`, same as `describe([name], { only: true }[, fn])`.
90
- * @since v18.15.0
91
- */
92
- function only(name?: string, options?: TestOptions, fn?: SuiteFn): void;
93
- function only(name?: string, fn?: SuiteFn): void;
94
- function only(options?: TestOptions, fn?: SuiteFn): void;
95
- function only(fn?: SuiteFn): void;
96
- }
97
-
98
- /**
99
- * @since v18.6.0
100
- * @param name The name of the test, which is displayed when reporting test results.
101
- * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
102
- * @param options Configuration options for the test
103
- * @param fn The function under test. If the test uses callbacks, the callback function is
104
- * passed as the second argument. Default: A no-op function.
105
- */
106
- function it(name?: string, options?: TestOptions, fn?: TestFn): void;
107
- function it(name?: string, fn?: TestFn): void;
108
- function it(options?: TestOptions, fn?: TestFn): void;
109
- function it(fn?: TestFn): void;
110
- namespace it {
111
- // Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
112
- function skip(name?: string, options?: TestOptions, fn?: TestFn): void;
113
- function skip(name?: string, fn?: TestFn): void;
114
- function skip(options?: TestOptions, fn?: TestFn): void;
115
- function skip(fn?: TestFn): void;
116
-
117
- // Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
118
- function todo(name?: string, options?: TestOptions, fn?: TestFn): void;
119
- function todo(name?: string, fn?: TestFn): void;
120
- function todo(options?: TestOptions, fn?: TestFn): void;
121
- function todo(fn?: TestFn): void;
122
-
123
- /**
124
- * Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`.
125
- * @since v18.15.0
126
- */
127
- function only(name?: string, options?: TestOptions, fn?: TestFn): void;
128
- function only(name?: string, fn?: TestFn): void;
129
- function only(options?: TestOptions, fn?: TestFn): void;
130
- function only(fn?: TestFn): void;
131
- }
132
-
133
- /**
134
- * The type of a function under test. The first argument to this function is a
135
- * {@link TestContext} object. If the test uses callbacks, the callback function is passed as
136
- * the second argument.
137
- */
138
- type TestFn = (t: TestContext, done: (result?: any) => void) => any;
139
-
140
- /**
141
- * The type of a function under Suite.
142
- * If the test uses callbacks, the callback function is passed as an argument
143
- */
144
- type SuiteFn = (done: (result?: any) => void) => void;
145
-
146
- interface RunOptions {
147
- /**
148
- * If a number is provided, then that many files would run in parallel.
149
- * If truthy, it would run (number of cpu cores - 1) files in parallel.
150
- * If falsy, it would only run one file at a time.
151
- * If unspecified, subtests inherit this value from their parent.
152
- * @default true
153
- */
154
- concurrency?: number | boolean | undefined;
155
-
156
- /**
157
- * An array containing the list of files to run.
158
- * If unspecified, the test runner execution model will be used.
159
- */
160
- files?: readonly string[] | undefined;
161
-
162
- /**
163
- * Allows aborting an in-progress test execution.
164
- * @default undefined
165
- */
166
- signal?: AbortSignal | undefined;
167
-
168
- /**
169
- * A number of milliseconds the test will fail after.
170
- * If unspecified, subtests inherit this value from their parent.
171
- * @default Infinity
172
- */
173
- timeout?: number | undefined;
174
-
175
- /**
176
- * Sets inspector port of test child process.
177
- * If a nullish value is provided, each process gets its own port,
178
- * incremented from the primary's `process.debugPort`.
179
- */
180
- inspectPort?: number | (() => number) | undefined;
181
- }
182
-
183
- /**
184
- * A successful call of the `run()` method will return a new `TestsStream` object,
185
- * streaming a series of events representing the execution of the tests.
186
- * `TestsStream` will emit events in the order of the tests' definitions.
187
- * @since v18.9.0
188
- */
189
- interface TestsStream extends NodeJS.ReadableStream {
190
- addListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
191
- addListener(event: 'test:fail', listener: (data: TestFail) => void): this;
192
- addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
193
- addListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
194
- addListener(event: 'test:start', listener: (data: TestStart) => void): this;
195
- addListener(event: string, listener: (...args: any[]) => void): this;
196
- emit(event: 'test:diagnostic', data: DiagnosticData): boolean;
197
- emit(event: 'test:fail', data: TestFail): boolean;
198
- emit(event: 'test:pass', data: TestPass): boolean;
199
- emit(event: 'test:plan', data: TestPlan): boolean;
200
- emit(event: 'test:start', data: TestStart): boolean;
201
- emit(event: string | symbol, ...args: any[]): boolean;
202
- on(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
203
- on(event: 'test:fail', listener: (data: TestFail) => void): this;
204
- on(event: 'test:pass', listener: (data: TestPass) => void): this;
205
- on(event: 'test:plan', listener: (data: TestPlan) => void): this;
206
- on(event: 'test:start', listener: (data: TestStart) => void): this;
207
- on(event: string, listener: (...args: any[]) => void): this;
208
- once(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
209
- once(event: 'test:fail', listener: (data: TestFail) => void): this;
210
- once(event: 'test:pass', listener: (data: TestPass) => void): this;
211
- once(event: 'test:plan', listener: (data: TestPlan) => void): this;
212
- once(event: 'test:start', listener: (data: TestStart) => void): this;
213
- once(event: string, listener: (...args: any[]) => void): this;
214
- prependListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
215
- prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
216
- prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
217
- prependListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
218
- prependListener(event: 'test:start', listener: (data: TestStart) => void): this;
219
- prependListener(event: string, listener: (...args: any[]) => void): this;
220
- prependOnceListener(event: 'test:diagnostic', listener: (data: DiagnosticData) => void): this;
221
- prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
222
- prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
223
- prependOnceListener(event: 'test:plan', listener: (data: TestPlan) => void): this;
224
- prependOnceListener(event: 'test:start', listener: (data: TestStart) => void): this;
225
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
226
- }
227
-
228
- interface DiagnosticData {
229
- /**
230
- * The diagnostic message.
231
- */
232
- message: string;
233
-
234
- /**
235
- * The nesting level of the test.
236
- */
237
- nesting: number;
238
- }
239
-
240
- interface TestFail {
241
- /**
242
- * Additional execution metadata.
243
- */
244
- details: {
245
- /**
246
- * The duration of the test in milliseconds.
247
- */
248
- duration: number;
249
-
250
- /**
251
- * The error thrown by the test.
252
- */
253
- error: Error;
254
- };
255
-
256
- /**
257
- * The test name.
258
- */
259
- name: string;
260
-
261
- /**
262
- * The nesting level of the test.
263
- */
264
- nesting: number;
265
-
266
- /**
267
- * The ordinal number of the test.
268
- */
269
- testNumber: number;
270
-
271
- /**
272
- * Present if `context.todo` is called.
273
- */
274
- todo?: string | boolean;
275
-
276
- /**
277
- * Present if `context.skip` is called.
278
- */
279
- skip?: string | boolean;
280
- }
281
-
282
- interface TestPass {
283
- /**
284
- * Additional execution metadata.
285
- */
286
- details: {
287
- /**
288
- * The duration of the test in milliseconds.
289
- */
290
- duration: number;
291
- };
292
-
293
- /**
294
- * The test name.
295
- */
296
- name: string;
297
-
298
- /**
299
- * The nesting level of the test.
300
- */
301
- nesting: number;
302
-
303
- /**
304
- * The ordinal number of the test.
305
- */
306
- testNumber: number;
307
-
308
- /**
309
- * Present if `context.todo` is called.
310
- */
311
- todo?: string | boolean;
312
-
313
- /**
314
- * Present if `context.skip` is called.
315
- */
316
- skip?: string | boolean;
317
- }
318
-
319
- interface TestPlan {
320
- /**
321
- * The nesting level of the test.
322
- */
323
- nesting: number;
324
-
325
- /**
326
- * The number of subtests that have ran.
327
- */
328
- count: number;
329
- }
330
-
331
- interface TestStart {
332
- /**
333
- * The test name.
334
- */
335
- name: string;
336
-
337
- /**
338
- * The nesting level of the test.
339
- */
340
- nesting: number;
341
- }
342
-
343
- /**
344
- * An instance of `TestContext` is passed to each test function in order to interact with the
345
- * test runner. However, the `TestContext` constructor is not exposed as part of the API.
346
- * @since v18.0.0
347
- */
348
- interface TestContext {
349
- /**
350
- * This function is used to create a hook running before each subtest of the current test.
351
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
352
- * the second argument. Default: A no-op function.
353
- * @param options Configuration options for the hook.
354
- * @since v18.8.0
355
- */
356
- beforeEach: typeof beforeEach;
357
-
358
- /**
359
- * This function is used to create a hook that runs after the current test finishes.
360
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
361
- * the second argument. Default: A no-op function.
362
- * @param options Configuration options for the hook.
363
- * @since v18.13.0
364
- */
365
- after: typeof after;
366
-
367
- /**
368
- * This function is used to create a hook running after each subtest of the current test.
369
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
370
- * the second argument. Default: A no-op function.
371
- * @param options Configuration options for the hook.
372
- * @since v18.8.0
373
- */
374
- afterEach: typeof afterEach;
375
-
376
- /**
377
- * This function is used to write diagnostics to the output. Any diagnostic information is
378
- * included at the end of the test's results. This function does not return a value.
379
- * @param message Message to be reported.
380
- * @since v18.0.0
381
- */
382
- diagnostic(message: string): void;
383
-
384
- /**
385
- * The name of the test.
386
- * @since v18.8.0
387
- */
388
- readonly name: string;
389
-
390
- /**
391
- * If `shouldRunOnlyTests` is truthy, the test context will only run tests that have the `only`
392
- * option set. Otherwise, all tests are run. If Node.js was not started with the `--test-only`
393
- * command-line option, this function is a no-op.
394
- * @param shouldRunOnlyTests Whether or not to run `only` tests.
395
- * @since v18.0.0
396
- */
397
- runOnly(shouldRunOnlyTests: boolean): void;
398
-
399
- /**
400
- * Can be used to abort test subtasks when the test has been aborted.
401
- * @since v18.7.0
402
- */
403
- readonly signal: AbortSignal;
404
-
405
- /**
406
- * This function causes the test's output to indicate the test as skipped. If `message` is
407
- * provided, it is included in the output. Calling `skip()` does not terminate execution of
408
- * the test function. This function does not return a value.
409
- * @param message Optional skip message.
410
- * @since v18.0.0
411
- */
412
- skip(message?: string): void;
413
-
414
- /**
415
- * This function adds a `TODO` directive to the test's output. If `message` is provided, it is
416
- * included in the output. Calling `todo()` does not terminate execution of the test
417
- * function. This function does not return a value.
418
- * @param message Optional `TODO` message.
419
- * @since v18.0.0
420
- */
421
- todo(message?: string): void;
422
-
423
- /**
424
- * This function is used to create subtests under the current test. This function behaves in
425
- * the same fashion as the top level {@link test} function.
426
- * @since v18.0.0
427
- * @param name The name of the test, which is displayed when reporting test results.
428
- * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
429
- * @param options Configuration options for the test
430
- * @param fn The function under test. This first argument to this function is a
431
- * {@link TestContext} object. If the test uses callbacks, the callback function is
432
- * passed as the second argument. Default: A no-op function.
433
- * @returns A {@link Promise} resolved with `undefined` once the test completes.
434
- */
435
- test: typeof test;
436
- /**
437
- * Each test provides its own MockTracker instance.
438
- */
439
- readonly mock: MockTracker;
440
- }
441
-
442
- interface TestOptions {
443
- /**
444
- * If a number is provided, then that many tests would run in parallel.
445
- * If truthy, it would run (number of cpu cores - 1) tests in parallel.
446
- * For subtests, it will be `Infinity` tests in parallel.
447
- * If falsy, it would only run one test at a time.
448
- * If unspecified, subtests inherit this value from their parent.
449
- * @default false
450
- */
451
- concurrency?: number | boolean | undefined;
452
-
453
- /**
454
- * If truthy, and the test context is configured to run `only` tests, then this test will be
455
- * run. Otherwise, the test is skipped.
456
- * @default false
457
- */
458
- only?: boolean | undefined;
459
-
460
- /**
461
- * Allows aborting an in-progress test.
462
- * @since v18.8.0
463
- */
464
- signal?: AbortSignal | undefined;
465
-
466
- /**
467
- * If truthy, the test is skipped. If a string is provided, that string is displayed in the
468
- * test results as the reason for skipping the test.
469
- * @default false
470
- */
471
- skip?: boolean | string | undefined;
472
-
473
- /**
474
- * A number of milliseconds the test will fail after. If unspecified, subtests inherit this
475
- * value from their parent.
476
- * @default Infinity
477
- * @since v18.7.0
478
- */
479
- timeout?: number | undefined;
480
-
481
- /**
482
- * If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in
483
- * the test results as the reason why the test is `TODO`.
484
- * @default false
485
- */
486
- todo?: boolean | string | undefined;
487
- }
488
-
489
- /**
490
- * This function is used to create a hook running before running a suite.
491
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
492
- * the second argument. Default: A no-op function.
493
- * @param options Configuration options for the hook.
494
- * @since v18.8.0
495
- */
496
- function before(fn?: HookFn, options?: HookOptions): void;
497
-
498
- /**
499
- * This function is used to create a hook running after running a suite.
500
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
501
- * the second argument. Default: A no-op function.
502
- * @param options Configuration options for the hook.
503
- * @since v18.8.0
504
- */
505
- function after(fn?: HookFn, options?: HookOptions): void;
506
-
507
- /**
508
- * This function is used to create a hook running before each subtest of the current suite.
509
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
510
- * the second argument. Default: A no-op function.
511
- * @param options Configuration options for the hook.
512
- * @since v18.8.0
513
- */
514
- function beforeEach(fn?: HookFn, options?: HookOptions): void;
515
-
516
- /**
517
- * This function is used to create a hook running after each subtest of the current test.
518
- * @param fn The hook function. If the hook uses callbacks, the callback function is passed as
519
- * the second argument. Default: A no-op function.
520
- * @param options Configuration options for the hook.
521
- * @since v18.8.0
522
- */
523
- function afterEach(fn?: HookFn, options?: HookOptions): void;
524
-
525
- /**
526
- * The hook function. If the hook uses callbacks, the callback function is passed as the
527
- * second argument.
528
- */
529
- type HookFn = (done: (result?: any) => void) => any;
530
-
531
- /**
532
- * Configuration options for hooks.
533
- * @since v18.8.0
534
- */
535
- interface HookOptions {
536
- /**
537
- * Allows aborting an in-progress hook.
538
- */
539
- signal?: AbortSignal | undefined;
540
-
541
- /**
542
- * A number of milliseconds the hook will fail after. If unspecified, subtests inherit this
543
- * value from their parent.
544
- * @default Infinity
545
- */
546
- timeout?: number | undefined;
547
- }
548
-
549
- interface MockFunctionOptions {
550
- /**
551
- * The number of times that the mock will use the behavior of `implementation`.
552
- * Once the mock function has been called `times` times,
553
- * it will automatically restore the behavior of `original`.
554
- * This value must be an integer greater than zero.
555
- * @default Infinity
556
- */
557
- times?: number | undefined;
558
- }
559
-
560
- interface MockMethodOptions extends MockFunctionOptions {
561
- /**
562
- * If `true`, `object[methodName]` is treated as a getter.
563
- * This option cannot be used with the `setter` option.
564
- */
565
- getter?: boolean | undefined;
566
-
567
- /**
568
- * If `true`, `object[methodName]` is treated as a setter.
569
- * This option cannot be used with the `getter` option.
570
- */
571
- setter?: boolean | undefined;
572
- }
573
-
574
- type Mock<F extends Function> = F & {
575
- mock: MockFunctionContext<F>;
576
- };
577
-
578
- type NoOpFunction = (...args: any[]) => undefined;
579
-
580
- type FunctionPropertyNames<T> = {
581
- [K in keyof T]: T[K] extends Function ? K : never;
582
- }[keyof T];
583
-
584
- interface MockTracker {
585
- /**
586
- * This function is used to create a mock function.
587
- * @param original An optional function to create a mock on.
588
- * @param implementation An optional function used as the mock implementation for `original`.
589
- * This is useful for creating mocks that exhibit one behavior for a specified number of calls and then restore the behavior of `original`.
590
- * @param options Optional configuration options for the mock function.
591
- */
592
- fn<F extends Function = NoOpFunction>(original?: F, options?: MockFunctionOptions): Mock<F>;
593
- fn<F extends Function = NoOpFunction, Implementation extends Function = F>(original?: F, implementation?: Implementation, options?: MockFunctionOptions): Mock<F | Implementation>;
594
-
595
- /**
596
- * This function is used to create a mock on an existing object method.
597
- * @param object The object whose method is being mocked.
598
- * @param methodName The identifier of the method on `object` to mock. If `object[methodName]` is not a function, an error is thrown.
599
- * @param implementation An optional function used as the mock implementation for `object[methodName]`.
600
- * @param options Optional configuration options for the mock method.
601
- */
602
- method<
603
- MockedObject extends object,
604
- MethodName extends FunctionPropertyNames<MockedObject>,
605
- >(
606
- object: MockedObject,
607
- methodName: MethodName,
608
- options?: MockFunctionOptions,
609
- ): MockedObject[MethodName] extends Function
610
- ? Mock<MockedObject[MethodName]>
611
- : never;
612
- method<
613
- MockedObject extends object,
614
- MethodName extends FunctionPropertyNames<MockedObject>,
615
- Implementation extends Function,
616
- >(
617
- object: MockedObject,
618
- methodName: MethodName,
619
- implementation: Implementation,
620
- options?: MockFunctionOptions,
621
- ): MockedObject[MethodName] extends Function
622
- ? Mock<MockedObject[MethodName] | Implementation>
623
- : never;
624
- method<MockedObject extends object>(
625
- object: MockedObject,
626
- methodName: keyof MockedObject,
627
- options: MockMethodOptions,
628
- ): Mock<Function>;
629
- method<MockedObject extends object>(
630
- object: MockedObject,
631
- methodName: keyof MockedObject,
632
- implementation: Function,
633
- options: MockMethodOptions,
634
- ): Mock<Function>;
635
-
636
- /**
637
- * This function is syntax sugar for {@link MockTracker.method} with `options.getter` set to `true`.
638
- */
639
- getter<
640
- MockedObject extends object,
641
- MethodName extends keyof MockedObject,
642
- >(
643
- object: MockedObject,
644
- methodName: MethodName,
645
- options?: MockFunctionOptions,
646
- ): Mock<() => MockedObject[MethodName]>;
647
- getter<
648
- MockedObject extends object,
649
- MethodName extends keyof MockedObject,
650
- Implementation extends Function,
651
- >(
652
- object: MockedObject,
653
- methodName: MethodName,
654
- implementation?: Implementation,
655
- options?: MockFunctionOptions,
656
- ): Mock<(() => MockedObject[MethodName]) | Implementation>;
657
-
658
- /**
659
- * This function is syntax sugar for {@link MockTracker.method} with `options.setter` set to `true`.
660
- */
661
- setter<
662
- MockedObject extends object,
663
- MethodName extends keyof MockedObject,
664
- >(
665
- object: MockedObject,
666
- methodName: MethodName,
667
- options?: MockFunctionOptions,
668
- ): Mock<(value: MockedObject[MethodName]) => void>;
669
- setter<
670
- MockedObject extends object,
671
- MethodName extends keyof MockedObject,
672
- Implementation extends Function,
673
- >(
674
- object: MockedObject,
675
- methodName: MethodName,
676
- implementation?: Implementation,
677
- options?: MockFunctionOptions,
678
- ): Mock<((value: MockedObject[MethodName]) => void) | Implementation>;
679
-
680
- /**
681
- * This function restores the default behavior of all mocks that were previously created by this `MockTracker`
682
- * and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used,
683
- * but the `MockTracker` instance can no longer be used to reset their behavior or otherwise interact with them.
684
- *
685
- * After each test completes, this function is called on the test context's `MockTracker`.
686
- * If the global `MockTracker` is used extensively, calling this function manually is recommended.
687
- */
688
- reset(): void;
689
-
690
- /**
691
- * This function restores the default behavior of all mocks that were previously created by this `MockTracker`.
692
- * Unlike `mock.reset()`, `mock.restoreAll()` does not disassociate the mocks from the `MockTracker` instance.
693
- */
694
- restoreAll(): void;
695
- }
696
-
697
- const mock: MockTracker;
698
-
699
- interface MockFunctionCall<
700
- F extends Function,
701
- ReturnType = F extends (...args: any) => infer T
702
- ? T
703
- : F extends abstract new (...args: any) => infer T
704
- ? T
705
- : unknown,
706
- Args = F extends (...args: infer Y) => any
707
- ? Y
708
- : F extends abstract new (...args: infer Y) => any
709
- ? Y
710
- : unknown[],
711
- > {
712
- /**
713
- * An array of the arguments passed to the mock function.
714
- */
715
- arguments: Args;
716
- /**
717
- * If the mocked function threw then this property contains the thrown value.
718
- */
719
- error: unknown | undefined;
720
- /**
721
- * The value returned by the mocked function.
722
- *
723
- * If the mocked function threw, it will be `undefined`.
724
- */
725
- result: ReturnType | undefined;
726
- /**
727
- * An `Error` object whose stack can be used to determine the callsite of the mocked function invocation.
728
- */
729
- stack: Error;
730
- /**
731
- * If the mocked function is a constructor, this field contains the class being constructed.
732
- * Otherwise this will be `undefined`.
733
- */
734
- target: F extends abstract new (...args: any) => any ? F : undefined;
735
- /**
736
- * The mocked function's `this` value.
737
- */
738
- this: unknown;
739
- }
740
-
741
- interface MockFunctionContext<F extends Function> {
742
- /**
743
- * A getter that returns a copy of the internal array used to track calls to the mock.
744
- */
745
- readonly calls: Array<MockFunctionCall<F>>;
746
-
747
- /**
748
- * This function returns the number of times that this mock has been invoked.
749
- * This function is more efficient than checking `ctx.calls.length`
750
- * because `ctx.calls` is a getter that creates a copy of the internal call tracking array.
751
- */
752
- callCount(): number;
753
-
754
- /**
755
- * This function is used to change the behavior of an existing mock.
756
- * @param implementation The function to be used as the mock's new implementation.
757
- */
758
- mockImplementation(implementation: Function): void;
759
-
760
- /**
761
- * This function is used to change the behavior of an existing mock for a single invocation.
762
- * Once invocation `onCall` has occurred, the mock will revert to whatever behavior
763
- * it would have used had `mockImplementationOnce()` not been called.
764
- * @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`.
765
- * @param onCall The invocation number that will use `implementation`.
766
- * If the specified invocation has already occurred then an exception is thrown.
767
- */
768
- mockImplementationOnce(implementation: Function, onCall?: number): void;
769
-
770
- /**
771
- * Resets the call history of the mock function.
772
- */
773
- resetCalls(): void;
774
-
775
- /**
776
- * Resets the implementation of the mock function to its original behavior.
777
- * The mock can still be used after calling this function.
778
- */
779
- restore(): void;
780
- }
781
-
782
- export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock };
783
- }