velocious 1.0.643 → 1.0.645

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 (279) hide show
  1. package/README.md +21 -10
  2. package/build/authorization/ability.js +36 -13
  3. package/build/background-jobs/adapter.js +9 -0
  4. package/build/background-jobs/main.js +35 -10
  5. package/build/background-jobs/store.js +217 -38
  6. package/build/background-jobs/types.js +15 -0
  7. package/build/configuration-types.js +1 -1
  8. package/build/configuration.js +45 -9
  9. package/build/database/drivers/base-column.js +8 -0
  10. package/build/database/drivers/mssql/sql/update.js +1 -3
  11. package/build/database/drivers/mysql/sql/update.js +1 -3
  12. package/build/database/drivers/pgsql/column.js +22 -0
  13. package/build/database/drivers/pgsql/sql/update.js +1 -3
  14. package/build/database/drivers/sqlite/sql/alter-table.js +11 -1
  15. package/build/database/drivers/sqlite/sql/update.js +1 -3
  16. package/build/database/query/index.js +2 -2
  17. package/build/database/query/model-class-query.js +26 -10
  18. package/build/database/query/preloader/has-many.js +4 -1
  19. package/build/database/query/query-data.js +2 -1
  20. package/build/database/query/update-base.js +14 -0
  21. package/build/database/query/with-count.js +3 -1
  22. package/build/database/record/acts-as-list.js +37 -13
  23. package/build/database/record/attachments/store.js +336 -26
  24. package/build/database/record/auditing.js +6 -3
  25. package/build/database/record/index.js +197 -42
  26. package/build/database/record/instance-relationships/belongs-to.js +2 -1
  27. package/build/database/record/validators/uniqueness.js +8 -5
  28. package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -8
  29. package/build/frontend-model-controller.js +136 -53
  30. package/build/frontend-model-resource/base-resource.js +87 -37
  31. package/build/frontend-model-resource/velocious-attachment-resource.js +98 -31
  32. package/build/frontend-models/base.js +307 -59
  33. package/build/frontend-models/preloader.js +6 -3
  34. package/build/frontend-models/query.js +15 -6
  35. package/build/frontend-models/resource-definition.js +21 -2
  36. package/build/frontend-models/use-destroyed-event.js +1 -1
  37. package/build/frontend-models/use-model-class-event.js +2 -2
  38. package/build/frontend-models/use-updated-event.js +1 -1
  39. package/build/frontend-models/websocket-channel.js +256 -93
  40. package/build/frontend-models/websocket-publishers.js +218 -18
  41. package/build/http-server/client/websocket-session.js +13 -1
  42. package/build/http-server/websocket-channel.js +15 -2
  43. package/build/src/authorization/ability.d.ts +9 -3
  44. package/build/src/authorization/ability.d.ts.map +1 -1
  45. package/build/src/authorization/ability.js +33 -14
  46. package/build/src/background-jobs/adapter.d.ts +6 -0
  47. package/build/src/background-jobs/adapter.d.ts.map +1 -1
  48. package/build/src/background-jobs/adapter.js +9 -1
  49. package/build/src/background-jobs/main.d.ts +6 -0
  50. package/build/src/background-jobs/main.d.ts.map +1 -1
  51. package/build/src/background-jobs/main.js +34 -11
  52. package/build/src/background-jobs/store.d.ts +66 -12
  53. package/build/src/background-jobs/store.d.ts.map +1 -1
  54. package/build/src/background-jobs/store.js +191 -35
  55. package/build/src/background-jobs/types.d.ts +55 -0
  56. package/build/src/background-jobs/types.d.ts.map +1 -1
  57. package/build/src/background-jobs/types.js +16 -1
  58. package/build/src/configuration-types.d.ts +3 -3
  59. package/build/src/configuration-types.d.ts.map +1 -1
  60. package/build/src/configuration-types.js +2 -2
  61. package/build/src/configuration.d.ts +18 -8
  62. package/build/src/configuration.d.ts.map +1 -1
  63. package/build/src/configuration.js +38 -7
  64. package/build/src/database/drivers/base-column.d.ts +5 -0
  65. package/build/src/database/drivers/base-column.d.ts.map +1 -1
  66. package/build/src/database/drivers/base-column.js +8 -1
  67. package/build/src/database/drivers/mssql/sql/update.d.ts.map +1 -1
  68. package/build/src/database/drivers/mssql/sql/update.js +2 -4
  69. package/build/src/database/drivers/mysql/sql/update.d.ts.map +1 -1
  70. package/build/src/database/drivers/mysql/sql/update.js +2 -4
  71. package/build/src/database/drivers/pgsql/column.d.ts +5 -0
  72. package/build/src/database/drivers/pgsql/column.d.ts.map +1 -1
  73. package/build/src/database/drivers/pgsql/column.js +19 -1
  74. package/build/src/database/drivers/pgsql/sql/update.d.ts.map +1 -1
  75. package/build/src/database/drivers/pgsql/sql/update.js +2 -4
  76. package/build/src/database/drivers/sqlite/sql/alter-table.d.ts.map +1 -1
  77. package/build/src/database/drivers/sqlite/sql/alter-table.js +6 -2
  78. package/build/src/database/drivers/sqlite/sql/update.d.ts.map +1 -1
  79. package/build/src/database/drivers/sqlite/sql/update.js +2 -4
  80. package/build/src/database/query/index.d.ts +4 -4
  81. package/build/src/database/query/index.d.ts.map +1 -1
  82. package/build/src/database/query/index.js +3 -3
  83. package/build/src/database/query/model-class-query.d.ts +8 -2
  84. package/build/src/database/query/model-class-query.d.ts.map +1 -1
  85. package/build/src/database/query/model-class-query.js +25 -11
  86. package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
  87. package/build/src/database/query/preloader/has-many.js +4 -2
  88. package/build/src/database/query/query-data.d.ts.map +1 -1
  89. package/build/src/database/query/query-data.js +3 -2
  90. package/build/src/database/query/update-base.d.ts +7 -0
  91. package/build/src/database/query/update-base.d.ts.map +1 -1
  92. package/build/src/database/query/update-base.js +13 -1
  93. package/build/src/database/query/with-count.d.ts.map +1 -1
  94. package/build/src/database/query/with-count.js +3 -2
  95. package/build/src/database/record/acts-as-list.d.ts.map +1 -1
  96. package/build/src/database/record/acts-as-list.js +35 -14
  97. package/build/src/database/record/attachments/store.d.ts +67 -0
  98. package/build/src/database/record/attachments/store.d.ts.map +1 -1
  99. package/build/src/database/record/attachments/store.js +301 -25
  100. package/build/src/database/record/auditing.d.ts.map +1 -1
  101. package/build/src/database/record/auditing.js +7 -4
  102. package/build/src/database/record/index.d.ts +78 -26
  103. package/build/src/database/record/index.d.ts.map +1 -1
  104. package/build/src/database/record/index.js +171 -42
  105. package/build/src/database/record/instance-relationships/belongs-to.d.ts.map +1 -1
  106. package/build/src/database/record/instance-relationships/belongs-to.js +3 -2
  107. package/build/src/database/record/validators/uniqueness.d.ts.map +1 -1
  108. package/build/src/database/record/validators/uniqueness.js +8 -6
  109. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +4 -4
  110. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
  111. package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -12
  112. package/build/src/frontend-model-controller.d.ts +29 -8
  113. package/build/src/frontend-model-controller.d.ts.map +1 -1
  114. package/build/src/frontend-model-controller.js +122 -51
  115. package/build/src/frontend-model-resource/base-resource.d.ts +51 -24
  116. package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
  117. package/build/src/frontend-model-resource/base-resource.js +83 -37
  118. package/build/src/frontend-model-resource/velocious-attachment-resource.d.ts +45 -26
  119. package/build/src/frontend-model-resource/velocious-attachment-resource.d.ts.map +1 -1
  120. package/build/src/frontend-model-resource/velocious-attachment-resource.js +89 -31
  121. package/build/src/frontend-models/base.d.ts +53 -20
  122. package/build/src/frontend-models/base.d.ts.map +1 -1
  123. package/build/src/frontend-models/base.js +275 -59
  124. package/build/src/frontend-models/preloader.d.ts.map +1 -1
  125. package/build/src/frontend-models/preloader.js +6 -4
  126. package/build/src/frontend-models/query.d.ts +2 -2
  127. package/build/src/frontend-models/query.d.ts.map +1 -1
  128. package/build/src/frontend-models/query.js +14 -7
  129. package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
  130. package/build/src/frontend-models/resource-definition.js +20 -3
  131. package/build/src/frontend-models/use-destroyed-event.d.ts +1 -1
  132. package/build/src/frontend-models/use-destroyed-event.d.ts.map +1 -1
  133. package/build/src/frontend-models/use-destroyed-event.js +2 -2
  134. package/build/src/frontend-models/use-model-class-event.d.ts +2 -2
  135. package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
  136. package/build/src/frontend-models/use-model-class-event.js +3 -3
  137. package/build/src/frontend-models/use-updated-event.d.ts +1 -1
  138. package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
  139. package/build/src/frontend-models/use-updated-event.js +2 -2
  140. package/build/src/frontend-models/websocket-channel.d.ts +60 -41
  141. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  142. package/build/src/frontend-models/websocket-channel.js +225 -85
  143. package/build/src/frontend-models/websocket-publishers.d.ts +9 -0
  144. package/build/src/frontend-models/websocket-publishers.d.ts.map +1 -1
  145. package/build/src/frontend-models/websocket-publishers.js +190 -19
  146. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  147. package/build/src/http-server/client/websocket-session.js +11 -2
  148. package/build/src/http-server/websocket-channel.d.ts +20 -8
  149. package/build/src/http-server/websocket-channel.d.ts.map +1 -1
  150. package/build/src/http-server/websocket-channel.js +15 -3
  151. package/build/src/sync/assets/cache.d.ts +288 -0
  152. package/build/src/sync/assets/cache.d.ts.map +1 -0
  153. package/build/src/sync/assets/cache.js +883 -0
  154. package/build/src/sync/assets/types.d.ts +199 -0
  155. package/build/src/sync/assets/types.d.ts.map +1 -0
  156. package/build/src/sync/assets/types.js +56 -0
  157. package/build/src/sync/sync-api-client.d.ts.map +1 -1
  158. package/build/src/sync/sync-api-client.js +4 -3
  159. package/build/src/sync/sync-client.d.ts.map +1 -1
  160. package/build/src/sync/sync-client.js +3 -2
  161. package/build/src/sync/sync-envelope-replay-service.d.ts.map +1 -1
  162. package/build/src/sync/sync-envelope-replay-service.js +6 -5
  163. package/build/src/sync/sync-publisher.d.ts.map +1 -1
  164. package/build/src/sync/sync-publisher.js +4 -3
  165. package/build/src/testing/browser-frontend-model-event-hook-scenarios.d.ts +2 -2
  166. package/build/src/testing/browser-frontend-model-event-hook-scenarios.d.ts.map +1 -1
  167. package/build/src/testing/browser-frontend-model-event-hook-scenarios.js +3 -3
  168. package/build/src/testing/test-profiler.d.ts +4 -4
  169. package/build/src/testing/test-profiler.d.ts.map +1 -1
  170. package/build/src/testing/test-profiler.js +3 -3
  171. package/build/src/testing/test-runner.d.ts +279 -117
  172. package/build/src/testing/test-runner.d.ts.map +1 -1
  173. package/build/src/testing/test-runner.js +503 -933
  174. package/build/src/testing/test.d.ts +11 -72
  175. package/build/src/testing/test.d.ts.map +1 -1
  176. package/build/src/testing/test.js +131 -284
  177. package/build/src/testing/velocious-attempt-executor.d.ts +54 -0
  178. package/build/src/testing/velocious-attempt-executor.d.ts.map +1 -0
  179. package/build/src/testing/velocious-attempt-executor.js +408 -0
  180. package/build/src/testing/velocious-runner-reporter.d.ts +67 -0
  181. package/build/src/testing/velocious-runner-reporter.d.ts.map +1 -0
  182. package/build/src/testing/velocious-runner-reporter.js +240 -0
  183. package/build/src/testing/velocious-suite-hook-executor.d.ts +19 -0
  184. package/build/src/testing/velocious-suite-hook-executor.d.ts.map +1 -0
  185. package/build/src/testing/velocious-suite-hook-executor.js +41 -0
  186. package/build/src/testing/velocious-test-arguments.d.ts +39 -0
  187. package/build/src/testing/velocious-test-arguments.d.ts.map +1 -0
  188. package/build/src/testing/velocious-test-arguments.js +55 -0
  189. package/build/src/utils/model-primary-key.d.ts +73 -0
  190. package/build/src/utils/model-primary-key.d.ts.map +1 -0
  191. package/build/src/utils/model-primary-key.js +144 -0
  192. package/build/src/utils/sha256-bytes-hex.d.ts +7 -0
  193. package/build/src/utils/sha256-bytes-hex.d.ts.map +1 -0
  194. package/build/src/utils/sha256-bytes-hex.js +117 -0
  195. package/build/src/utils/sha256-hex.d.ts +2 -4
  196. package/build/src/utils/sha256-hex.d.ts.map +1 -1
  197. package/build/src/utils/sha256-hex.js +6 -120
  198. package/build/sync/assets/cache.js +998 -0
  199. package/build/sync/assets/types.js +62 -0
  200. package/build/sync/sync-api-client.js +3 -2
  201. package/build/sync/sync-client.js +2 -1
  202. package/build/sync/sync-envelope-replay-service.js +5 -4
  203. package/build/sync/sync-publisher.js +3 -2
  204. package/build/testing/browser-frontend-model-event-hook-scenarios.js +2 -2
  205. package/build/testing/test-profiler.js +2 -2
  206. package/build/testing/test-runner.js +496 -990
  207. package/build/testing/test.js +164 -306
  208. package/build/testing/velocious-attempt-executor.js +441 -0
  209. package/build/testing/velocious-runner-reporter.js +264 -0
  210. package/build/testing/velocious-suite-hook-executor.js +43 -0
  211. package/build/testing/velocious-test-arguments.js +64 -0
  212. package/build/tsconfig.tsbuildinfo +1 -1
  213. package/build/utils/model-primary-key.js +171 -0
  214. package/build/utils/sha256-bytes-hex.js +132 -0
  215. package/build/utils/sha256-hex.js +7 -135
  216. package/package.json +5 -4
  217. package/src/authorization/ability.js +36 -13
  218. package/src/background-jobs/adapter.js +9 -0
  219. package/src/background-jobs/main.js +35 -10
  220. package/src/background-jobs/store.js +217 -38
  221. package/src/background-jobs/types.js +15 -0
  222. package/src/configuration-types.js +1 -1
  223. package/src/configuration.js +45 -9
  224. package/src/database/drivers/base-column.js +8 -0
  225. package/src/database/drivers/mssql/sql/update.js +1 -3
  226. package/src/database/drivers/mysql/sql/update.js +1 -3
  227. package/src/database/drivers/pgsql/column.js +22 -0
  228. package/src/database/drivers/pgsql/sql/update.js +1 -3
  229. package/src/database/drivers/sqlite/sql/alter-table.js +11 -1
  230. package/src/database/drivers/sqlite/sql/update.js +1 -3
  231. package/src/database/query/index.js +2 -2
  232. package/src/database/query/model-class-query.js +26 -10
  233. package/src/database/query/preloader/has-many.js +4 -1
  234. package/src/database/query/query-data.js +2 -1
  235. package/src/database/query/update-base.js +14 -0
  236. package/src/database/query/with-count.js +3 -1
  237. package/src/database/record/acts-as-list.js +37 -13
  238. package/src/database/record/attachments/store.js +336 -26
  239. package/src/database/record/auditing.js +6 -3
  240. package/src/database/record/index.js +197 -42
  241. package/src/database/record/instance-relationships/belongs-to.js +2 -1
  242. package/src/database/record/validators/uniqueness.js +8 -5
  243. package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -8
  244. package/src/frontend-model-controller.js +136 -53
  245. package/src/frontend-model-resource/base-resource.js +87 -37
  246. package/src/frontend-model-resource/velocious-attachment-resource.js +98 -31
  247. package/src/frontend-models/base.js +307 -59
  248. package/src/frontend-models/preloader.js +6 -3
  249. package/src/frontend-models/query.js +15 -6
  250. package/src/frontend-models/resource-definition.js +21 -2
  251. package/src/frontend-models/use-destroyed-event.js +1 -1
  252. package/src/frontend-models/use-model-class-event.js +2 -2
  253. package/src/frontend-models/use-updated-event.js +1 -1
  254. package/src/frontend-models/websocket-channel.js +256 -93
  255. package/src/frontend-models/websocket-publishers.js +218 -18
  256. package/src/http-server/client/websocket-session.js +13 -1
  257. package/src/http-server/websocket-channel.js +15 -2
  258. package/src/sync/assets/cache.js +998 -0
  259. package/src/sync/assets/types.js +62 -0
  260. package/src/sync/sync-api-client.js +3 -2
  261. package/src/sync/sync-client.js +2 -1
  262. package/src/sync/sync-envelope-replay-service.js +5 -4
  263. package/src/sync/sync-publisher.js +3 -2
  264. package/src/testing/browser-frontend-model-event-hook-scenarios.js +2 -2
  265. package/src/testing/test-profiler.js +2 -2
  266. package/src/testing/test-runner.js +496 -990
  267. package/src/testing/test.js +164 -306
  268. package/src/testing/velocious-attempt-executor.js +441 -0
  269. package/src/testing/velocious-runner-reporter.js +264 -0
  270. package/src/testing/velocious-suite-hook-executor.js +43 -0
  271. package/src/testing/velocious-test-arguments.js +64 -0
  272. package/src/utils/model-primary-key.js +171 -0
  273. package/src/utils/sha256-bytes-hex.js +132 -0
  274. package/src/utils/sha256-hex.js +7 -135
  275. package/build/src/testing/testing-package-adapter.d.ts +0 -9
  276. package/build/src/testing/testing-package-adapter.d.ts.map +0 -1
  277. package/build/src/testing/testing-package-adapter.js +0 -69
  278. package/build/testing/testing-package-adapter.js +0 -76
  279. package/src/testing/testing-package-adapter.js +0 -76
