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