@as-pect/json-reporter 8.0.1 → 9.0.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/CHANGELOG.md +16 -0
- package/LICENSE +6 -6
- package/__tests__/JSONReporter.spec.ts +295 -0
- package/index.ts +64 -58
- package/jest.config.js +17 -0
- package/lib/index.d.ts +23 -19
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +75 -70
- package/lib/index.js.map +1 -1
- package/package.json +8 -4
- package/readme.md +48 -3
- package/tsconfig.json +28 -24
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# @as-pect/json-reporter
|
|
2
|
+
|
|
3
|
+
## 9.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fdd7f20: Add a dedicated CTRF JSON reporter package and `asp --ctrf` shortcut while documenting that `asp --json` remains the as-pect legacy JSON v1 contract.
|
|
8
|
+
- 65058fe: Share file-backed reporter output behavior across CSV and JSON reporters while preserving existing output paths and formats.
|
|
9
|
+
- 5abb0e1: Treat groups and tests skipped by `--group` or `--test` filters as skipped instead of failed, and suppress per-file reports and aggregate counts for files with no executed results.
|
|
10
|
+
- dd71792: Anchor built-in file-backed reporter output to the Test session project path, and allow programmatic reporter users to pass an explicit output root.
|
|
11
|
+
- Updated dependencies [dbaaae5]
|
|
12
|
+
- Updated dependencies [65058fe]
|
|
13
|
+
- Updated dependencies [5abb0e1]
|
|
14
|
+
- Updated dependencies [4420210]
|
|
15
|
+
- @as-pect/core@9.0.0
|
|
16
|
+
- @as-pect/reporter-output@9.0.0
|
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright 2019 Joshua Tenner
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
1
|
+
Copyright 2019 Joshua Tenner
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
7
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { access, mkdir, mkdtemp, readFile, rm } from "fs/promises";
|
|
2
|
+
import { join, relative } from "path";
|
|
3
|
+
import JSONReporter from "../index.js";
|
|
4
|
+
import type { SuiteReport, SuiteResultReport } from "@as-pect/core";
|
|
5
|
+
|
|
6
|
+
class TestJSONReporter extends JSONReporter {
|
|
7
|
+
public async writeAndWait(report: Pick<SuiteReport, "fileName" | "hasResults" | "results">): Promise<void> {
|
|
8
|
+
this.onReportFinish({ report: report as SuiteReport });
|
|
9
|
+
await this.onFlush();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function testResult(overrides: Partial<SuiteResultReport> = {}): SuiteResultReport {
|
|
14
|
+
return {
|
|
15
|
+
type: "test",
|
|
16
|
+
groupName: "math",
|
|
17
|
+
name: "adds values",
|
|
18
|
+
ran: true,
|
|
19
|
+
negated: false,
|
|
20
|
+
pass: true,
|
|
21
|
+
runtime: 3,
|
|
22
|
+
message: null,
|
|
23
|
+
stackTrace: null,
|
|
24
|
+
rtraceDelta: 0,
|
|
25
|
+
logs: [],
|
|
26
|
+
actual: "3",
|
|
27
|
+
expected: "3",
|
|
28
|
+
actualValue: null,
|
|
29
|
+
expectedValue: null,
|
|
30
|
+
...overrides,
|
|
31
|
+
} as SuiteResultReport;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function reporterCreatesFile(report: Pick<SuiteReport, "hasResults" | "results">): Promise<boolean> {
|
|
35
|
+
const tempDir = await mkdtemp(join(process.cwd(), "tmp-json-reporter-"));
|
|
36
|
+
const fileName = join(relative(process.cwd(), tempDir), "example.spec.ts");
|
|
37
|
+
const reporter = new TestJSONReporter();
|
|
38
|
+
const outputPath = join(tempDir, "example.spec.json");
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
await reporter.writeAndWait({ fileName, ...report });
|
|
42
|
+
await access(outputPath);
|
|
43
|
+
return true;
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
} finally {
|
|
47
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function runReporter(results: SuiteResultReport[]): Promise<unknown> {
|
|
52
|
+
const tempDir = await mkdtemp(join(process.cwd(), "tmp-json-reporter-"));
|
|
53
|
+
const fileName = join(relative(process.cwd(), tempDir), "example.spec.ts");
|
|
54
|
+
const reporter = new TestJSONReporter();
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
await reporter.writeAndWait({ fileName, hasResults: true, results });
|
|
58
|
+
const output = await readFile(join(tempDir, "example.spec.json"), "utf8");
|
|
59
|
+
return JSON.parse(output);
|
|
60
|
+
} finally {
|
|
61
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function runNestedReporter(): Promise<unknown> {
|
|
66
|
+
const tempDir = await mkdtemp(join(process.cwd(), "tmp-json-reporter-"));
|
|
67
|
+
const sourceDir = join(tempDir, "assembly", "__tests__");
|
|
68
|
+
const fileName = join(relative(process.cwd(), sourceDir), "entry.spec.ts");
|
|
69
|
+
const reporter = new TestJSONReporter();
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
await mkdir(sourceDir, { recursive: true });
|
|
73
|
+
await reporter.writeAndWait({ fileName, hasResults: true, results: [testResult()] });
|
|
74
|
+
const output = await readFile(join(sourceDir, "entry.spec.json"), "utf8");
|
|
75
|
+
return JSON.parse(output);
|
|
76
|
+
} finally {
|
|
77
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function runProjectRootReporter(): Promise<unknown> {
|
|
82
|
+
const tempDir = await mkdtemp(join(process.cwd(), "tmp-json-reporter-root-"));
|
|
83
|
+
const sourceDir = join(tempDir, "assembly", "__tests__");
|
|
84
|
+
const reporter = new TestJSONReporter(tempDir);
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
await mkdir(sourceDir, { recursive: true });
|
|
88
|
+
await reporter.writeAndWait({
|
|
89
|
+
fileName: "assembly/__tests__/entry.spec.ts",
|
|
90
|
+
hasResults: true,
|
|
91
|
+
results: [testResult()],
|
|
92
|
+
});
|
|
93
|
+
const output = await readFile(join(sourceDir, "entry.spec.json"), "utf8");
|
|
94
|
+
return JSON.parse(output);
|
|
95
|
+
} finally {
|
|
96
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function writeReportWithMissingOutputDirectory(): Promise<void> {
|
|
101
|
+
const tempDir = await mkdtemp(join(process.cwd(), "tmp-json-reporter-"));
|
|
102
|
+
const fileName = join(relative(process.cwd(), tempDir), "missing", "entry.spec.ts");
|
|
103
|
+
const reporter = new TestJSONReporter();
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
await reporter.writeAndWait({ fileName, hasResults: true, results: [testResult()] });
|
|
107
|
+
} finally {
|
|
108
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
describe("JSONReporter", () => {
|
|
113
|
+
it("does not write a file for reports with no executed results", async () => {
|
|
114
|
+
await expect(
|
|
115
|
+
reporterCreatesFile({
|
|
116
|
+
hasResults: false,
|
|
117
|
+
results: [testResult({ name: "skipped by filter", ran: false })],
|
|
118
|
+
}),
|
|
119
|
+
).resolves.toBe(false);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("writes parseable JSON for an empty report", async () => {
|
|
123
|
+
await expect(runReporter([])).resolves.toEqual([]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("writes parseable JSON for one test result", async () => {
|
|
127
|
+
await expect(runReporter([testResult()])).resolves.toEqual([
|
|
128
|
+
{
|
|
129
|
+
group: "math",
|
|
130
|
+
name: "adds values",
|
|
131
|
+
ran: true,
|
|
132
|
+
pass: true,
|
|
133
|
+
negated: false,
|
|
134
|
+
runtime: 3,
|
|
135
|
+
message: null,
|
|
136
|
+
actual: "3",
|
|
137
|
+
expected: "3",
|
|
138
|
+
},
|
|
139
|
+
]);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("writes the JSON file next to a nested test entry", async () => {
|
|
143
|
+
await expect(runNestedReporter()).resolves.toEqual([
|
|
144
|
+
{
|
|
145
|
+
group: "math",
|
|
146
|
+
name: "adds values",
|
|
147
|
+
ran: true,
|
|
148
|
+
pass: true,
|
|
149
|
+
negated: false,
|
|
150
|
+
runtime: 3,
|
|
151
|
+
message: null,
|
|
152
|
+
actual: "3",
|
|
153
|
+
expected: "3",
|
|
154
|
+
},
|
|
155
|
+
]);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("writes project-relative report files under the configured output root", async () => {
|
|
159
|
+
await expect(runProjectRootReporter()).resolves.toEqual([
|
|
160
|
+
{
|
|
161
|
+
group: "math",
|
|
162
|
+
name: "adds values",
|
|
163
|
+
ran: true,
|
|
164
|
+
pass: true,
|
|
165
|
+
negated: false,
|
|
166
|
+
runtime: 3,
|
|
167
|
+
message: null,
|
|
168
|
+
actual: "3",
|
|
169
|
+
expected: "3",
|
|
170
|
+
},
|
|
171
|
+
]);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("surfaces output stream errors through flush", async () => {
|
|
175
|
+
await expect(writeReportWithMissingOutputDirectory()).rejects.toMatchObject({ code: "ENOENT" });
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("preserves the as-pect legacy JSON v1 shape for pass, fail, and todo results", async () => {
|
|
179
|
+
await expect(
|
|
180
|
+
runReporter([
|
|
181
|
+
testResult({ name: "adds values", runtime: 3 }),
|
|
182
|
+
testResult({
|
|
183
|
+
name: "subtracts values",
|
|
184
|
+
pass: false,
|
|
185
|
+
runtime: 5,
|
|
186
|
+
message: "expected 1",
|
|
187
|
+
actual: "2",
|
|
188
|
+
expected: "1",
|
|
189
|
+
}),
|
|
190
|
+
{
|
|
191
|
+
type: "todo",
|
|
192
|
+
groupName: "math",
|
|
193
|
+
description: "handles division",
|
|
194
|
+
},
|
|
195
|
+
]),
|
|
196
|
+
).resolves.toEqual([
|
|
197
|
+
{
|
|
198
|
+
group: "math",
|
|
199
|
+
name: "adds values",
|
|
200
|
+
ran: true,
|
|
201
|
+
pass: true,
|
|
202
|
+
negated: false,
|
|
203
|
+
runtime: 3,
|
|
204
|
+
message: null,
|
|
205
|
+
actual: "3",
|
|
206
|
+
expected: "3",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
group: "math",
|
|
210
|
+
name: "subtracts values",
|
|
211
|
+
ran: true,
|
|
212
|
+
pass: false,
|
|
213
|
+
negated: false,
|
|
214
|
+
runtime: 5,
|
|
215
|
+
message: "expected 1",
|
|
216
|
+
actual: "2",
|
|
217
|
+
expected: "1",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
group: "math",
|
|
221
|
+
name: "TODO: handles division",
|
|
222
|
+
ran: false,
|
|
223
|
+
pass: null,
|
|
224
|
+
negated: false,
|
|
225
|
+
runtime: 0,
|
|
226
|
+
message: "",
|
|
227
|
+
actual: null,
|
|
228
|
+
expected: null,
|
|
229
|
+
},
|
|
230
|
+
]);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("writes parseable JSON for multiple test results", async () => {
|
|
234
|
+
await expect(
|
|
235
|
+
runReporter([
|
|
236
|
+
testResult({ name: "adds values", runtime: 3 }),
|
|
237
|
+
testResult({
|
|
238
|
+
name: "subtracts values",
|
|
239
|
+
pass: false,
|
|
240
|
+
runtime: 5,
|
|
241
|
+
message: "expected 1",
|
|
242
|
+
actual: "2",
|
|
243
|
+
expected: "1",
|
|
244
|
+
}),
|
|
245
|
+
]),
|
|
246
|
+
).resolves.toEqual([
|
|
247
|
+
{
|
|
248
|
+
group: "math",
|
|
249
|
+
name: "adds values",
|
|
250
|
+
ran: true,
|
|
251
|
+
pass: true,
|
|
252
|
+
negated: false,
|
|
253
|
+
runtime: 3,
|
|
254
|
+
message: null,
|
|
255
|
+
actual: "3",
|
|
256
|
+
expected: "3",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
group: "math",
|
|
260
|
+
name: "subtracts values",
|
|
261
|
+
ran: true,
|
|
262
|
+
pass: false,
|
|
263
|
+
negated: false,
|
|
264
|
+
runtime: 5,
|
|
265
|
+
message: "expected 1",
|
|
266
|
+
actual: "2",
|
|
267
|
+
expected: "1",
|
|
268
|
+
},
|
|
269
|
+
]);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("writes parseable JSON for a todo result", async () => {
|
|
273
|
+
await expect(
|
|
274
|
+
runReporter([
|
|
275
|
+
{
|
|
276
|
+
type: "todo",
|
|
277
|
+
groupName: "math",
|
|
278
|
+
description: "handles division",
|
|
279
|
+
},
|
|
280
|
+
]),
|
|
281
|
+
).resolves.toEqual([
|
|
282
|
+
{
|
|
283
|
+
group: "math",
|
|
284
|
+
name: "TODO: handles division",
|
|
285
|
+
ran: false,
|
|
286
|
+
pass: null,
|
|
287
|
+
negated: false,
|
|
288
|
+
runtime: 0,
|
|
289
|
+
message: "",
|
|
290
|
+
actual: null,
|
|
291
|
+
expected: null,
|
|
292
|
+
},
|
|
293
|
+
]);
|
|
294
|
+
});
|
|
295
|
+
});
|
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Writable } from "stream";
|
|
2
|
+
import { TestContext, IReporter, IWritable, SuiteReport, SuiteReportEvent, SuiteResultReport } from "@as-pect/core";
|
|
3
|
+
import { ReporterFileOutput } from "@as-pect/reporter-output";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This class reports all relevant test statistics to a JSON file located at
|
|
@@ -10,74 +10,80 @@ export default class JSONReporter implements IReporter {
|
|
|
10
10
|
public stdout: IWritable | null = null;
|
|
11
11
|
public stderr: IWritable | null = null;
|
|
12
12
|
|
|
13
|
-
protected file:
|
|
13
|
+
protected file: Writable | null = null;
|
|
14
|
+
protected fileOutput: ReporterFileOutput;
|
|
14
15
|
|
|
15
16
|
private first: boolean = true;
|
|
16
17
|
|
|
17
|
-
public
|
|
18
|
-
|
|
19
|
-
const dir = dirname(ctx.fileName);
|
|
20
|
-
const base = basename(ctx.fileName, extension);
|
|
21
|
-
const outPath = join(process.cwd(), dir, base + ".json");
|
|
22
|
-
this.file = createWriteStream(outPath, "utf8");
|
|
23
|
-
this.file.write("[");
|
|
24
|
-
this.first = true;
|
|
18
|
+
public constructor(outputRoot?: string) {
|
|
19
|
+
this.fileOutput = new ReporterFileOutput(undefined, outputRoot);
|
|
25
20
|
}
|
|
26
21
|
|
|
27
|
-
public
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
public onEnter(_ctx: TestContext): void {}
|
|
23
|
+
|
|
24
|
+
public onExit(_ctx: TestContext): void {}
|
|
25
|
+
|
|
26
|
+
public onReportFinish(event: SuiteReportEvent): void {
|
|
27
|
+
this.writeReport(event.report);
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
public onFinish(
|
|
34
|
-
this.
|
|
30
|
+
public onFinish(ctx: TestContext): void {
|
|
31
|
+
this.writeReport(SuiteReport.from(ctx));
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
public onFlush(): Promise<void> {
|
|
35
|
+
return this.fileOutput.flush();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected writeReport(report: SuiteReport): void {
|
|
39
|
+
if (report.hasResults === false) return;
|
|
40
|
+
|
|
41
|
+
const fileReport = this.fileOutput.start(report, ".json");
|
|
42
|
+
if (fileReport === null) return;
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
const file = fileReport.stream;
|
|
45
|
+
this.file = file;
|
|
46
|
+
file.write("[");
|
|
47
|
+
this.first = true;
|
|
48
|
+
|
|
49
|
+
for (const result of report.results) {
|
|
50
|
+
this.onResult(result);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
file.write(this.first ? "]" : "\n]");
|
|
54
|
+
file.end();
|
|
42
55
|
}
|
|
43
56
|
|
|
44
|
-
protected
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
protected onResult(result: SuiteResultReport): void {
|
|
58
|
+
if (result.type === "test") {
|
|
59
|
+
this.writeResult({
|
|
60
|
+
group: result.groupName,
|
|
61
|
+
name: result.name,
|
|
62
|
+
ran: result.ran,
|
|
63
|
+
pass: result.pass,
|
|
64
|
+
negated: result.negated,
|
|
65
|
+
runtime: result.runtime,
|
|
66
|
+
message: result.message,
|
|
67
|
+
actual: result.actual,
|
|
68
|
+
expected: result.expected,
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
this.writeResult({
|
|
72
|
+
group: result.groupName,
|
|
73
|
+
name: "TODO: " + result.description,
|
|
74
|
+
ran: false,
|
|
75
|
+
pass: null,
|
|
76
|
+
negated: false,
|
|
77
|
+
runtime: 0,
|
|
78
|
+
message: "",
|
|
79
|
+
actual: null,
|
|
80
|
+
expected: null,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
64
83
|
}
|
|
65
84
|
|
|
66
|
-
protected
|
|
67
|
-
this.file!.write(
|
|
68
|
-
(this.first ? "\n" : ",\n") +
|
|
69
|
-
JSON.stringify({
|
|
70
|
-
group: group.name,
|
|
71
|
-
name: "TODO: " + desc,
|
|
72
|
-
ran: false,
|
|
73
|
-
pass: null,
|
|
74
|
-
negated: false,
|
|
75
|
-
runtime: 0,
|
|
76
|
-
message: "",
|
|
77
|
-
actual: null,
|
|
78
|
-
expected: null,
|
|
79
|
-
}),
|
|
80
|
-
);
|
|
85
|
+
protected writeResult(result: object): void {
|
|
86
|
+
this.file!.write((this.first ? "\n" : ",\n") + JSON.stringify(result));
|
|
81
87
|
this.first = false;
|
|
82
88
|
}
|
|
83
|
-
}
|
|
89
|
+
}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolve } from "path";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
testEnvironment: "node",
|
|
5
|
+
transform: {
|
|
6
|
+
"^.+\\.tsx?$": ["ts-jest", { useESM: true }],
|
|
7
|
+
},
|
|
8
|
+
testMatch: ["**/__tests__/**/*.spec.[jt]s"],
|
|
9
|
+
testPathIgnorePatterns: ["/node_modules/"],
|
|
10
|
+
extensionsToTreatAsEsm: [".ts"],
|
|
11
|
+
moduleNameMapper: {
|
|
12
|
+
"^(\\.{1,2}/.*)\\.js$": "$1",
|
|
13
|
+
"^@as-pect/core$": resolve("../core/src/index.ts"),
|
|
14
|
+
"^@as-pect/reporter-output$": resolve("../reporter-output/index.ts"),
|
|
15
|
+
"^@as-pect/snapshots$": resolve("../snapshots/src/index.ts"),
|
|
16
|
+
},
|
|
17
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
/**
|
|
5
|
-
* This class reports all relevant test statistics to a JSON file located at
|
|
6
|
-
* `{testLocation}.spec.json`.
|
|
7
|
-
*/
|
|
8
|
-
export default class JSONReporter implements IReporter {
|
|
9
|
-
stdout: IWritable | null;
|
|
10
|
-
stderr: IWritable | null;
|
|
11
|
-
protected file:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { Writable } from "stream";
|
|
2
|
+
import { TestContext, IReporter, IWritable, SuiteReport, SuiteReportEvent, SuiteResultReport } from "@as-pect/core";
|
|
3
|
+
import { ReporterFileOutput } from "@as-pect/reporter-output";
|
|
4
|
+
/**
|
|
5
|
+
* This class reports all relevant test statistics to a JSON file located at
|
|
6
|
+
* `{testLocation}.spec.json`.
|
|
7
|
+
*/
|
|
8
|
+
export default class JSONReporter implements IReporter {
|
|
9
|
+
stdout: IWritable | null;
|
|
10
|
+
stderr: IWritable | null;
|
|
11
|
+
protected file: Writable | null;
|
|
12
|
+
protected fileOutput: ReporterFileOutput;
|
|
13
|
+
private first;
|
|
14
|
+
constructor(outputRoot?: string);
|
|
15
|
+
onEnter(_ctx: TestContext): void;
|
|
16
|
+
onExit(_ctx: TestContext): void;
|
|
17
|
+
onReportFinish(event: SuiteReportEvent): void;
|
|
18
|
+
onFinish(ctx: TestContext): void;
|
|
19
|
+
onFlush(): Promise<void>;
|
|
20
|
+
protected writeReport(report: SuiteReport): void;
|
|
21
|
+
protected onResult(result: SuiteResultReport): void;
|
|
22
|
+
protected writeResult(result: object): void;
|
|
23
|
+
}
|
|
20
24
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACpH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,SAAS;IAC7C,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;IAChC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;IAEvC,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAQ;IACvC,SAAS,CAAC,UAAU,EAAE,kBAAkB,CAAC;IAEzC,OAAO,CAAC,KAAK,CAAiB;gBAEX,UAAU,CAAC,EAAE,MAAM;IAI/B,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAEhC,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAE/B,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAI7C,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;IAIhC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAmBhD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IA4BnD,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAI5C"}
|
package/lib/index.js
CHANGED
|
@@ -1,71 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
/**
|
|
4
|
-
* This class reports all relevant test statistics to a JSON file located at
|
|
5
|
-
* `{testLocation}.spec.json`.
|
|
6
|
-
*/
|
|
7
|
-
export default class JSONReporter {
|
|
8
|
-
stdout = null;
|
|
9
|
-
stderr = null;
|
|
10
|
-
file = null;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
1
|
+
import { SuiteReport } from "@as-pect/core";
|
|
2
|
+
import { ReporterFileOutput } from "@as-pect/reporter-output";
|
|
3
|
+
/**
|
|
4
|
+
* This class reports all relevant test statistics to a JSON file located at
|
|
5
|
+
* `{testLocation}.spec.json`.
|
|
6
|
+
*/
|
|
7
|
+
export default class JSONReporter {
|
|
8
|
+
stdout = null;
|
|
9
|
+
stderr = null;
|
|
10
|
+
file = null;
|
|
11
|
+
fileOutput;
|
|
12
|
+
first = true;
|
|
13
|
+
constructor(outputRoot) {
|
|
14
|
+
this.fileOutput = new ReporterFileOutput(undefined, outputRoot);
|
|
15
|
+
}
|
|
16
|
+
onEnter(_ctx) { }
|
|
17
|
+
onExit(_ctx) { }
|
|
18
|
+
onReportFinish(event) {
|
|
19
|
+
this.writeReport(event.report);
|
|
20
|
+
}
|
|
21
|
+
onFinish(ctx) {
|
|
22
|
+
this.writeReport(SuiteReport.from(ctx));
|
|
23
|
+
}
|
|
24
|
+
onFlush() {
|
|
25
|
+
return this.fileOutput.flush();
|
|
26
|
+
}
|
|
27
|
+
writeReport(report) {
|
|
28
|
+
if (report.hasResults === false)
|
|
29
|
+
return;
|
|
30
|
+
const fileReport = this.fileOutput.start(report, ".json");
|
|
31
|
+
if (fileReport === null)
|
|
32
|
+
return;
|
|
33
|
+
const file = fileReport.stream;
|
|
34
|
+
this.file = file;
|
|
35
|
+
file.write("[");
|
|
36
|
+
this.first = true;
|
|
37
|
+
for (const result of report.results) {
|
|
38
|
+
this.onResult(result);
|
|
39
|
+
}
|
|
40
|
+
file.write(this.first ? "]" : "\n]");
|
|
41
|
+
file.end();
|
|
42
|
+
}
|
|
43
|
+
onResult(result) {
|
|
44
|
+
if (result.type === "test") {
|
|
45
|
+
this.writeResult({
|
|
46
|
+
group: result.groupName,
|
|
47
|
+
name: result.name,
|
|
48
|
+
ran: result.ran,
|
|
49
|
+
pass: result.pass,
|
|
50
|
+
negated: result.negated,
|
|
51
|
+
runtime: result.runtime,
|
|
52
|
+
message: result.message,
|
|
53
|
+
actual: result.actual,
|
|
54
|
+
expected: result.expected,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.writeResult({
|
|
59
|
+
group: result.groupName,
|
|
60
|
+
name: "TODO: " + result.description,
|
|
61
|
+
ran: false,
|
|
62
|
+
pass: null,
|
|
63
|
+
negated: false,
|
|
64
|
+
runtime: 0,
|
|
65
|
+
message: "",
|
|
66
|
+
actual: null,
|
|
67
|
+
expected: null,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
writeResult(result) {
|
|
72
|
+
this.file.write((this.first ? "\n" : ",\n") + JSON.stringify(result));
|
|
73
|
+
this.first = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
71
76
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@as-pect/json-reporter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Json reporter for as-pect",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
-
"types": "lib/index.ts",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"tsc:all": "tsc",
|
|
10
|
-
"test": "
|
|
10
|
+
"test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"author": "Joshua Tenner",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@as-pect/core": "^
|
|
19
|
+
"@as-pect/core": "^9.0.0",
|
|
20
|
+
"@as-pect/reporter-output": "^9.0.0"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
20
24
|
}
|
|
21
25
|
}
|
package/readme.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# jtenner/as-pect - @as-pect/json-reporter
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.org/jtenner/as-pect)
|
|
3
|
+
[](https://github.com/jtenner/as-pect/actions/workflows/test.yml)
|
|
5
4
|
[](https://coveralls.io/github/jtenner/as-pect?branch=master)
|
|
6
|
-
[](https://github.com/changesets/changesets)
|
|
7
6
|
|
|
8
7
|
Write your module in AssemblyScript and get blazing fast bootstrapped tests
|
|
9
8
|
with WebAssembly speeds!
|
|
@@ -12,6 +11,52 @@ with WebAssembly speeds!
|
|
|
12
11
|
|
|
13
12
|
To view the documentation, it's located [here](https://tenner-joshua.gitbook.io/as-pect/) on the gitbook. If there are any issues with the docs, please feel free to file an issue!
|
|
14
13
|
|
|
14
|
+
## Reporter API
|
|
15
|
+
|
|
16
|
+
This package writes JSON from the Suite report facts delivered to `onReportFinish({ report })`. Custom file reporters should prefer the report event callbacks from `@as-pect/core` and treat `onFinish(ctx)` as a legacy compatibility callback.
|
|
17
|
+
|
|
18
|
+
## as-pect legacy JSON v1 contract
|
|
19
|
+
|
|
20
|
+
`@as-pect/json-reporter` is the as-pect legacy JSON reporter. It is selected by `asp --json` and intentionally remains separate from the standardized CTRF reporter in `@as-pect/ctrf-reporter`.
|
|
21
|
+
|
|
22
|
+
The reporter writes one sibling `.json` file per test entry. The file root is an array of result objects in execution order.
|
|
23
|
+
|
|
24
|
+
Passing and failing tests use this field shape:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"group": "math",
|
|
29
|
+
"name": "adds values",
|
|
30
|
+
"ran": true,
|
|
31
|
+
"pass": true,
|
|
32
|
+
"negated": false,
|
|
33
|
+
"runtime": 3,
|
|
34
|
+
"message": null,
|
|
35
|
+
"actual": "3",
|
|
36
|
+
"expected": "3"
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Failed tests keep the same fields with `pass: false`, assertion text in `message`, and reflected assertion strings in `actual` and `expected` when present.
|
|
41
|
+
|
|
42
|
+
Todo results use the same object shape for compatibility:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"group": "math",
|
|
47
|
+
"name": "TODO: handles division",
|
|
48
|
+
"ran": false,
|
|
49
|
+
"pass": null,
|
|
50
|
+
"negated": false,
|
|
51
|
+
"runtime": 0,
|
|
52
|
+
"message": "",
|
|
53
|
+
"actual": null,
|
|
54
|
+
"expected": null
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Use `asp --ctrf` or `asp --reporter @as-pect/ctrf-reporter` when a consumer expects CTRF root fields such as `reportFormat`, `specVersion`, and `results`.
|
|
59
|
+
|
|
15
60
|
## Contributors
|
|
16
61
|
|
|
17
62
|
To contribute please see [CONTRIBUTING.md](./CONTRIBUTING.md).
|
package/tsconfig.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
/* Basic Options */
|
|
4
|
-
"target": "ESNext"
|
|
5
|
-
"module": "ESNext"
|
|
4
|
+
"target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
|
|
5
|
+
"module": "ESNext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
|
6
6
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
7
|
-
"allowJs": true
|
|
8
|
-
"checkJs": true
|
|
7
|
+
"allowJs": true /* Allow javascript files to be compiled. */,
|
|
8
|
+
"checkJs": true /* Report errors in .js files. */,
|
|
9
9
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
10
|
-
"declaration": true
|
|
11
|
-
"declarationMap": true
|
|
12
|
-
"sourceMap": true
|
|
10
|
+
"declaration": true /* Generates corresponding '.d.ts' file. */,
|
|
11
|
+
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
|
|
12
|
+
"sourceMap": true /* Generates corresponding '.map' file. */,
|
|
13
13
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
14
|
-
"outDir": "./lib/"
|
|
14
|
+
"outDir": "./lib/" /* Redirect output structure to the directory. */,
|
|
15
15
|
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
16
16
|
// "composite": true, /* Enable project compilation */
|
|
17
17
|
// "removeComments": true, /* Do not emit comments to output. */
|
|
18
18
|
// "noEmit": true, /* Do not emit outputs. */
|
|
19
19
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
20
|
-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
20
|
+
// // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
21
21
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
22
22
|
|
|
23
23
|
/* Strict Type-Checking Options */
|
|
24
|
-
"strict": true
|
|
25
|
-
"noImplicitAny": true
|
|
26
|
-
"strictNullChecks": true
|
|
27
|
-
"strictFunctionTypes": true
|
|
28
|
-
"strictBindCallApply": true
|
|
29
|
-
"strictPropertyInitialization": true
|
|
30
|
-
"noImplicitThis": true
|
|
31
|
-
"alwaysStrict": true
|
|
24
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
25
|
+
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
|
26
|
+
"strictNullChecks": true /* Enable strict null checks. */,
|
|
27
|
+
"strictFunctionTypes": true /* Enable strict checking of function types. */,
|
|
28
|
+
"strictBindCallApply": true /* Enable strict 'bind', 'call', and 'apply' methods on functions. */,
|
|
29
|
+
"strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */,
|
|
30
|
+
"noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
|
|
31
|
+
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
|
|
32
32
|
|
|
33
33
|
/* Additional Checks */
|
|
34
|
-
"noUnusedLocals": true
|
|
35
|
-
"noUnusedParameters": true
|
|
36
|
-
"noImplicitReturns": true
|
|
37
|
-
"noFallthroughCasesInSwitch": true
|
|
34
|
+
"noUnusedLocals": true /* Report errors on unused locals. */,
|
|
35
|
+
"noUnusedParameters": true /* Report errors on unused parameters. */,
|
|
36
|
+
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
|
|
37
|
+
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
|
|
38
38
|
|
|
39
39
|
/* Module Resolution Options */
|
|
40
|
-
"moduleResolution": "
|
|
40
|
+
"moduleResolution": "bundler" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
|
41
41
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
42
42
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
43
43
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
44
|
-
|
|
44
|
+
"types": ["node"] /* Type declaration files to be included in compilation. */,
|
|
45
45
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
46
|
-
"esModuleInterop": true
|
|
46
|
+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
47
47
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
48
48
|
|
|
49
49
|
/* Source Map Options */
|
|
@@ -52,8 +52,12 @@
|
|
|
52
52
|
// "inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */
|
|
53
53
|
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
54
54
|
|
|
55
|
+
"skipLibCheck": true
|
|
56
|
+
|
|
55
57
|
/* Experimental Options */
|
|
56
58
|
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
57
59
|
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
58
60
|
},
|
|
61
|
+
"include": ["index.ts"],
|
|
62
|
+
"exclude": ["__tests__", "lib", "node_modules"]
|
|
59
63
|
}
|