@@ -1,12 +1,28 @@
1
1
  // @ts-check
2
2
 
3
- import path from "path"
4
- import {fileURLToPath} from "url"
5
- import {defaultTestContext, waitForEvent} from "@velocious/testing"
3
+ import {
4
+ afterAll,
5
+ afterEach,
6
+ beforeAll,
7
+ beforeEach,
8
+ configureTests,
9
+ defaultTestContext,
10
+ describe,
11
+ fdescribe,
12
+ fit,
13
+ it,
14
+ test,
15
+ waitForEvent,
16
+ xdescribe,
17
+ xit,
18
+ xtest
19
+ } from "@velocious/testing"
6
20
  import EventEmitter from "../utils/event-emitter.js"
7
21
  import Expect from "./expect.js"
8
22
  import {arrayContaining, objectContaining} from "./expect-utils.js"
9
23
 
24
+ /** @typedef {(typeof defaultTestContext.registry.suites)[number]} PackageSuiteDeclaration */
25
+
10
26
  /**
11
27
  * VelociousTestConfig type.
12
28
  * @typedef {object} VelociousTestConfig
@@ -15,342 +31,158 @@ import {arrayContaining, objectContaining} from "./expect-utils.js"
15
31
  * @property {number} defaultTimeoutSeconds - Default timeout in seconds.
16
32
  * @property {number} failedConsoleOutputMaxLines - Maximum failed console lines to print inline.
17
33
  */
