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.
- package/README.md +21 -10
- package/build/authorization/ability.js +36 -13
- package/build/background-jobs/adapter.js +9 -0
- package/build/background-jobs/main.js +35 -10
- package/build/background-jobs/store.js +217 -38
- package/build/background-jobs/types.js +15 -0
- package/build/configuration-types.js +1 -1
- package/build/configuration.js +45 -9
- package/build/database/drivers/base-column.js +8 -0
- package/build/database/drivers/mssql/sql/update.js +1 -3
- package/build/database/drivers/mysql/sql/update.js +1 -3
- package/build/database/drivers/pgsql/column.js +22 -0
- package/build/database/drivers/pgsql/sql/update.js +1 -3
- package/build/database/drivers/sqlite/sql/alter-table.js +11 -1
- package/build/database/drivers/sqlite/sql/update.js +1 -3
- package/build/database/query/index.js +2 -2
- package/build/database/query/model-class-query.js +26 -10
- package/build/database/query/preloader/has-many.js +4 -1
- package/build/database/query/query-data.js +2 -1
- package/build/database/query/update-base.js +14 -0
- package/build/database/query/with-count.js +3 -1
- package/build/database/record/acts-as-list.js +37 -13
- package/build/database/record/attachments/store.js +336 -26
- package/build/database/record/auditing.js +6 -3
- package/build/database/record/index.js +197 -42
- package/build/database/record/instance-relationships/belongs-to.js +2 -1
- package/build/database/record/validators/uniqueness.js +8 -5
- package/build/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -8
- package/build/frontend-model-controller.js +136 -53
- package/build/frontend-model-resource/base-resource.js +87 -37
- package/build/frontend-model-resource/velocious-attachment-resource.js +98 -31
- package/build/frontend-models/base.js +307 -59
- package/build/frontend-models/preloader.js +6 -3
- package/build/frontend-models/query.js +15 -6
- package/build/frontend-models/resource-definition.js +21 -2
- package/build/frontend-models/use-destroyed-event.js +1 -1
- package/build/frontend-models/use-model-class-event.js +2 -2
- package/build/frontend-models/use-updated-event.js +1 -1
- package/build/frontend-models/websocket-channel.js +256 -93
- package/build/frontend-models/websocket-publishers.js +218 -18
- package/build/http-server/client/websocket-session.js +13 -1
- package/build/http-server/websocket-channel.js +15 -2
- package/build/src/authorization/ability.d.ts +9 -3
- package/build/src/authorization/ability.d.ts.map +1 -1
- package/build/src/authorization/ability.js +33 -14
- package/build/src/background-jobs/adapter.d.ts +6 -0
- package/build/src/background-jobs/adapter.d.ts.map +1 -1
- package/build/src/background-jobs/adapter.js +9 -1
- package/build/src/background-jobs/main.d.ts +6 -0
- package/build/src/background-jobs/main.d.ts.map +1 -1
- package/build/src/background-jobs/main.js +34 -11
- package/build/src/background-jobs/store.d.ts +66 -12
- package/build/src/background-jobs/store.d.ts.map +1 -1
- package/build/src/background-jobs/store.js +191 -35
- package/build/src/background-jobs/types.d.ts +55 -0
- package/build/src/background-jobs/types.d.ts.map +1 -1
- package/build/src/background-jobs/types.js +16 -1
- package/build/src/configuration-types.d.ts +3 -3
- package/build/src/configuration-types.d.ts.map +1 -1
- package/build/src/configuration-types.js +2 -2
- package/build/src/configuration.d.ts +18 -8
- package/build/src/configuration.d.ts.map +1 -1
- package/build/src/configuration.js +38 -7
- package/build/src/database/drivers/base-column.d.ts +5 -0
- package/build/src/database/drivers/base-column.d.ts.map +1 -1
- package/build/src/database/drivers/base-column.js +8 -1
- package/build/src/database/drivers/mssql/sql/update.d.ts.map +1 -1
- package/build/src/database/drivers/mssql/sql/update.js +2 -4
- package/build/src/database/drivers/mysql/sql/update.d.ts.map +1 -1
- package/build/src/database/drivers/mysql/sql/update.js +2 -4
- package/build/src/database/drivers/pgsql/column.d.ts +5 -0
- package/build/src/database/drivers/pgsql/column.d.ts.map +1 -1
- package/build/src/database/drivers/pgsql/column.js +19 -1
- package/build/src/database/drivers/pgsql/sql/update.d.ts.map +1 -1
- package/build/src/database/drivers/pgsql/sql/update.js +2 -4
- package/build/src/database/drivers/sqlite/sql/alter-table.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/sql/alter-table.js +6 -2
- package/build/src/database/drivers/sqlite/sql/update.d.ts.map +1 -1
- package/build/src/database/drivers/sqlite/sql/update.js +2 -4
- package/build/src/database/query/index.d.ts +4 -4
- package/build/src/database/query/index.d.ts.map +1 -1
- package/build/src/database/query/index.js +3 -3
- package/build/src/database/query/model-class-query.d.ts +8 -2
- package/build/src/database/query/model-class-query.d.ts.map +1 -1
- package/build/src/database/query/model-class-query.js +25 -11
- package/build/src/database/query/preloader/has-many.d.ts.map +1 -1
- package/build/src/database/query/preloader/has-many.js +4 -2
- package/build/src/database/query/query-data.d.ts.map +1 -1
- package/build/src/database/query/query-data.js +3 -2
- package/build/src/database/query/update-base.d.ts +7 -0
- package/build/src/database/query/update-base.d.ts.map +1 -1
- package/build/src/database/query/update-base.js +13 -1
- package/build/src/database/query/with-count.d.ts.map +1 -1
- package/build/src/database/query/with-count.js +3 -2
- package/build/src/database/record/acts-as-list.d.ts.map +1 -1
- package/build/src/database/record/acts-as-list.js +35 -14
- package/build/src/database/record/attachments/store.d.ts +67 -0
- package/build/src/database/record/attachments/store.d.ts.map +1 -1
- package/build/src/database/record/attachments/store.js +301 -25
- package/build/src/database/record/auditing.d.ts.map +1 -1
- package/build/src/database/record/auditing.js +7 -4
- package/build/src/database/record/index.d.ts +78 -26
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +171 -42
- package/build/src/database/record/instance-relationships/belongs-to.d.ts.map +1 -1
- package/build/src/database/record/instance-relationships/belongs-to.js +3 -2
- package/build/src/database/record/validators/uniqueness.d.ts.map +1 -1
- package/build/src/database/record/validators/uniqueness.js +8 -6
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts +4 -4
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.d.ts.map +1 -1
- package/build/src/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -12
- package/build/src/frontend-model-controller.d.ts +29 -8
- package/build/src/frontend-model-controller.d.ts.map +1 -1
- package/build/src/frontend-model-controller.js +122 -51
- package/build/src/frontend-model-resource/base-resource.d.ts +51 -24
- package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
- package/build/src/frontend-model-resource/base-resource.js +83 -37
- package/build/src/frontend-model-resource/velocious-attachment-resource.d.ts +45 -26
- package/build/src/frontend-model-resource/velocious-attachment-resource.d.ts.map +1 -1
- package/build/src/frontend-model-resource/velocious-attachment-resource.js +89 -31
- package/build/src/frontend-models/base.d.ts +53 -20
- package/build/src/frontend-models/base.d.ts.map +1 -1
- package/build/src/frontend-models/base.js +275 -59
- package/build/src/frontend-models/preloader.d.ts.map +1 -1
- package/build/src/frontend-models/preloader.js +6 -4
- package/build/src/frontend-models/query.d.ts +2 -2
- package/build/src/frontend-models/query.d.ts.map +1 -1
- package/build/src/frontend-models/query.js +14 -7
- package/build/src/frontend-models/resource-definition.d.ts.map +1 -1
- package/build/src/frontend-models/resource-definition.js +20 -3
- package/build/src/frontend-models/use-destroyed-event.d.ts +1 -1
- package/build/src/frontend-models/use-destroyed-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-destroyed-event.js +2 -2
- package/build/src/frontend-models/use-model-class-event.d.ts +2 -2
- package/build/src/frontend-models/use-model-class-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-model-class-event.js +3 -3
- package/build/src/frontend-models/use-updated-event.d.ts +1 -1
- package/build/src/frontend-models/use-updated-event.d.ts.map +1 -1
- package/build/src/frontend-models/use-updated-event.js +2 -2
- package/build/src/frontend-models/websocket-channel.d.ts +60 -41
- package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
- package/build/src/frontend-models/websocket-channel.js +225 -85
- package/build/src/frontend-models/websocket-publishers.d.ts +9 -0
- package/build/src/frontend-models/websocket-publishers.d.ts.map +1 -1
- package/build/src/frontend-models/websocket-publishers.js +190 -19
- package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
- package/build/src/http-server/client/websocket-session.js +11 -2
- package/build/src/http-server/websocket-channel.d.ts +20 -8
- package/build/src/http-server/websocket-channel.d.ts.map +1 -1
- package/build/src/http-server/websocket-channel.js +15 -3
- package/build/src/sync/assets/cache.d.ts +288 -0
- package/build/src/sync/assets/cache.d.ts.map +1 -0
- package/build/src/sync/assets/cache.js +883 -0
- package/build/src/sync/assets/types.d.ts +199 -0
- package/build/src/sync/assets/types.d.ts.map +1 -0
- package/build/src/sync/assets/types.js +56 -0
- package/build/src/sync/sync-api-client.d.ts.map +1 -1
- package/build/src/sync/sync-api-client.js +4 -3
- package/build/src/sync/sync-client.d.ts.map +1 -1
- package/build/src/sync/sync-client.js +3 -2
- package/build/src/sync/sync-envelope-replay-service.d.ts.map +1 -1
- package/build/src/sync/sync-envelope-replay-service.js +6 -5
- package/build/src/sync/sync-publisher.d.ts.map +1 -1
- package/build/src/sync/sync-publisher.js +4 -3
- package/build/src/testing/browser-frontend-model-event-hook-scenarios.d.ts +2 -2
- package/build/src/testing/browser-frontend-model-event-hook-scenarios.d.ts.map +1 -1
- package/build/src/testing/browser-frontend-model-event-hook-scenarios.js +3 -3
- package/build/src/testing/test-profiler.d.ts +4 -4
- package/build/src/testing/test-profiler.d.ts.map +1 -1
- package/build/src/testing/test-profiler.js +3 -3
- package/build/src/testing/test-runner.d.ts +279 -117
- package/build/src/testing/test-runner.d.ts.map +1 -1
- package/build/src/testing/test-runner.js +503 -933
- package/build/src/testing/test.d.ts +11 -72
- package/build/src/testing/test.d.ts.map +1 -1
- package/build/src/testing/test.js +131 -284
- package/build/src/testing/velocious-attempt-executor.d.ts +54 -0
- package/build/src/testing/velocious-attempt-executor.d.ts.map +1 -0
- package/build/src/testing/velocious-attempt-executor.js +408 -0
- package/build/src/testing/velocious-runner-reporter.d.ts +67 -0
- package/build/src/testing/velocious-runner-reporter.d.ts.map +1 -0
- package/build/src/testing/velocious-runner-reporter.js +240 -0
- package/build/src/testing/velocious-suite-hook-executor.d.ts +19 -0
- package/build/src/testing/velocious-suite-hook-executor.d.ts.map +1 -0
- package/build/src/testing/velocious-suite-hook-executor.js +41 -0
- package/build/src/testing/velocious-test-arguments.d.ts +39 -0
- package/build/src/testing/velocious-test-arguments.d.ts.map +1 -0
- package/build/src/testing/velocious-test-arguments.js +55 -0
- package/build/src/utils/model-primary-key.d.ts +73 -0
- package/build/src/utils/model-primary-key.d.ts.map +1 -0
- package/build/src/utils/model-primary-key.js +144 -0
- package/build/src/utils/sha256-bytes-hex.d.ts +7 -0
- package/build/src/utils/sha256-bytes-hex.d.ts.map +1 -0
- package/build/src/utils/sha256-bytes-hex.js +117 -0
- package/build/src/utils/sha256-hex.d.ts +2 -4
- package/build/src/utils/sha256-hex.d.ts.map +1 -1
- package/build/src/utils/sha256-hex.js +6 -120
- package/build/sync/assets/cache.js +998 -0
- package/build/sync/assets/types.js +62 -0
- package/build/sync/sync-api-client.js +3 -2
- package/build/sync/sync-client.js +2 -1
- package/build/sync/sync-envelope-replay-service.js +5 -4
- package/build/sync/sync-publisher.js +3 -2
- package/build/testing/browser-frontend-model-event-hook-scenarios.js +2 -2
- package/build/testing/test-profiler.js +2 -2
- package/build/testing/test-runner.js +496 -990
- package/build/testing/test.js +164 -306
- package/build/testing/velocious-attempt-executor.js +441 -0
- package/build/testing/velocious-runner-reporter.js +264 -0
- package/build/testing/velocious-suite-hook-executor.js +43 -0
- package/build/testing/velocious-test-arguments.js +64 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/utils/model-primary-key.js +171 -0
- package/build/utils/sha256-bytes-hex.js +132 -0
- package/build/utils/sha256-hex.js +7 -135
- package/package.json +5 -4
- package/src/authorization/ability.js +36 -13
- package/src/background-jobs/adapter.js +9 -0
- package/src/background-jobs/main.js +35 -10
- package/src/background-jobs/store.js +217 -38
- package/src/background-jobs/types.js +15 -0
- package/src/configuration-types.js +1 -1
- package/src/configuration.js +45 -9
- package/src/database/drivers/base-column.js +8 -0
- package/src/database/drivers/mssql/sql/update.js +1 -3
- package/src/database/drivers/mysql/sql/update.js +1 -3
- package/src/database/drivers/pgsql/column.js +22 -0
- package/src/database/drivers/pgsql/sql/update.js +1 -3
- package/src/database/drivers/sqlite/sql/alter-table.js +11 -1
- package/src/database/drivers/sqlite/sql/update.js +1 -3
- package/src/database/query/index.js +2 -2
- package/src/database/query/model-class-query.js +26 -10
- package/src/database/query/preloader/has-many.js +4 -1
- package/src/database/query/query-data.js +2 -1
- package/src/database/query/update-base.js +14 -0
- package/src/database/query/with-count.js +3 -1
- package/src/database/record/acts-as-list.js +37 -13
- package/src/database/record/attachments/store.js +336 -26
- package/src/database/record/auditing.js +6 -3
- package/src/database/record/index.js +197 -42
- package/src/database/record/instance-relationships/belongs-to.js +2 -1
- package/src/database/record/validators/uniqueness.js +8 -5
- package/src/environment-handlers/node/cli/commands/generate/frontend-models.js +24 -8
- package/src/frontend-model-controller.js +136 -53
- package/src/frontend-model-resource/base-resource.js +87 -37
- package/src/frontend-model-resource/velocious-attachment-resource.js +98 -31
- package/src/frontend-models/base.js +307 -59
- package/src/frontend-models/preloader.js +6 -3
- package/src/frontend-models/query.js +15 -6
- package/src/frontend-models/resource-definition.js +21 -2
- package/src/frontend-models/use-destroyed-event.js +1 -1
- package/src/frontend-models/use-model-class-event.js +2 -2
- package/src/frontend-models/use-updated-event.js +1 -1
- package/src/frontend-models/websocket-channel.js +256 -93
- package/src/frontend-models/websocket-publishers.js +218 -18
- package/src/http-server/client/websocket-session.js +13 -1
- package/src/http-server/websocket-channel.js +15 -2
- package/src/sync/assets/cache.js +998 -0
- package/src/sync/assets/types.js +62 -0
- package/src/sync/sync-api-client.js +3 -2
- package/src/sync/sync-client.js +2 -1
- package/src/sync/sync-envelope-replay-service.js +5 -4
- package/src/sync/sync-publisher.js +3 -2
- package/src/testing/browser-frontend-model-event-hook-scenarios.js +2 -2
- package/src/testing/test-profiler.js +2 -2
- package/src/testing/test-runner.js +496 -990
- package/src/testing/test.js +164 -306
- package/src/testing/velocious-attempt-executor.js +441 -0
- package/src/testing/velocious-runner-reporter.js +264 -0
- package/src/testing/velocious-suite-hook-executor.js +43 -0
- package/src/testing/velocious-test-arguments.js +64 -0
- package/src/utils/model-primary-key.js +171 -0
- package/src/utils/sha256-bytes-hex.js +132 -0
- package/src/utils/sha256-hex.js +7 -135
- package/build/src/testing/testing-package-adapter.d.ts +0 -9
- package/build/src/testing/testing-package-adapter.d.ts.map +0 -1
- package/build/src/testing/testing-package-adapter.js +0 -69
- package/build/testing/testing-package-adapter.js +0 -76
- package/src/testing/testing-package-adapter.js +0 -76
package/build/testing/test.js
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
88
|
-
* @param {
|
|
89
|
-
* @returns {
|
|
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
|
|
160
|
-
|
|
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
|
-
|
|
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
|
-
|
|
181
|
-
|
|
47
|
+
/** Velocious-owned awaited compatibility events. */
|
|
48
|
+
const testEvents = new EventEmitter()
|
|
182
49
|
|
|
183
50
|
/**
|
|
184
|
-
*
|
|
185
|
-
* @param {
|
|
186
|
-
* @returns {
|
|
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
|
|
189
|
-
|
|
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
|
-
|
|
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
|
-
|
|
64
|
+
return Object.freeze(projectedValue)
|
|
203
65
|
}
|
|
204
66
|
|
|
205
67
|
/**
|
|
206
|
-
*
|
|
207
|
-
* @
|
|
208
|
-
* @returns {void} - No return value.
|
|
68
|
+
* Backward-compatible view of the package configuration.
|
|
69
|
+
* @type {VelociousTestConfig}
|
|
209
70
|
*/
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* @param {
|
|
220
|
-
* @
|
|
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
|
-
|
|
224
|
-
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
afterAlls:
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
260
|
-
|
|
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
|
-
*
|
|
283
|
-
*
|
|
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
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
166
|
+
return Object.freeze(projectedSuites)
|
|
167
|
+
},
|
|
168
|
+
get tests() {
|
|
169
|
+
/** @type {Record<string, import("./test-runner.js").TestData>} */
|
|
170
|
+
const projectedTests = {}
|
|
311
171
|
|
|
312
|
-
|
|
172
|
+
for (const suite of defaultTestContext.registry.suites) {
|
|
173
|
+
if (suite.name !== "") continue
|
|
313
174
|
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
197
|
+
test,
|
|
198
|
+
testEvents,
|
|
199
|
+
xdescribe,
|
|
200
|
+
xit,
|
|
201
|
+
xtest
|
|
365
202
|
})
|
|
366
203
|
|
|
367
|
-
export {
|
|
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
|
+
}
|