@travetto/test 7.0.0-rc.4 → 7.0.0-rc.5
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 +13 -15
- package/package.json +9 -8
- package/src/consumer/registry-adapter.ts +0 -1
- package/src/consumer/types/tap.ts +0 -1
- package/src/decorator/suite.ts +1 -0
- package/src/execute/run.ts +2 -1
- package/src/model/test.ts +0 -1
- package/src/worker/types.ts +0 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This module provides unit testing functionality that integrates with the framewo
|
|
|
21
21
|
**Note**: All tests should be under the `**/*` folders. The pattern for tests is defined as as a standard glob using [Node](https://nodejs.org)'s built in globbing support.
|
|
22
22
|
|
|
23
23
|
## Definition
|
|
24
|
-
A test suite is a collection of individual tests. All test suites are classes with the [@Suite](https://github.com/travetto/travetto/tree/main/module/test/src/decorator/suite.ts#
|
|
24
|
+
A test suite is a collection of individual tests. All test suites are classes with the [@Suite](https://github.com/travetto/travetto/tree/main/module/test/src/decorator/suite.ts#L15) decorator. Tests are defined as methods on the suite class, using the [@Test](https://github.com/travetto/travetto/tree/main/module/test/src/decorator/test.ts#L25) decorator. All tests intrinsically support `async`/`await`.
|
|
25
25
|
|
|
26
26
|
A simple example would be:
|
|
27
27
|
|
|
@@ -76,17 +76,15 @@ would translate to:
|
|
|
76
76
|
|
|
77
77
|
**Code: Transpiled test Code**
|
|
78
78
|
```javascript
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const Δfunction = tslib_1.__importStar(require("@travetto/runtime/src/function.js"));
|
|
86
|
-
const Δschema = tslib_1.__importStar(require("@travetto/schema/src/decorator/schema.js"));
|
|
79
|
+
import { __decorate } from "tslib";
|
|
80
|
+
import * as Δmethod from "@travetto/schema/src/decorator/method.js";
|
|
81
|
+
import * as Δdebug from "@travetto/runtime/src/debug.js";
|
|
82
|
+
import * as Δcheck from "@travetto/test/src/assert/check.js";
|
|
83
|
+
import * as Δfunction from "@travetto/runtime/src/function.js";
|
|
84
|
+
import * as Δschema from "@travetto/schema/src/decorator/schema.js";
|
|
87
85
|
var mod_1 = ["@travetto/test", "doc/assert-example.ts"];
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
import assert from 'node:assert';
|
|
87
|
+
import { Suite, Test } from '@travetto/test';
|
|
90
88
|
let SimpleTest = class SimpleTest {
|
|
91
89
|
static { Δfunction.registerFunction(SimpleTest, mod_1, { hash: 1887908328, lines: [5, 12] }, { test: { hash: 102834457, lines: [8, 11, 10] } }, false); }
|
|
92
90
|
async test() {
|
|
@@ -95,12 +93,12 @@ let SimpleTest = class SimpleTest {
|
|
|
95
93
|
Δcheck.AssertCheck.check({ module: mod_1, line: 10, text: "{ size: 20, address: { state: 'VA' } }", operator: "deepStrictEqual" }, true, { size: 20, address: { state: 'VA' } }, {});
|
|
96
94
|
}
|
|
97
95
|
};
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
__decorate([
|
|
97
|
+
Test(),
|
|
100
98
|
Δmethod.Method({ returnType: {} })
|
|
101
99
|
], SimpleTest.prototype, "test", null);
|
|
102
|
-
SimpleTest =
|
|
103
|
-
|
|
100
|
+
SimpleTest = __decorate([
|
|
101
|
+
Suite(),
|
|
104
102
|
Δschema.Schema()
|
|
105
103
|
], SimpleTest);
|
|
106
104
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/test",
|
|
3
|
-
"version": "7.0.0-rc.
|
|
3
|
+
"version": "7.0.0-rc.5",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Declarative test framework",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"unit-testing",
|
|
@@ -27,15 +28,15 @@
|
|
|
27
28
|
"directory": "module/test"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@travetto/registry": "^7.0.0-rc.
|
|
31
|
-
"@travetto/runtime": "^7.0.0-rc.
|
|
32
|
-
"@travetto/terminal": "^7.0.0-rc.
|
|
33
|
-
"@travetto/worker": "^7.0.0-rc.
|
|
34
|
-
"yaml": "^2.8.
|
|
31
|
+
"@travetto/registry": "^7.0.0-rc.5",
|
|
32
|
+
"@travetto/runtime": "^7.0.0-rc.5",
|
|
33
|
+
"@travetto/terminal": "^7.0.0-rc.5",
|
|
34
|
+
"@travetto/worker": "^7.0.0-rc.5",
|
|
35
|
+
"yaml": "^2.8.2"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"@travetto/cli": "^7.0.0-rc.
|
|
38
|
-
"@travetto/transformer": "^7.0.0-rc.
|
|
38
|
+
"@travetto/cli": "^7.0.0-rc.5",
|
|
39
|
+
"@travetto/transformer": "^7.0.0-rc.4"
|
|
39
40
|
},
|
|
40
41
|
"peerDependenciesMeta": {
|
|
41
42
|
"@travetto/transformer": {
|
package/src/decorator/suite.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type SuitePhase = 'beforeAll' | 'beforeEach' | 'afterAll' | 'afterEach';
|
|
|
9
9
|
* Register a class to be defined as a test suite, and a candidate for testing
|
|
10
10
|
* @param description The Suite description
|
|
11
11
|
* @augments `@travetto/schema:Schema`
|
|
12
|
+
* @example opt-in
|
|
12
13
|
* @kind decorator
|
|
13
14
|
*/
|
|
14
15
|
export function Suite(): ClassDecorator;
|
package/src/execute/run.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { createReadStream } from 'node:fs';
|
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import readline from 'node:readline/promises';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
5
6
|
|
|
6
7
|
import { Env, ExecUtil, ShutdownManager, Util, RuntimeIndex, Runtime, TimeUtil, JSONUtil } from '@travetto/runtime';
|
|
7
8
|
import { WorkPool } from '@travetto/worker';
|
|
@@ -85,7 +86,7 @@ export class RunUtil {
|
|
|
85
86
|
*/
|
|
86
87
|
static async resolveGlobInput({ globs, tags, metadata }: TestGlobInput): Promise<TestRun[]> {
|
|
87
88
|
const digestProcess = await ExecUtil.getResult(
|
|
88
|
-
|
|
89
|
+
spawn(process.argv0, [Runtime.trvEntryPoint, 'test:digest', '-o', 'json', ...globs], {
|
|
89
90
|
env: { ...process.env, ...Env.FORCE_COLOR.export(0), ...Env.NO_COLOR.export(true) },
|
|
90
91
|
}),
|
|
91
92
|
{ catch: true }
|
package/src/model/test.ts
CHANGED
package/src/worker/types.ts
CHANGED
|
@@ -16,7 +16,6 @@ export type TestRunEvent = { type: 'runTest', import: string };
|
|
|
16
16
|
export const isTestRunEvent = (event: unknown): event is TestRunEvent =>
|
|
17
17
|
typeof event === 'object' && !!event && 'type' in event && event.type === 'runTest';
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
export type TestReadyEvent = { type: 'ready' };
|
|
21
20
|
export type TestLogEvent = { type: 'log', message: string };
|
|
22
21
|
|