18
- /**
19
- * Tests.
20
- * @type {import("./test-runner.js").TestsArgument} */
21
- const tests = {
22
- /**
23
- * Narrows the runtime value to the documented type.
24
- * @type {import("./test-runner.js").AfterBeforeEachCallbackObjectType[]} */
25
- afterEaches: [],
26
- /**
27
- * Narrows the runtime value to the documented type.
28
- * @type {import("./test-runner.js").BeforeAfterAllCallbackObjectType[]} */
29
- afterAlls: [],
30
- args: {databaseCleaning: {transaction: true}},
31
-
32
- /**
33
- * Narrows the runtime value to the documented type.
34
- * @type {import("./test-runner.js").BeforeAfterAllCallbackObjectType[]} */
35
- beforeAlls: [],
36
- /**
37
- * Narrows the runtime value to the documented type.
38
- * @type {import("./test-runner.js").AfterBeforeEachCallbackObjectType[]} */
39
- beforeEaches: [],
40
- filePath: undefined,
41
- line: undefined,
42
- subs: {},
43
- tests: {}
44
- }
45
-
46
- const testEvents = new EventEmitter()
47
-
48
- let currentPath = [tests]
49
-
50
- /**
51
- * Runs capture location.
52
- * @returns {{filePath?: string, line?: number}} - Location.
53
- */
54
- function captureLocation() {
55
- const error = new Error()
56
- const stack = typeof error.stack === "string" ? error.stack.split("\n") : []
57
-
58
- for (const line of stack) {
59
- const trimmed = line.trim()
60
-
61
- if (!trimmed.includes("at")) continue
62
- if (trimmed.includes("/src/testing/test.js")) continue
63
- if (trimmed.includes("/@velocious/testing/")) continue
64
-
65
- const match = trimmed.match(/(?:\(|\s)(file:\/\/.*?|\/.*?):(\d+):(\d+)\)?$/)
66
-
67
- if (!match) continue
68
-
69
- const rawPath = match[1]
70
- const lineNumber = Number(match[2])
71
- const filePath = rawPath.startsWith("file://")
72
- ? fileURLToPath(rawPath)
73
- : rawPath
74
-
75
- return {
76
- filePath: path.resolve(filePath),
77
- line: Number.isFinite(lineNumber) ? lineNumber : undefined
78
- }
79
- }
80
-
81
- return {}
82
- }
83
-
84
- defaultTestContext.setDeclarationLocator(captureLocation)
85
34
 
