@travetto/test 8.0.0-alpha.24 → 8.0.0-alpha.26
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/package.json +19 -19
- package/src/assert/capture.ts +3 -3
- package/src/consumer/types/tap.ts +9 -9
- package/src/execute/run.ts +1 -1
- package/src/model/util.ts +1 -1
- package/src/trv.d.ts +2 -2
- package/support/transformer.assert.ts +12 -12
package/package.json
CHANGED
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/test",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "8.0.0-alpha.26",
|
|
5
4
|
"description": "Declarative test framework",
|
|
6
5
|
"keywords": [
|
|
7
|
-
"
|
|
6
|
+
"ast-transformations",
|
|
7
|
+
"decorators",
|
|
8
8
|
"testing",
|
|
9
9
|
"travetto",
|
|
10
10
|
"typescript",
|
|
11
|
-
"
|
|
12
|
-
"ast-transformations"
|
|
11
|
+
"unit-testing"
|
|
13
12
|
],
|
|
14
13
|
"homepage": "https://travetto.io",
|
|
15
14
|
"license": "MIT",
|
|
16
15
|
"author": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
16
|
+
"name": "Travetto Framework",
|
|
17
|
+
"email": "travetto.framework@gmail.com"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"url": "git+https://github.com/travetto/travetto.git",
|
|
21
|
+
"directory": "module/test"
|
|
19
22
|
},
|
|
20
23
|
"files": [
|
|
21
24
|
"__index__.ts",
|
|
22
25
|
"src",
|
|
23
26
|
"support"
|
|
24
27
|
],
|
|
28
|
+
"type": "module",
|
|
25
29
|
"main": "__index__.ts",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"directory": "module/test"
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
|
-
"@travetto/registry": "^8.0.0-alpha.
|
|
32
|
-
"@travetto/runtime": "^8.0.0-alpha.
|
|
33
|
-
"@travetto/terminal": "^8.0.0-alpha.
|
|
34
|
-
"@travetto/worker": "^8.0.0-alpha.
|
|
34
|
+
"@travetto/registry": "^8.0.0-alpha.24",
|
|
35
|
+
"@travetto/runtime": "^8.0.0-alpha.24",
|
|
36
|
+
"@travetto/terminal": "^8.0.0-alpha.24",
|
|
37
|
+
"@travetto/worker": "^8.0.0-alpha.25",
|
|
35
38
|
"yaml": "^2.9.0"
|
|
36
39
|
},
|
|
37
40
|
"peerDependencies": {
|
|
38
|
-
"@travetto/cli": "^8.0.0-alpha.
|
|
39
|
-
"@travetto/transformer": "^8.0.0-alpha.
|
|
41
|
+
"@travetto/cli": "^8.0.0-alpha.33",
|
|
42
|
+
"@travetto/transformer": "^8.0.0-alpha.19"
|
|
40
43
|
},
|
|
41
44
|
"peerDependenciesMeta": {
|
|
42
45
|
"@travetto/transformer": {
|
|
@@ -52,8 +55,5 @@
|
|
|
52
55
|
"roles": [
|
|
53
56
|
"test"
|
|
54
57
|
]
|
|
55
|
-
},
|
|
56
|
-
"publishConfig": {
|
|
57
|
-
"access": "public"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/src/assert/capture.ts
CHANGED
|
@@ -26,15 +26,15 @@ class $AssertCapture {
|
|
|
26
26
|
|
|
27
27
|
// Emit and collect, every assertion as it occurs
|
|
28
28
|
const handler = (a: CapturedAssertion): void => {
|
|
29
|
-
const
|
|
29
|
+
const assertion: Assertion = {
|
|
30
30
|
...a,
|
|
31
31
|
import: a.import ?? a.module!.join('/'),
|
|
32
32
|
classId: test.classId,
|
|
33
33
|
methodName: test.methodName
|
|
34
34
|
};
|
|
35
|
-
assertions.push(
|
|
35
|
+
assertions.push(assertion);
|
|
36
36
|
if (listener) {
|
|
37
|
-
listener(
|
|
37
|
+
listener(assertion);
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -80,29 +80,29 @@ export class TapEmitter implements TestConsumerShape {
|
|
|
80
80
|
// Handle each assertion
|
|
81
81
|
if (test.assertions.length) {
|
|
82
82
|
let subCount = 0;
|
|
83
|
-
for (const
|
|
84
|
-
const assertSourceFile = RuntimeIndex.getFromImport(
|
|
85
|
-
const text =
|
|
86
|
-
const location =
|
|
83
|
+
for (const assertion of test.assertions) {
|
|
84
|
+
const assertSourceFile = RuntimeIndex.getFromImport(assertion.import)!.sourceFile;
|
|
85
|
+
const text = assertion.message ? `${assertion.text} (${this.#enhancer.failure(assertion.message)})` : assertion.text;
|
|
86
|
+
const location = assertion.import ? `./${path.relative(process.cwd(), assertSourceFile)}` : '<unknown>';
|
|
87
87
|
let subMessage = [
|
|
88
88
|
this.#enhancer.assertNumber((subCount += 1)),
|
|
89
89
|
'-',
|
|
90
90
|
this.#enhancer.assertDescription(text),
|
|
91
91
|
StyleUtil.link(
|
|
92
|
-
`${this.#enhancer.assertFile(location)}:${this.#enhancer.assertLine(
|
|
93
|
-
`file://${assertSourceFile}#${
|
|
92
|
+
`${this.#enhancer.assertFile(location)}:${this.#enhancer.assertLine(assertion.line)}`,
|
|
93
|
+
`file://${assertSourceFile}#${assertion.line}`
|
|
94
94
|
)
|
|
95
95
|
].join(' ');
|
|
96
96
|
|
|
97
|
-
if (
|
|
97
|
+
if (assertion.error) {
|
|
98
98
|
subMessage = `${this.#enhancer.failure('not ok')} ${subMessage}`;
|
|
99
99
|
} else {
|
|
100
100
|
subMessage = `${this.#enhancer.success('ok')} ${subMessage}`;
|
|
101
101
|
}
|
|
102
102
|
this.log(` ${subMessage}`);
|
|
103
103
|
|
|
104
|
-
if (
|
|
105
|
-
this.logMeta({ message:
|
|
104
|
+
if (assertion.message && assertion.message.length > 100) {
|
|
105
|
+
this.logMeta({ message: assertion.message.replace(/\\n/g, '\n') });
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
this.log(` ${this.#enhancer.assertNumber(1)}..${this.#enhancer.assertNumber(subCount)}`);
|
package/src/execute/run.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { describeFunction, Env, ExecUtil, JSONUtil, Runtime, RuntimeIndex, TimeU
|
|
|
8
8
|
import { WorkPool } from '@travetto/worker';
|
|
9
9
|
|
|
10
10
|
import { TestConsumerRegistryIndex } from '../consumer/registry-index.ts';
|
|
11
|
-
import { RunnableTestConsumer } from '../consumer/types/runnable.ts';
|
|
12
11
|
import type { TestConsumerShape } from '../consumer/types.ts';
|
|
12
|
+
import { RunnableTestConsumer } from '../consumer/types/runnable.ts';
|
|
13
13
|
import type { TestRemoveEvent } from '../model/event.ts';
|
|
14
14
|
import type { TestConfig, TestDiffInput, TestGlobInput, TestRun, TestRunInput } from '../model/test.ts';
|
|
15
15
|
import { SuiteRegistryIndex } from '../registry/registry-index.ts';
|
package/src/model/util.ts
CHANGED
package/src/trv.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TimeSpan } from '@travetto/runtime';
|
|
1
|
+
import type { TimeSpan } from '@travetto/runtime';
|
|
2
2
|
|
|
3
3
|
declare module '@travetto/runtime' {
|
|
4
4
|
interface EnvData {
|
|
@@ -17,4 +17,4 @@ declare module '@travetto/runtime' {
|
|
|
17
17
|
*/
|
|
18
18
|
TRV_TEST_TAGS: string[];
|
|
19
19
|
}
|
|
20
|
-
}
|
|
20
|
+
}
|
|
@@ -18,9 +18,9 @@ export const DEEP_EQUALS_MAPPING: Record<string, string> = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Typescript
|
|
21
|
+
* Typescript op token to assert methods
|
|
22
22
|
*/
|
|
23
|
-
export const
|
|
23
|
+
export const OP_TOKEN_ASSERT = {
|
|
24
24
|
InKeyword: 'in',
|
|
25
25
|
EqualsEqualsToken: 'equal',
|
|
26
26
|
ExclamationEqualsToken: 'notEqual',
|
|
@@ -46,7 +46,7 @@ const METHODS: Record<string, Function[]> = {
|
|
|
46
46
|
test: [RegExp]
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
const OP_TOKEN_TO_NAME = new Map<number, keyof typeof
|
|
49
|
+
const OP_TOKEN_TO_NAME = new Map<number, keyof typeof OP_TOKEN_ASSERT>();
|
|
50
50
|
|
|
51
51
|
const AssertSymbol = Symbol();
|
|
52
52
|
const IsTestSymbol = Symbol();
|
|
@@ -96,21 +96,21 @@ export class AssertTransformer {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
* Resolves
|
|
99
|
+
* Resolves op token to syntax kind. Relies on `ts`
|
|
100
100
|
*/
|
|
101
101
|
static lookupOpToken(key: number): string | undefined {
|
|
102
102
|
if (OP_TOKEN_TO_NAME.size === 0) {
|
|
103
103
|
Object.keys(ts.SyntaxKind)
|
|
104
104
|
.filter(kind => !/^\d+$/.test(kind))
|
|
105
|
-
.filter((kind): kind is keyof typeof
|
|
105
|
+
.filter((kind): kind is keyof typeof OP_TOKEN_ASSERT => !/^(Last|First)/.test(kind))
|
|
106
106
|
.forEach(kind => {
|
|
107
107
|
OP_TOKEN_TO_NAME.set(ts.SyntaxKind[kind], kind);
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
const name = OP_TOKEN_TO_NAME.get(key)!;
|
|
112
|
-
if (name in
|
|
113
|
-
return
|
|
112
|
+
if (name in OP_TOKEN_ASSERT) {
|
|
113
|
+
return OP_TOKEN_ASSERT[name];
|
|
114
114
|
} else {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
@@ -142,12 +142,12 @@ export class AssertTransformer {
|
|
|
142
142
|
*/
|
|
143
143
|
static initState(state: TransformerState & AssertState): void {
|
|
144
144
|
if (!state[AssertSymbol]) {
|
|
145
|
-
const
|
|
145
|
+
const assertion = state.importFile('@travetto/test/src/assert/check.ts').identifier;
|
|
146
146
|
state[AssertSymbol] = {
|
|
147
|
-
assert:
|
|
148
|
-
assertCheck: CoreUtil.createAccess(state.factory,
|
|
149
|
-
checkThrow: CoreUtil.createAccess(state.factory,
|
|
150
|
-
checkThrowAsync: CoreUtil.createAccess(state.factory,
|
|
147
|
+
assert: assertion,
|
|
148
|
+
assertCheck: CoreUtil.createAccess(state.factory, assertion, ASSERT_UTIL, 'check'),
|
|
149
|
+
checkThrow: CoreUtil.createAccess(state.factory, assertion, ASSERT_UTIL, 'checkThrow'),
|
|
150
|
+
checkThrowAsync: CoreUtil.createAccess(state.factory, assertion, ASSERT_UTIL, 'checkThrowAsync')
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
}
|