@apiquest/fracture 1.0.2 → 1.0.4
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 +119 -0
- package/bin/cli.js +2 -2
- package/dist/CollectionRunner.js +3 -3
- package/dist/ScriptEngine.js +4 -4
- package/dist/cli/plugin-commands.d.ts.map +1 -1
- package/dist/cli/plugin-commands.js +2 -1
- package/dist/cli/plugin-commands.js.map +1 -1
- package/package.json +55 -50
- package/src/CollectionAnalyzer.ts +102 -102
- package/src/CollectionRunner.ts +1423 -1423
- package/src/CollectionRunner.types.ts +9 -9
- package/src/CollectionValidator.ts +289 -289
- package/src/ConsoleReporter.ts +143 -143
- package/src/CookieJar.ts +258 -258
- package/src/DagScheduler.ts +439 -439
- package/src/Logger.ts +85 -85
- package/src/PluginLoader.ts +126 -126
- package/src/PluginManager.ts +208 -208
- package/src/PluginResolver.ts +154 -154
- package/src/QuestAPI.ts +764 -764
- package/src/QuestAPI.types.ts +33 -33
- package/src/QuestTestAPI.ts +164 -164
- package/src/RequestFilter.ts +224 -224
- package/src/ScriptEngine.ts +219 -219
- package/src/ScriptValidator.ts +428 -428
- package/src/TaskGraph.ts +598 -598
- package/src/TestCounter.ts +109 -109
- package/src/VariableResolver.ts +114 -114
- package/src/cli/index.ts +480 -480
- package/src/cli/plugin-commands.ts +342 -341
- package/src/cli/plugin-discovery.ts +44 -44
- package/src/index.ts +24 -24
- package/src/utils.ts +52 -52
- package/tsconfig.json +20 -20
- package/tsconfig.test.json +5 -5
- package/vitest.config.ts +22 -22
- package/dist/ExecutionTree.d.ts +0 -77
- package/dist/ExecutionTree.d.ts.map +0 -1
- package/dist/ExecutionTree.js +0 -265
- package/dist/ExecutionTree.js.map +0 -1
- package/dist/fracture/src/CollectionAnalyzer.d.ts +0 -17
- package/dist/fracture/src/CollectionAnalyzer.d.ts.map +0 -1
- package/dist/fracture/src/CollectionAnalyzer.js +0 -70
- package/dist/fracture/src/CollectionAnalyzer.js.map +0 -1
- package/dist/fracture/src/CollectionRunner.d.ts +0 -39
- package/dist/fracture/src/CollectionRunner.d.ts.map +0 -1
- package/dist/fracture/src/CollectionRunner.js +0 -802
- package/dist/fracture/src/CollectionRunner.js.map +0 -1
- package/dist/fracture/src/CollectionRunner.types.d.ts +0 -8
- package/dist/fracture/src/CollectionRunner.types.d.ts.map +0 -1
- package/dist/fracture/src/CollectionRunner.types.js +0 -2
- package/dist/fracture/src/CollectionRunner.types.js.map +0 -1
- package/dist/fracture/src/CollectionValidator.d.ts +0 -14
- package/dist/fracture/src/CollectionValidator.d.ts.map +0 -1
- package/dist/fracture/src/CollectionValidator.js +0 -145
- package/dist/fracture/src/CollectionValidator.js.map +0 -1
- package/dist/fracture/src/ConsoleReporter.d.ts +0 -24
- package/dist/fracture/src/ConsoleReporter.d.ts.map +0 -1
- package/dist/fracture/src/ConsoleReporter.js +0 -123
- package/dist/fracture/src/ConsoleReporter.js.map +0 -1
- package/dist/fracture/src/CookieJar.d.ts +0 -70
- package/dist/fracture/src/CookieJar.d.ts.map +0 -1
- package/dist/fracture/src/CookieJar.js +0 -233
- package/dist/fracture/src/CookieJar.js.map +0 -1
- package/dist/fracture/src/ExecutionTree.d.ts +0 -77
- package/dist/fracture/src/ExecutionTree.d.ts.map +0 -1
- package/dist/fracture/src/ExecutionTree.js +0 -258
- package/dist/fracture/src/ExecutionTree.js.map +0 -1
- package/dist/fracture/src/Logger.d.ts +0 -25
- package/dist/fracture/src/Logger.d.ts.map +0 -1
- package/dist/fracture/src/Logger.js +0 -78
- package/dist/fracture/src/Logger.js.map +0 -1
- package/dist/fracture/src/PluginLoader.d.ts +0 -23
- package/dist/fracture/src/PluginLoader.d.ts.map +0 -1
- package/dist/fracture/src/PluginLoader.js +0 -102
- package/dist/fracture/src/PluginLoader.js.map +0 -1
- package/dist/fracture/src/PluginManager.d.ts +0 -64
- package/dist/fracture/src/PluginManager.d.ts.map +0 -1
- package/dist/fracture/src/PluginManager.js +0 -162
- package/dist/fracture/src/PluginManager.js.map +0 -1
- package/dist/fracture/src/PluginResolver.d.ts +0 -35
- package/dist/fracture/src/PluginResolver.d.ts.map +0 -1
- package/dist/fracture/src/PluginResolver.js +0 -128
- package/dist/fracture/src/PluginResolver.js.map +0 -1
- package/dist/fracture/src/QuestAPI.d.ts +0 -9
- package/dist/fracture/src/QuestAPI.d.ts.map +0 -1
- package/dist/fracture/src/QuestAPI.js +0 -679
- package/dist/fracture/src/QuestAPI.js.map +0 -1
- package/dist/fracture/src/QuestAPI.types.d.ts +0 -35
- package/dist/fracture/src/QuestAPI.types.d.ts.map +0 -1
- package/dist/fracture/src/QuestAPI.types.js +0 -3
- package/dist/fracture/src/QuestAPI.types.js.map +0 -1
- package/dist/fracture/src/QuestTestAPI.d.ts +0 -12
- package/dist/fracture/src/QuestTestAPI.d.ts.map +0 -1
- package/dist/fracture/src/QuestTestAPI.js +0 -133
- package/dist/fracture/src/QuestTestAPI.js.map +0 -1
- package/dist/fracture/src/ScriptEngine.d.ts +0 -21
- package/dist/fracture/src/ScriptEngine.d.ts.map +0 -1
- package/dist/fracture/src/ScriptEngine.js +0 -183
- package/dist/fracture/src/ScriptEngine.js.map +0 -1
- package/dist/fracture/src/ScriptValidator.d.ts +0 -68
- package/dist/fracture/src/ScriptValidator.d.ts.map +0 -1
- package/dist/fracture/src/ScriptValidator.js +0 -351
- package/dist/fracture/src/ScriptValidator.js.map +0 -1
- package/dist/fracture/src/TestCounter.d.ts +0 -18
- package/dist/fracture/src/TestCounter.d.ts.map +0 -1
- package/dist/fracture/src/TestCounter.js +0 -82
- package/dist/fracture/src/TestCounter.js.map +0 -1
- package/dist/fracture/src/VariableResolver.d.ts +0 -20
- package/dist/fracture/src/VariableResolver.d.ts.map +0 -1
- package/dist/fracture/src/VariableResolver.js +0 -100
- package/dist/fracture/src/VariableResolver.js.map +0 -1
- package/dist/fracture/src/cli/index.d.ts +0 -3
- package/dist/fracture/src/cli/index.d.ts.map +0 -1
- package/dist/fracture/src/cli/index.js +0 -347
- package/dist/fracture/src/cli/index.js.map +0 -1
- package/dist/fracture/src/cli/plugin-commands.d.ts +0 -6
- package/dist/fracture/src/cli/plugin-commands.d.ts.map +0 -1
- package/dist/fracture/src/cli/plugin-commands.js +0 -263
- package/dist/fracture/src/cli/plugin-commands.js.map +0 -1
- package/dist/fracture/src/cli/plugin-discovery.d.ts +0 -11
- package/dist/fracture/src/cli/plugin-discovery.d.ts.map +0 -1
- package/dist/fracture/src/cli/plugin-discovery.js +0 -64
- package/dist/fracture/src/cli/plugin-discovery.js.map +0 -1
- package/dist/fracture/src/index.d.ts +0 -13
- package/dist/fracture/src/index.d.ts.map +0 -1
- package/dist/fracture/src/index.js +0 -17
- package/dist/fracture/src/index.js.map +0 -1
- package/dist/fracture/src/utils.d.ts +0 -28
- package/dist/fracture/src/utils.d.ts.map +0 -1
- package/dist/fracture/src/utils.js +0 -48
- package/dist/fracture/src/utils.js.map +0 -1
- package/dist/plugin-auth/src/apikey-auth.d.ts +0 -3
- package/dist/plugin-auth/src/apikey-auth.d.ts.map +0 -1
- package/dist/plugin-auth/src/apikey-auth.js +0 -73
- package/dist/plugin-auth/src/apikey-auth.js.map +0 -1
- package/dist/plugin-auth/src/basic-auth.d.ts +0 -3
- package/dist/plugin-auth/src/basic-auth.d.ts.map +0 -1
- package/dist/plugin-auth/src/basic-auth.js +0 -61
- package/dist/plugin-auth/src/basic-auth.js.map +0 -1
- package/dist/plugin-auth/src/bearer-auth.d.ts +0 -3
- package/dist/plugin-auth/src/bearer-auth.d.ts.map +0 -1
- package/dist/plugin-auth/src/bearer-auth.js +0 -49
- package/dist/plugin-auth/src/bearer-auth.js.map +0 -1
- package/dist/plugin-auth/src/helpers.d.ts +0 -3
- package/dist/plugin-auth/src/helpers.d.ts.map +0 -1
- package/dist/plugin-auth/src/helpers.js +0 -8
- package/dist/plugin-auth/src/helpers.js.map +0 -1
- package/dist/plugin-auth/src/index.d.ts +0 -10
- package/dist/plugin-auth/src/index.d.ts.map +0 -1
- package/dist/plugin-auth/src/index.js +0 -25
- package/dist/plugin-auth/src/index.js.map +0 -1
- package/dist/plugin-auth/src/oauth2-auth.d.ts +0 -35
- package/dist/plugin-auth/src/oauth2-auth.d.ts.map +0 -1
- package/dist/plugin-auth/src/oauth2-auth.js +0 -266
- package/dist/plugin-auth/src/oauth2-auth.js.map +0 -1
- package/dist/plugin-http/src/index.d.ts +0 -4
- package/dist/plugin-http/src/index.d.ts.map +0 -1
- package/dist/plugin-http/src/index.js +0 -266
- package/dist/plugin-http/src/index.js.map +0 -1
- package/dist/plugin-vault-file/src/index.d.ts +0 -67
- package/dist/plugin-vault-file/src/index.d.ts.map +0 -1
- package/dist/plugin-vault-file/src/index.js +0 -171
- package/dist/plugin-vault-file/src/index.js.map +0 -1
- package/dist/types.d.ts +0 -374
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -13
- package/dist/types.js.map +0 -1
package/src/ConsoleReporter.ts
CHANGED
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
IReporter,
|
|
3
|
-
Collection,
|
|
4
|
-
RunOptions,
|
|
5
|
-
Request,
|
|
6
|
-
RequestResult,
|
|
7
|
-
TestResult,
|
|
8
|
-
RunResult,
|
|
9
|
-
LogLevel,
|
|
10
|
-
EventPayloads
|
|
11
|
-
} from '@apiquest/types';
|
|
12
|
-
import { LogLevel as LogLevelEnum } from '@apiquest/types';
|
|
13
|
-
import type { EventEmitter } from 'events';
|
|
14
|
-
|
|
15
|
-
export class ConsoleReporter implements IReporter {
|
|
16
|
-
name = 'console';
|
|
17
|
-
version: string = '1.0.0';
|
|
18
|
-
description: string = 'Pretty CLI output for quest runs';
|
|
19
|
-
reportTypes: string[] = ['console'];
|
|
20
|
-
|
|
21
|
-
private logLevel: LogLevel;
|
|
22
|
-
private color: boolean;
|
|
23
|
-
private runner?: EventEmitter;
|
|
24
|
-
|
|
25
|
-
constructor(options?: { logLevel?: LogLevel; color?: boolean; runner?: EventEmitter }) {
|
|
26
|
-
this.logLevel = options?.logLevel ?? LogLevelEnum.INFO;
|
|
27
|
-
this.color = options?.color ?? true; // Color enabled by default
|
|
28
|
-
this.runner = options?.runner;
|
|
29
|
-
|
|
30
|
-
// Subscribe to console events for logger output
|
|
31
|
-
if (this.runner !== null && this.runner !== undefined) {
|
|
32
|
-
this.setupConsoleLogging();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private setupConsoleLogging(): void {
|
|
37
|
-
if (this.runner === null || this.runner === undefined) return;
|
|
38
|
-
|
|
39
|
-
// Log levels are hierarchical using LogLevel enum values
|
|
40
|
-
this.runner.on('console', ({ level, levelName, message }: EventPayloads['console']) => {
|
|
41
|
-
// Only show if message level is <= configured level (lower number = higher priority)
|
|
42
|
-
if (level <= this.logLevel) {
|
|
43
|
-
const tag = `[${(levelName !== null && levelName !== undefined && levelName.length > 0) ? levelName.toUpperCase() : 'LOG'}]`;
|
|
44
|
-
if (level === LogLevelEnum.ERROR) {
|
|
45
|
-
console.error(`${tag} ${message}`);
|
|
46
|
-
} else if (level === LogLevelEnum.WARN) {
|
|
47
|
-
console.warn(`${tag} ${message}`);
|
|
48
|
-
} else {
|
|
49
|
-
console.log(`${tag} ${message}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private colorize(text: string, colorCode: string): string {
|
|
56
|
-
if (!this.color) return text;
|
|
57
|
-
return `${colorCode}${text}\x1b[0m`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
onRunStarted(collection: Collection, options: RunOptions): void {
|
|
61
|
-
console.log('============================================================');
|
|
62
|
-
console.log(` Quest v1.0.0`);
|
|
63
|
-
console.log(` Collection: ${collection.info.name}`);
|
|
64
|
-
console.log('============================================================');
|
|
65
|
-
console.log('');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
onBeforeRequest(payload: EventPayloads['beforeRequest']): void {
|
|
69
|
-
console.log('');
|
|
70
|
-
console.log(`${this.colorize('>', '\x1b[36m')} ${payload.request.name}`);
|
|
71
|
-
|
|
72
|
-
const requestData = payload.request.data as Record<string, unknown> | null | undefined;
|
|
73
|
-
if (requestData !== null && requestData !== undefined) {
|
|
74
|
-
const method = (typeof requestData.method === 'string' && requestData.method.length > 0) ? requestData.method : 'GET';
|
|
75
|
-
const url = (typeof requestData.url === 'string' && requestData.url.length > 0) ? requestData.url : '';
|
|
76
|
-
console.log(` ${method} ${url}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
onAfterRequest(payload: EventPayloads['afterRequest']): void {
|
|
81
|
-
if (payload.response.error !== null && payload.response.error !== undefined && payload.response.error.length > 0) {
|
|
82
|
-
console.log(` ${this.colorize('[FAIL]', '\x1b[31m')} ERROR: ${payload.response.error}`);
|
|
83
|
-
} else {
|
|
84
|
-
const statusColor = payload.response.status >= 400 ? '\x1b[31m' : '\x1b[32m';
|
|
85
|
-
console.log(` ${this.colorize('<', statusColor)} ${payload.response.status} ${payload.response.statusText} (${payload.duration}ms)`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
onAssertion(payload: EventPayloads['assertion']): void {
|
|
90
|
-
const test = payload.test;
|
|
91
|
-
if (test.skipped) {
|
|
92
|
-
console.log(` ${this.colorize('[SKIP]', '\x1b[90m')} ${test.name}`);
|
|
93
|
-
} else if (test.passed) {
|
|
94
|
-
console.log(` ${this.colorize('[PASS]', '\x1b[32m')} ${test.name}`);
|
|
95
|
-
} else {
|
|
96
|
-
console.log(` ${this.colorize('[FAIL]', '\x1b[31m')} ${test.name}`);
|
|
97
|
-
if (test.error !== null && test.error !== undefined && test.error.length > 0) {
|
|
98
|
-
console.log(` Error: ${test.error}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
onRunCompleted(result: RunResult): void {
|
|
104
|
-
console.log('');
|
|
105
|
-
console.log('------------------------------------------------------------');
|
|
106
|
-
console.log('');
|
|
107
|
-
console.log('RESULTS:');
|
|
108
|
-
console.log(` Collection: ${result.collectionName}`);
|
|
109
|
-
console.log(` Duration: ${(result.duration / 1000).toFixed(2)}s`);
|
|
110
|
-
console.log(` Requests: ${result.requestResults.length}`);
|
|
111
|
-
|
|
112
|
-
const successful = result.requestResults.filter(r => r.success).length;
|
|
113
|
-
const failed = result.requestResults.filter(r => !r.success).length;
|
|
114
|
-
|
|
115
|
-
if (successful > 0) {
|
|
116
|
-
console.log(` - Successful: ${successful}`);
|
|
117
|
-
}
|
|
118
|
-
if (failed > 0) {
|
|
119
|
-
console.log(` - Failed: ${failed}`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (result.totalTests > 0) {
|
|
123
|
-
console.log(` Tests: ${result.totalTests}`);
|
|
124
|
-
console.log(` - Passed: ${result.passedTests}`);
|
|
125
|
-
if (result.failedTests > 0) {
|
|
126
|
-
console.log(` - Failed: ${result.failedTests}`);
|
|
127
|
-
}
|
|
128
|
-
if (result.skippedTests > 0) {
|
|
129
|
-
console.log(` - Skipped: ${result.skippedTests}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
console.log('');
|
|
134
|
-
|
|
135
|
-
// if any TEST results failed end with error exit code 1
|
|
136
|
-
// Request failures are OK if tests expect and handle them
|
|
137
|
-
if (result.failedTests > 0) {
|
|
138
|
-
console.log(`${this.colorize('[FAIL]', '\x1b[31m')} Collection run completed with errors`); // Red
|
|
139
|
-
} else {
|
|
140
|
-
console.log(`${this.colorize('[PASS]', '\x1b[32m')} Collection run completed successfully`); // Green
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
IReporter,
|
|
3
|
+
Collection,
|
|
4
|
+
RunOptions,
|
|
5
|
+
Request,
|
|
6
|
+
RequestResult,
|
|
7
|
+
TestResult,
|
|
8
|
+
RunResult,
|
|
9
|
+
LogLevel,
|
|
10
|
+
EventPayloads
|
|
11
|
+
} from '@apiquest/types';
|
|
12
|
+
import { LogLevel as LogLevelEnum } from '@apiquest/types';
|
|
13
|
+
import type { EventEmitter } from 'events';
|
|
14
|
+
|
|
15
|
+
export class ConsoleReporter implements IReporter {
|
|
16
|
+
name = 'console';
|
|
17
|
+
version: string = '1.0.0';
|
|
18
|
+
description: string = 'Pretty CLI output for quest runs';
|
|
19
|
+
reportTypes: string[] = ['console'];
|
|
20
|
+
|
|
21
|
+
private logLevel: LogLevel;
|
|
22
|
+
private color: boolean;
|
|
23
|
+
private runner?: EventEmitter;
|
|
24
|
+
|
|
25
|
+
constructor(options?: { logLevel?: LogLevel; color?: boolean; runner?: EventEmitter }) {
|
|
26
|
+
this.logLevel = options?.logLevel ?? LogLevelEnum.INFO;
|
|
27
|
+
this.color = options?.color ?? true; // Color enabled by default
|
|
28
|
+
this.runner = options?.runner;
|
|
29
|
+
|
|
30
|
+
// Subscribe to console events for logger output
|
|
31
|
+
if (this.runner !== null && this.runner !== undefined) {
|
|
32
|
+
this.setupConsoleLogging();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private setupConsoleLogging(): void {
|
|
37
|
+
if (this.runner === null || this.runner === undefined) return;
|
|
38
|
+
|
|
39
|
+
// Log levels are hierarchical using LogLevel enum values
|
|
40
|
+
this.runner.on('console', ({ level, levelName, message }: EventPayloads['console']) => {
|
|
41
|
+
// Only show if message level is <= configured level (lower number = higher priority)
|
|
42
|
+
if (level <= this.logLevel) {
|
|
43
|
+
const tag = `[${(levelName !== null && levelName !== undefined && levelName.length > 0) ? levelName.toUpperCase() : 'LOG'}]`;
|
|
44
|
+
if (level === LogLevelEnum.ERROR) {
|
|
45
|
+
console.error(`${tag} ${message}`);
|
|
46
|
+
} else if (level === LogLevelEnum.WARN) {
|
|
47
|
+
console.warn(`${tag} ${message}`);
|
|
48
|
+
} else {
|
|
49
|
+
console.log(`${tag} ${message}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private colorize(text: string, colorCode: string): string {
|
|
56
|
+
if (!this.color) return text;
|
|
57
|
+
return `${colorCode}${text}\x1b[0m`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
onRunStarted(collection: Collection, options: RunOptions): void {
|
|
61
|
+
console.log('============================================================');
|
|
62
|
+
console.log(` Quest v1.0.0`);
|
|
63
|
+
console.log(` Collection: ${collection.info.name}`);
|
|
64
|
+
console.log('============================================================');
|
|
65
|
+
console.log('');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onBeforeRequest(payload: EventPayloads['beforeRequest']): void {
|
|
69
|
+
console.log('');
|
|
70
|
+
console.log(`${this.colorize('>', '\x1b[36m')} ${payload.request.name}`);
|
|
71
|
+
|
|
72
|
+
const requestData = payload.request.data as Record<string, unknown> | null | undefined;
|
|
73
|
+
if (requestData !== null && requestData !== undefined) {
|
|
74
|
+
const method = (typeof requestData.method === 'string' && requestData.method.length > 0) ? requestData.method : 'GET';
|
|
75
|
+
const url = (typeof requestData.url === 'string' && requestData.url.length > 0) ? requestData.url : '';
|
|
76
|
+
console.log(` ${method} ${url}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onAfterRequest(payload: EventPayloads['afterRequest']): void {
|
|
81
|
+
if (payload.response.error !== null && payload.response.error !== undefined && payload.response.error.length > 0) {
|
|
82
|
+
console.log(` ${this.colorize('[FAIL]', '\x1b[31m')} ERROR: ${payload.response.error}`);
|
|
83
|
+
} else {
|
|
84
|
+
const statusColor = payload.response.status >= 400 ? '\x1b[31m' : '\x1b[32m';
|
|
85
|
+
console.log(` ${this.colorize('<', statusColor)} ${payload.response.status} ${payload.response.statusText} (${payload.duration}ms)`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
onAssertion(payload: EventPayloads['assertion']): void {
|
|
90
|
+
const test = payload.test;
|
|
91
|
+
if (test.skipped) {
|
|
92
|
+
console.log(` ${this.colorize('[SKIP]', '\x1b[90m')} ${test.name}`);
|
|
93
|
+
} else if (test.passed) {
|
|
94
|
+
console.log(` ${this.colorize('[PASS]', '\x1b[32m')} ${test.name}`);
|
|
95
|
+
} else {
|
|
96
|
+
console.log(` ${this.colorize('[FAIL]', '\x1b[31m')} ${test.name}`);
|
|
97
|
+
if (test.error !== null && test.error !== undefined && test.error.length > 0) {
|
|
98
|
+
console.log(` Error: ${test.error}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
onRunCompleted(result: RunResult): void {
|
|
104
|
+
console.log('');
|
|
105
|
+
console.log('------------------------------------------------------------');
|
|
106
|
+
console.log('');
|
|
107
|
+
console.log('RESULTS:');
|
|
108
|
+
console.log(` Collection: ${result.collectionName}`);
|
|
109
|
+
console.log(` Duration: ${(result.duration / 1000).toFixed(2)}s`);
|
|
110
|
+
console.log(` Requests: ${result.requestResults.length}`);
|
|
111
|
+
|
|
112
|
+
const successful = result.requestResults.filter(r => r.success).length;
|
|
113
|
+
const failed = result.requestResults.filter(r => !r.success).length;
|
|
114
|
+
|
|
115
|
+
if (successful > 0) {
|
|
116
|
+
console.log(` - Successful: ${successful}`);
|
|
117
|
+
}
|
|
118
|
+
if (failed > 0) {
|
|
119
|
+
console.log(` - Failed: ${failed}`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (result.totalTests > 0) {
|
|
123
|
+
console.log(` Tests: ${result.totalTests}`);
|
|
124
|
+
console.log(` - Passed: ${result.passedTests}`);
|
|
125
|
+
if (result.failedTests > 0) {
|
|
126
|
+
console.log(` - Failed: ${result.failedTests}`);
|
|
127
|
+
}
|
|
128
|
+
if (result.skippedTests > 0) {
|
|
129
|
+
console.log(` - Skipped: ${result.skippedTests}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log('');
|
|
134
|
+
|
|
135
|
+
// if any TEST results failed end with error exit code 1
|
|
136
|
+
// Request failures are OK if tests expect and handle them
|
|
137
|
+
if (result.failedTests > 0) {
|
|
138
|
+
console.log(`${this.colorize('[FAIL]', '\x1b[31m')} Collection run completed with errors`); // Red
|
|
139
|
+
} else {
|
|
140
|
+
console.log(`${this.colorize('[PASS]', '\x1b[32m')} Collection run completed successfully`); // Green
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|