86
35
  /**
87
- * Runs normalize tags.
88
- * @param {string[] | string | undefined} tags - Tags.
89
- * @returns {string[]} - Normalized tags.
90
- */
91
- function normalizeTags(tags) {
92
- if (!tags) return []
93
-
94
- const values = []
95
- const rawTags = Array.isArray(tags) ? tags : [tags]
96
-
97
- for (const rawTag of rawTags) {
98
- if (rawTag === undefined || rawTag === null) continue
99
-
100
- const parts = String(rawTag).split(",")
101
-
102
- for (const part of parts) {
103
- const trimmed = part.trim()
104
-
105
- if (trimmed) values.push(trimmed)
106
- }
107
- }
108
-
109
- return Array.from(new Set(values))
110
- }
111
-
112
- /**
113
- * Test config.
114
- * @type {VelociousTestConfig} */
115
- const testConfig = {
116
- consoleOutput: "failure",
117
- failedConsoleOutputMaxLines: 200,
118
- excludeTags: [],
119
- defaultTimeoutSeconds: 60
120
- }
121
-
122
- /**
123
- * Runs configure tests.
124
- * @param {object} args - Options.
125
- * @param {"failure" | "live"} [args.consoleOutput] - Console output mode.
126
- * @param {string[] | string} [args.excludeTags] - Tags to exclude.
127
- * @param {number} [args.defaultTimeoutSeconds] - Default timeout in seconds.
128
- * @param {number} [args.failedConsoleOutputMaxLines] - Maximum failed console lines to print inline.
129
- * @returns {void}
130
- */
131
- function configureTests({consoleOutput, excludeTags, defaultTimeoutSeconds, failedConsoleOutputMaxLines} = {}) {
132
- if (excludeTags !== undefined) {
133
- testConfig.excludeTags = normalizeTags(excludeTags)
134
- }
135
-
136
- if (consoleOutput !== undefined) {
137
- if (consoleOutput !== "failure" && consoleOutput !== "live") {
138
- throw new Error(`Invalid consoleOutput config: ${consoleOutput}`)
139
- }
140
-
141
- testConfig.consoleOutput = consoleOutput
142
- }
143
-
144
- if (typeof defaultTimeoutSeconds === "number") {
145
- testConfig.defaultTimeoutSeconds = defaultTimeoutSeconds
146
- }
147
-
148
- if (typeof failedConsoleOutputMaxLines === "number") {
149
- testConfig.failedConsoleOutputMaxLines = failedConsoleOutputMaxLines
150
- }
151
- }
152
-
153
- /**
154
- * Runs merge test args.
155
- * @param {Record<string, ReturnType<typeof JSON.parse>>} baseArgs - Base args.
156
- * @param {Record<string, ReturnType<typeof JSON.parse>>} extraArgs - Extra args.
157
- * @returns {Record<string, ReturnType<typeof JSON.parse>>} - Merged args.
36
+ * Runs expect.
37
+ * @param {ReturnType<typeof JSON.parse>} arg - Arg.
38
+ * @returns {Expect} - The expect.
158
39
  */
