@travetto/test 5.0.18 → 6.0.0-rc.0
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 +8 -8
- package/src/consumer/registry.ts +2 -9
- package/src/consumer/types/all.ts +1 -1
- package/src/consumer/types/{tap-streamed.ts → tap-summary.ts} +11 -9
- package/src/consumer/types/tap.ts +0 -4
- package/src/worker/standard.ts +2 -2
- package/support/bin/run.ts +2 -2
- package/LICENSE +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/test",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-rc.0",
|
|
4
4
|
"description": "Declarative test framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unit-testing",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"directory": "module/test"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/registry": "^
|
|
31
|
-
"@travetto/runtime": "^
|
|
32
|
-
"@travetto/terminal": "^
|
|
33
|
-
"@travetto/worker": "^
|
|
34
|
-
"yaml": "^2.
|
|
30
|
+
"@travetto/registry": "^6.0.0-rc.0",
|
|
31
|
+
"@travetto/runtime": "^6.0.0-rc.0",
|
|
32
|
+
"@travetto/terminal": "^6.0.0-rc.0",
|
|
33
|
+
"@travetto/worker": "^6.0.0-rc.0",
|
|
34
|
+
"yaml": "^2.7.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@travetto/cli": "^
|
|
38
|
-
"@travetto/transformer": "^
|
|
37
|
+
"@travetto/cli": "^6.0.0-rc.0",
|
|
38
|
+
"@travetto/transformer": "^6.0.0-rc.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@travetto/transformer": {
|
package/src/consumer/registry.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { classConstruct, describeFunction,
|
|
2
|
+
import { classConstruct, describeFunction, type Class } from '@travetto/runtime';
|
|
3
3
|
import type { TestConsumerShape } from './types';
|
|
4
|
-
import { RunState } from '../execute/types';
|
|
4
|
+
import type { RunState } from '../execute/types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Test Results Handler Registry
|
|
@@ -16,13 +16,6 @@ class $TestConsumerRegistry {
|
|
|
16
16
|
await import('./types/all');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Import a specific path and load all consumers there
|
|
21
|
-
*/
|
|
22
|
-
async importConsumers(pth: string): Promise<void> {
|
|
23
|
-
await import((RuntimeIndex.getEntry(pth) ?? RuntimeIndex.getFromImport(pth))!.outputFile);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
19
|
/**
|
|
27
20
|
* Add a new consumer
|
|
28
21
|
* @param cls The consumer class
|
|
@@ -8,6 +8,7 @@ import type { SuitesSummary, TestConsumerShape, TestRunState } from '../types';
|
|
|
8
8
|
import { TestConsumer } from '../registry';
|
|
9
9
|
|
|
10
10
|
import { TapEmitter } from './tap';
|
|
11
|
+
import { CONSOLE_ENHANCER, TestResultsEnhancer } from '../enhancer';
|
|
11
12
|
|
|
12
13
|
type Result = {
|
|
13
14
|
key: string;
|
|
@@ -19,7 +20,7 @@ type Result = {
|
|
|
19
20
|
* Streamed summary results
|
|
20
21
|
*/
|
|
21
22
|
@TestConsumer()
|
|
22
|
-
export class
|
|
23
|
+
export class TapSummaryEmitter implements TestConsumerShape {
|
|
23
24
|
|
|
24
25
|
#timings = new Map([
|
|
25
26
|
['file', new Map<string, Result>()],
|
|
@@ -32,11 +33,13 @@ export class TapStreamedEmitter implements TestConsumerShape {
|
|
|
32
33
|
#results = new AsyncQueue<TestResult>();
|
|
33
34
|
#progress: Promise<unknown> | undefined;
|
|
34
35
|
#consumer: TapEmitter;
|
|
36
|
+
#enhancer: TestResultsEnhancer;
|
|
35
37
|
#options?: Record<string, unknown>;
|
|
36
38
|
|
|
37
39
|
constructor(terminal: Terminal = new Terminal(process.stderr)) {
|
|
38
40
|
this.#terminal = terminal;
|
|
39
|
-
this.#
|
|
41
|
+
this.#enhancer = CONSOLE_ENHANCER;
|
|
42
|
+
this.#consumer = new TapEmitter(this.#terminal, this.#enhancer);
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
setOptions(options?: Record<string, unknown>): Promise<void> | void {
|
|
@@ -116,20 +119,19 @@ export class TapStreamedEmitter implements TestConsumerShape {
|
|
|
116
119
|
await this.#progress;
|
|
117
120
|
await this.#consumer.onSummary?.(summary);
|
|
118
121
|
|
|
119
|
-
const enhancer = this.#consumer.enhancer;
|
|
120
|
-
|
|
121
122
|
if (this.#options?.timings) {
|
|
122
123
|
const count = +(this.#options?.count ?? 5);
|
|
123
|
-
|
|
124
|
+
await this.#consumer.log('\n---');
|
|
124
125
|
for (const [title, results] of [...this.#timings.entries()].sort((a, b) => a[0].localeCompare(b[0]))) {
|
|
125
|
-
|
|
126
|
+
await this.#consumer.log(`${this.#enhancer.suiteName(`Top ${count} slowest ${title}s`)}: `);
|
|
126
127
|
const top10 = [...results.values()].sort((a, b) => b.duration - a.duration).slice(0, count);
|
|
128
|
+
|
|
127
129
|
for (const x of top10) {
|
|
128
|
-
console.log(` * ${enhancer.testName(x.key)} - ${enhancer.total(x.duration)}ms / ${enhancer.total(x.tests)} tests`);
|
|
130
|
+
console.log(` * ${this.#enhancer.testName(x.key)} - ${this.#enhancer.total(x.duration)}ms / ${this.#enhancer.total(x.tests)} tests`);
|
|
129
131
|
}
|
|
130
|
-
|
|
132
|
+
await this.#consumer.log('');
|
|
131
133
|
}
|
|
132
|
-
|
|
134
|
+
await this.#consumer.log('...');
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
}
|
|
@@ -27,10 +27,6 @@ export class TapEmitter implements TestConsumerShape {
|
|
|
27
27
|
this.#enhancer = enhancer;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
get enhancer(): TestResultsEnhancer {
|
|
31
|
-
return this.#enhancer;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
30
|
log(message: string): void {
|
|
35
31
|
this.#terminal.writer.writeLine(message).commit();
|
|
36
32
|
}
|
package/src/worker/standard.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Env, RuntimeIndex } from '@travetto/runtime';
|
|
|
4
4
|
import { IpcChannel } from '@travetto/worker';
|
|
5
5
|
|
|
6
6
|
import { Events, TestLogEvent } from './types';
|
|
7
|
-
import {
|
|
7
|
+
import { TestConsumerShape } from '../consumer/types';
|
|
8
8
|
import { SerializeUtil } from '../consumer/serialize';
|
|
9
9
|
import { TestEvent } from '../model/event';
|
|
10
10
|
import { TestRun } from '../model/test';
|
|
@@ -16,7 +16,7 @@ const log = (message: string): void => {
|
|
|
16
16
|
/**
|
|
17
17
|
* Produce a handler for the child worker
|
|
18
18
|
*/
|
|
19
|
-
export async function buildStandardTestManager(consumer:
|
|
19
|
+
export async function buildStandardTestManager(consumer: TestConsumerShape, run: TestRun): Promise<void> {
|
|
20
20
|
log(`Worker Input ${JSON.stringify(run)}`);
|
|
21
21
|
log(`Worker Executing ${run.import}`);
|
|
22
22
|
|
package/support/bin/run.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { castTo } from '@travetto/runtime';
|
|
1
|
+
import { castTo, Runtime } from '@travetto/runtime';
|
|
2
2
|
import { AllViewSymbol } from '@travetto/schema/src/internal/types';
|
|
3
3
|
import { SchemaRegistry } from '@travetto/schema';
|
|
4
4
|
|
|
@@ -30,7 +30,7 @@ export async function selectConsumer(inst: { format?: string }) {
|
|
|
30
30
|
let types = TestConsumerRegistry.getTypes();
|
|
31
31
|
|
|
32
32
|
if (inst.format?.includes('/')) {
|
|
33
|
-
await
|
|
33
|
+
await Runtime.importFrom(inst.format);
|
|
34
34
|
types = TestConsumerRegistry.getTypes();
|
|
35
35
|
}
|
|
36
36
|
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 ArcSine Technologies
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|