159
- function mergeTestArgs(baseArgs, extraArgs) {
160
- const merged = Object.assign({}, baseArgs, extraArgs)
161
- const mergedTags = [...normalizeTags(baseArgs?.tags), ...normalizeTags(extraArgs?.tags)]
162
-
163
- if (mergedTags.length > 0) {
164
- merged.tags = Array.from(new Set(mergedTags))
165
- } else if ("tags" in merged) {
166
- delete merged.tags
167
- }
168
-
169
- return merged
40
+ function expect(arg) {
41
+ return new Expect(arg)
170
42
  }
171
43
 
172
- /**
173
- * Runs before each.
174
- * @param {import("./test-runner.js").AfterBeforeEachCallbackType} callback - Callback function.
175
- * @returns {void} - No return value.
176
- */
177
- function beforeEach(callback) {
178
- const currentTest = currentPath[currentPath.length - 1]
44
+ expect.objectContaining = objectContaining
45
+ expect.arrayContaining = arrayContaining
179
46
 
180
- currentTest.beforeEaches.push({callback})
181
- }
47
+ /** Velocious-owned awaited compatibility events. */
48
+ const testEvents = new EventEmitter()
182
49
 
183
50
  /**
184
- * Runs before all.
185
- * @param {import("./test-runner.js").BeforeAfterAllCallbackType} callback - Callback function.
186
- * @returns {void} - No return value.
51
+ * Detaches and freezes declaration metadata exposed by the compatibility view.
52
+ * @param {ReturnType<typeof JSON.parse>} value - Package declaration value.
53
+ * @returns {ReturnType<typeof JSON.parse>} - Immutable detached value.
187
54
  */
188
- function beforeAll(callback) {
189
- const currentTest = currentPath[currentPath.length - 1]
55
+ function readOnlySnapshot(value) {
56
+ if (Array.isArray(value)) return Object.freeze(value.map((entry) => readOnlySnapshot(entry)))
57
+ if (value === null || typeof value !== "object") return value
190
58
 
191
- currentTest.beforeAlls.push({callback})
192
- }
59
+ /** @type {Record<string, ReturnType<typeof JSON.parse>>} */
60
+ const projectedValue = {}
193
61
 
194
- /**
195
- * Runs after each.
196
- * @param {import("./test-runner.js").AfterBeforeEachCallbackType} callback - Callback function.
197
- * @returns {void} - No return value.
198
- */
199
- function afterEach(callback) {
200
- const currentTest = currentPath[currentPath.length - 1]
62
+ for (const [key, entry] of Object.entries(value)) projectedValue[key] = readOnlySnapshot(entry)
201
63
 
202
- currentTest.afterEaches.push({callback})
64
+ return Object.freeze(projectedValue)
203
65
  }
204
66
 
205
67
  /**
206
- * Runs after all.
207
- * @param {import("./test-runner.js").BeforeAfterAllCallbackType} callback - Callback function.
208
- * @returns {void} - No return value.
68
+ * Backward-compatible view of the package configuration.
69
+ * @type {VelociousTestConfig}
209
70
  */
210
- function afterAll(callback) {
211
- const currentTest = currentPath[currentPath.length - 1]
212
-
213
- currentTest.afterAlls.push({callback})
71
+ const testConfig = {
72
+ get consoleOutput() { return defaultTestContext.config.consoleOutput },
73
+ set consoleOutput(value) { defaultTestContext.configureTests({consoleOutput: value}) },
74
+ get excludeTags() { return defaultTestContext.config.excludeTags },
75
+ set excludeTags(value) { defaultTestContext.configureTests({excludeTags: value}) },
76
+ get defaultTimeoutSeconds() { return defaultTestContext.config.defaultTimeoutMs / 1000 },
77
+ set defaultTimeoutSeconds(value) { defaultTestContext.configureTests({defaultTimeoutSeconds: value}) },
78
+ get failedConsoleOutputMaxLines() { return defaultTestContext.config.failedConsoleOutputMaxLines },
79
+ set failedConsoleOutputMaxLines(value) { defaultTestContext.configureTests({failedConsoleOutputMaxLines: value}) }
214
80
  }
215
81
 
216
82
  /**
217
- * Runs describe.
218
- * @param {string} description - Description.
219
- * @param {object|(() => (void|Promise<void>))} arg1 - Arg1.
220
- * @param {undefined|(() => (void|Promise<void>))} [arg2] - Arg2.
221
- * @returns {Promise<void>} - Resolves when complete.
83
+ * Projects one package suite into the deprecated legacy inspection shape.
84
+ * The returned objects are snapshots and never participate in execution.
85
+ * @param {PackageSuiteDeclaration} suite - Package declaration.
86
+ * @returns {import("./test-runner.js").TestsArgument} - Read-only compatibility snapshot.
222
87
  */
223
- async function describe(description, arg1, arg2) {
224
- /**
225
- * Defines testArgs.
226
- * @type {Record<string, ReturnType<typeof JSON.parse>>} */
227
- let testArgs, testFunction
228
-
229
- if (typeof arg2 == "function") {
230
- testFunction = arg2
231
- testArgs = arg1
232
- } else if (typeof arg1 == "function") {
233
- testFunction = arg1
234
- testArgs = {}
235
- } else {
236
- throw new Error(`Invalid arguments for describe: ${arg1}, ${arg2}`)
237
- }
238
-
239
- const currentTest = currentPath[currentPath.length - 1]
240
- const newTestArgs = mergeTestArgs(currentTest.args, testArgs)
241
-
242
- if (description in currentTest.subs) {
243
- throw new Error(`Duplicate test description: ${description}`)
88
+ function projectSuite(suite) {
89
+ /** @type {Record<string, import("./test-runner.js").TestData>} */
90
+ const projectedTests = {}
91
+ /** @type {Record<string, import("./test-runner.js").TestsArgument>} */
92
+ const projectedSuites = {}
93
+
94
+ for (const declaration of suite.tests) {
95
+ const mutableArgs = {...declaration.options}
96
+
97
+ if (mutableArgs.retry === undefined && typeof mutableArgs.retries === "number") mutableArgs.retry = mutableArgs.retries
98
+ if (mutableArgs.timeoutSeconds === undefined && typeof mutableArgs.timeoutMs === "number") mutableArgs.timeoutSeconds = mutableArgs.timeoutMs / 1000
99
+ projectedTests[declaration.name] = Object.freeze({
100
+ args: readOnlySnapshot(mutableArgs),
101
+ filePath: declaration.location.filePath,
102
+ function: declaration.callback,
103
+ line: declaration.location.line
104
+ })
244
105
  }
245
106
 
246
- const location = captureLocation()
247
- const newTestData = {
248
- afterEaches: [],
249
- afterAlls: [],
250
- args: newTestArgs,
251
- beforeAlls: [],
252
- beforeEaches: [],
253
- filePath: location.filePath,
254
- line: location.line,
255
- subs: {},
256
- tests: {}
107
+ for (const child of suite.suites) projectedSuites[child.name] = projectSuite(child)
108
+
109
+ const projection = {
110
+ afterAlls: Object.freeze(suite.hooks.afterAll.map((hook) => Object.freeze({callback: hook.callback}))),
111
+ afterEaches: Object.freeze(suite.hooks.afterEach.map((hook) => Object.freeze({callback: hook.callback}))),
112
+ args: readOnlySnapshot(suite.options),
113
+ beforeAlls: Object.freeze(suite.hooks.beforeAll.map((hook) => Object.freeze({callback: hook.callback}))),
114
+ beforeEaches: Object.freeze(suite.hooks.beforeEach.map((hook) => Object.freeze({callback: hook.callback}))),
115
+ filePath: suite.location.filePath,
116
+ line: suite.location.line,
117
+ subs: Object.freeze(projectedSuites),
118
+ tests: Object.freeze(projectedTests)
257
119
  }
258
120
 
259
- currentTest.subs[description] = newTestData
260
- currentPath.push(newTestData)
261
-
262
- try {
263
- await testFunction()
264
- } finally {
265
- currentPath.pop()
266
- }
267
- }
268
-
269
- /**
270
- * Runs expect.
271
- * @param {ReturnType<typeof JSON.parse>} arg - Arg.
272
- * @returns {Expect} - The expect.
273
- */
274
- function expect(arg) {
275
- return new Expect(arg)
121
+ // Narrows the immutable snapshot to the historical inspection contract.
122
+ return /** @type {import("./test-runner.js").TestsArgument} */ (Object.freeze(projection))
276
123
  }
277
124
 
278
- expect.objectContaining = objectContaining
279
- expect.arrayContaining = arrayContaining
280
-
281
125
  /**
282
- * Runs it.
283
- * @param {string} description - Description.
284
- * @param {object|(() => (void|Promise<void>))} arg1 - Arg1.
285
- * @param {undefined|(() => (void|Promise<void>))} [arg2] - Arg2.
286
- * @returns {void} - No return value.
126
+ * Deprecated read-only declaration projection. Package declarations in
127
+ * defaultTestContext are the sole execution source.
287
128
  */
288
- function it(description, arg1, arg2) {
289
- const currentTest = currentPath[currentPath.length - 1]
290
- /**
291
- * Defines testArgs.
292
- * @type {Record<string, ReturnType<typeof JSON.parse>>} */
293
- let testArgs
294
-
295
- /**
296
- * Defines testFunction.
297
- * @type {() => (void|Promise<void>)} */
298
- let testFunction
299
-
300
- if (typeof arg1 == "function") {
301
- testFunction = /** @type {() => (void|Promise<void>)} */ (arg1)
302
- testArgs = {}
303
- } else if (typeof arg2 == "function") {
304
- testFunction = /** @type {() => (void|Promise<void>)} */ (arg2)
305
- testArgs = arg1
306
- } else {
307
- throw new Error(`Invalid arguments for it: ${description}, ${arg1}`)
308
- }
129
+ /** @type {import("./test-runner.js").BeforeAfterAllCallbackObjectType[]} */
130
+ const emptyAfterAlls = []
131
+ /** @type {import("./test-runner.js").AfterBeforeEachCallbackObjectType[]} */
132
+ const emptyAfterEaches = []
133
+ /** @type {import("./test-runner.js").BeforeAfterAllCallbackObjectType[]} */
134
+ const emptyBeforeAlls = []
135
+ /** @type {import("./test-runner.js").AfterBeforeEachCallbackObjectType[]} */
136
+ const emptyBeforeEaches = []
137
+ const defaultTestArguments = {databaseCleaning: {transaction: true}}
138
+
139
+ Object.freeze(emptyAfterAlls)
140
+ Object.freeze(emptyAfterEaches)
141
+ Object.freeze(emptyBeforeAlls)
142
+ Object.freeze(emptyBeforeEaches)
143
+ Object.freeze(defaultTestArguments.databaseCleaning)
144
+ Object.freeze(defaultTestArguments)
145
+
146
+ const testsProjection = {
147
+ get afterAlls() { return emptyAfterAlls },
148
+ get afterEaches() { return emptyAfterEaches },
149
+ get args() { return defaultTestArguments },
150
+ get beforeAlls() { return emptyBeforeAlls },
151
+ get beforeEaches() { return emptyBeforeEaches },
152
+ get filePath() { return undefined },
153
+ get line() { return undefined },
154
+ get subs() {
155
+ /** @type {Record<string, import("./test-runner.js").TestsArgument>} */
156
+ const projectedSuites = {}
157
+
158
+ for (const suite of defaultTestContext.registry.suites) {
159
+ if (suite.name === "") {
160
+ for (const childSuite of suite.suites) projectedSuites[childSuite.name] = projectSuite(childSuite)
161
+ } else {
162
+ projectedSuites[suite.name] = projectSuite(suite)
163
+ }
164
+ }
309
165
 
310
- const newTestArgs = mergeTestArgs(currentTest.args, testArgs)
166
+ return Object.freeze(projectedSuites)
167
+ },
168
+ get tests() {
169
+ /** @type {Record<string, import("./test-runner.js").TestData>} */
170
+ const projectedTests = {}
311
171
 
312
- const location = captureLocation()
172
+ for (const suite of defaultTestContext.registry.suites) {
173
+ if (suite.name !== "") continue
313
174
 
314
- currentTest.tests[description] = {
315
- args: newTestArgs,
316
- function: testFunction,
317
- filePath: location.filePath,
318
- line: location.line
319
- }
320
- }
321
-
322
- /**
323
- * Runs fit.
324
- * @param {string} description - Description.
325
- * @param {object|(() => (void|Promise<void>))} arg1 - Arg1.
326
- * @param {undefined|(() => (void|Promise<void>))} [arg2] - Arg2.
327
- * @returns {void} - No return value.
328
- */
329
- function fit(description, arg1, arg2) {
330
- /**
331
- * Defines testArgs.
332
- * @type {Record<string, ReturnType<typeof JSON.parse>>} */
333
- let testArgs
334
-
335
- /**
336
- * Defines testFunction.
337
- * @type {() => (void|Promise<void>)} */
338
- let testFunction
175
+ Object.assign(projectedTests, projectSuite(suite).tests)
176
+ }
339
177
 
340
- if (typeof arg1 == "function") {
341
- testFunction = /** @type {() => (void|Promise<void>)} */ (arg1)
342
- testArgs = {focus: true}
343
- } else if (typeof arg2 == "function") {
344
- testFunction = /** @type {() => (void|Promise<void>)} */ (arg2)
345
- testArgs = Object.assign({focus: true}, arg1)
346
- } else {
347
- throw new Error(`Invalid arguments for it: ${description}, ${arg1}`)
178
+ return Object.freeze(projectedTests)
348
179
  }
349
-
350
- return it(description, testArgs, testFunction)
351
180
  }
181
+ /** @type {import("./test-runner.js").TestsArgument} */
182
+ const tests = testsProjection
183
+ Object.freeze(tests)
352
184
 
353
- // Make the methods global so they can be used in test files
185
+ // Make the compatibility facade global so existing test files remain source-compatible.
354
186
  Object.assign(globalThis, {
355
187
  afterAll,
356
188
  afterEach,
@@ -359,9 +191,35 @@ Object.assign(globalThis, {
359
191
  configureTests,
360
192
  describe,
361
193
  expect,
194
+ fdescribe,
362
195
  fit,
363
196
  it,
364
- testEvents
197
+ test,
198
+ testEvents,
199
+ xdescribe,
200
+ xit,
201
+ xtest
365
202
  })
366
203
 
367
- export {afterAll, afterEach, beforeAll, beforeEach, configureTests, describe, expect, fit, it, arrayContaining, objectContaining, testConfig, testEvents, tests, waitForEvent}
204
+ export {
205
+ afterAll,
206
+ afterEach,
207
+ beforeAll,
208
+ beforeEach,
209
+ configureTests,
210
+ describe,
211
+ expect,
212
+ fdescribe,
213
+ fit,
214
+ it,
215
+ test,
216
+ xdescribe,
217
+ xit,
218
+ xtest,
219
+ arrayContaining,
220
+ objectContaining,
221
+ testConfig,
222
+ testEvents,
223
+ tests,
224
+ waitForEvent
225
+ }