@redproof/testing 0.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,32 @@
1
+ import { type Adapter } from 'redproof';
2
+ import { testCounts, testRunBreaches, type TestReportFormat, type TestRuleCatalog, type TestRuleOptions, type TestRunner } from './model.ts';
3
+ import { command } from './runner.ts';
4
+ import { jestJson, parseJestJson } from './reports/jest-json.ts';
5
+ import { junitXml, parseJunitXml } from './reports/junit-xml.ts';
6
+ export type TestingAdapterOptions<O extends TestRuleOptions> = {
7
+ readonly runner: TestRunner;
8
+ readonly report: TestReportFormat;
9
+ readonly rules: O;
10
+ };
11
+ export declare function testing<const O extends TestRuleOptions>(options: TestingAdapterOptions<O>): Adapter<TestRuleCatalog<O>>;
12
+ export declare function defineTestRunner<const R extends TestRunner>(runner: R): R;
13
+ export declare function defineTestReport<const R extends TestReportFormat>(report: R): R;
14
+ export type VitestAdapterOptions<O extends TestRuleOptions> = {
15
+ readonly command?: string;
16
+ readonly configFile?: string;
17
+ readonly files?: readonly string[];
18
+ readonly args?: readonly string[];
19
+ readonly rules: O;
20
+ };
21
+ export declare function vitest<const O extends TestRuleOptions>(options: VitestAdapterOptions<O>): Adapter<TestRuleCatalog<O>>;
22
+ export declare const runner: {
23
+ readonly command: typeof command;
24
+ };
25
+ export declare const report: {
26
+ readonly jestJson: typeof jestJson;
27
+ readonly junitXml: typeof junitXml;
28
+ };
29
+ export { command, jestJson, junitXml, parseJestJson, parseJunitXml, testCounts, testRunBreaches, };
30
+ export type { CommandArgs, CommandRunnerOptions, } from './runner.ts';
31
+ export type { TestCase, TestFailure, TestReportCapabilities, TestReportFormat, TestRuleCatalog, TestRuleOptions, TestRun, TestRunner, TestRunnerCompleted, TestRunnerContext, TestRunnerResult, TestRunnerUnavailable, TestSt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C,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACnB,CAAC;AAEF,wBAAgB,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,eAAe,EACpD,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAiB7B;AAED,eAAO,MAAM,MAAM;;CAAuB,CAAC;AAC3C,eAAO,MAAM,MAAM;;;CAAkC,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,aAAa,EACb,UAAU,EACV,eAAe,GAChB,CAAC;AAEF,YAAY,EACV,WAAW,EACX,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,QAAQ,EACR,WAAW,EACX,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,OAAO,EACP,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,GACX,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,178 @@
1
+ import { mkdtemp, readFile, rm } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
3
+ import { isAbsolute, join, relative } from 'node:path';
4
+ import { counting, defineAdapter, defineRules, result, } from 'redproof';
5
+ import { testCounts, testRunBreaches, } from "./model.js";
6
+ import { command } from "./runner.js";
7
+ import { jestJson, parseJestJson } from "./reports/jest-json.js";
8
+ import { junitXml, parseJunitXml } from "./reports/junit-xml.js";
9
+ function now() {
10
+ return new Date().toISOString();
11
+ }
12
+ function normalizeFile(root, file) {
13
+ if (!file)
14
+ return null;
15
+ if (!isAbsolute(file))
16
+ return file.replaceAll('\\', '/');
17
+ const rel = relative(root, file);
18
+ if (!rel.startsWith('..') && !isAbsolute(rel))
19
+ return rel.replaceAll('\\', '/');
20
+ return file.replaceAll('\\', '/');
21
+ }
22
+ function normalizeLocation(root, location) {
23
+ if (!location)
24
+ return null;
25
+ return {
26
+ ...location,
27
+ file: normalizeFile(root, location.file) ?? location.file,
28
+ };
29
+ }
30
+ function normalizeRun(root, run) {
31
+ return {
32
+ tests: run.tests.map((test) => ({
33
+ ...test,
34
+ file: normalizeFile(root, test.file),
35
+ location: normalizeLocation(root, test.location),
36
+ })),
37
+ };
38
+ }
39
+ export function testing(options) {
40
+ if (!options.rules.testsPass && !options.rules.noSkippedTests && !options.rules.noTodoTests) {
41
+ throw new Error('Testing adapter requires at least one Redproof rule.');
42
+ }
43
+ if (options.rules.noTodoTests && !options.report.capabilities.todo) {
44
+ throw new Error(`Report format ${options.report.kind} cannot distinguish TODO tests.`);
45
+ }
46
+ const catalog = {};
47
+ if (options.rules.testsPass) {
48
+ catalog.testsPass = {
49
+ id: 'testing/tests-pass',
50
+ description: 'All tests must pass.',
51
+ };
52
+ }
53
+ if (options.rules.noSkippedTests) {
54
+ catalog.noSkippedTests = {
55
+ id: 'testing/no-skipped-tests',
56
+ description: 'Tests must not be skipped.',
57
+ };
58
+ }
59
+ if (options.rules.noTodoTests) {
60
+ catalog.noTodoTests = {
61
+ id: 'testing/no-todo-tests',
62
+ description: 'Tests must not be marked TODO.',
63
+ };
64
+ }
65
+ const rules = defineRules(catalog);
66
+ const byAlias = rules;
67
+ return defineAdapter({
68
+ kind: 'testing',
69
+ rules,
70
+ check: {
71
+ description: `${options.runner.description}; interpret ${options.report.kind} test results`,
72
+ counting: counting.supported,
73
+ async run(ctx) {
74
+ const startedAt = now();
75
+ const temp = await mkdtemp(join(tmpdir(), 'redproof-testing-'));
76
+ const reportFile = join(temp, `report${options.report.extension}`);
77
+ try {
78
+ const execution = await options.runner.run({ root: ctx.root, reportFile });
79
+ if (execution.kind === 'unavailable') {
80
+ return result.refuse({
81
+ source: `testing/${options.report.kind}`,
82
+ startedAt,
83
+ finishedAt: now(),
84
+ inspected: null,
85
+ }, {
86
+ code: 'test-runner-unavailable',
87
+ message: execution.message,
88
+ location: null,
89
+ ...(execution.detail ? { detail: execution.detail } : {}),
90
+ });
91
+ }
92
+ let run;
93
+ try {
94
+ run = normalizeRun(ctx.root, options.report.parse(await readFile(reportFile, 'utf8')));
95
+ }
96
+ catch (error) {
97
+ return result.refuse({
98
+ source: `testing/${options.report.kind}`,
99
+ startedAt,
100
+ finishedAt: now(),
101
+ inspected: null,
102
+ }, {
103
+ code: 'test-report-unavailable',
104
+ message: 'The test command did not produce a trustworthy structured report.',
105
+ location: null,
106
+ detail: [
107
+ error instanceof Error ? error.message : String(error),
108
+ execution.stderr.trim(),
109
+ execution.stdout.trim(),
110
+ `exit code: ${execution.exitCode}`,
111
+ ].filter(Boolean).join('\n'),
112
+ });
113
+ }
114
+ const counts = testCounts(run);
115
+ if (execution.exitCode !== 0 && counts.failed === 0) {
116
+ return result.refuse({
117
+ source: `testing/${options.report.kind}`,
118
+ startedAt,
119
+ finishedAt: now(),
120
+ inspected: run.tests.length,
121
+ }, {
122
+ code: 'test-runner-unsuccessful',
123
+ message: 'The test command exited unsuccessfully without structured failed tests explaining the exit.',
124
+ location: null,
125
+ detail: [
126
+ execution.stderr.trim(),
127
+ execution.stdout.trim(),
128
+ `exit code: ${execution.exitCode}`,
129
+ ].filter(Boolean).join('\n'),
130
+ });
131
+ }
132
+ const scan = {
133
+ source: `testing/${options.report.kind}`,
134
+ startedAt,
135
+ finishedAt: now(),
136
+ inspected: run.tests.length,
137
+ };
138
+ return result.fromBreaches(scan, testRunBreaches(run, {
139
+ ...(options.rules.testsPass ? { testsPass: byAlias.testsPass } : {}),
140
+ ...(options.rules.noSkippedTests ? { noSkippedTests: byAlias.noSkippedTests } : {}),
141
+ ...(options.rules.noTodoTests ? { noTodoTests: byAlias.noTodoTests } : {}),
142
+ }));
143
+ }
144
+ finally {
145
+ await rm(temp, { recursive: true, force: true });
146
+ }
147
+ },
148
+ },
149
+ });
150
+ }
151
+ export function defineTestRunner(runner) {
152
+ return runner;
153
+ }
154
+ export function defineTestReport(report) {
155
+ return report;
156
+ }
157
+ export function vitest(options) {
158
+ return testing({
159
+ runner: command({
160
+ command: options.command ?? 'vitest',
161
+ description: 'run Vitest',
162
+ args: ({ reportFile }) => [
163
+ 'run',
164
+ '--reporter=json',
165
+ `--outputFile=${reportFile}`,
166
+ ...(options.configFile ? ['--config', options.configFile] : []),
167
+ ...(options.args ?? []),
168
+ ...(options.files ?? []),
169
+ ],
170
+ }),
171
+ report: jestJson(),
172
+ rules: options.rules,
173
+ });
174
+ }
175
+ export const runner = { command };
176
+ export const report = { jestJson, junitXml };
177
+ export { command, jestJson, junitXml, parseJestJson, parseJunitXml, testCounts, testRunBreaches, };
178
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EACL,QAAQ,EACR,aAAa,EACb,WAAW,EACX,MAAM,GAKP,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,UAAU,EACV,eAAe,GAOhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQjE,SAAS,GAAG;IACV,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,aAAa,CAAC,IAAY,EAAE,IAAmB;IACtD,I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AAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/D,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;gBACvB,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;aACzB;SACF,CAAC;QACF,MAAM,EAAE,QAAQ,EAAE;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,OAAO,EAAW,CAAC;AAC3C,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAW,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,aAAa,EACb,UAAU,EACV,eAAe,GAChB,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { type Breach, type Location, type Rule, type RuleRef } from 'redproof';
2
+ export type TestStatus = 'passed' | 'failed' | 'skipped' | 'todo';
3
+ export type TestFailure = {
4
+ readonly message: string;
5
+ readonly detail?: string;
6
+ readonly comparison?: {
7
+ readonly expected: string;
8
+ readonly actual: string;
9
+ };
10
+ };
11
+ export type TestCase = {
12
+ readonly name: string;
13
+ readonly suite: readonly string[];
14
+ readonly file: string | null;
15
+ readonly status: TestStatus;
16
+ readonly location: Location | null;
17
+ readonly durationMs?: number;
18
+ readonly failure?: TestFailure;
19
+ };
20
+ export type TestRun = {
21
+ readonly tests: readonly TestCase[];
22
+ };
23
+ export type TestRuleOptions = {
24
+ readonly testsPass?: true;
25
+ readonly noSkippedTests?: true;
26
+ readonly noTodoTests?: true;
27
+ };
28
+ export type TestRuleCatalog<O extends TestRuleOptions> = {
29
+ readonly [K in keyof O]: K extends 'testsPass' ? Rule<'testing/tests-pass'> : K extends 'noSkippedTests' ? Rule<'testing/no-skipped-tests'> : K extends 'noTodoTests' ? Rule<'testing/no-todo-tests'> : never;
30
+ };
31
+ export type TestReportCapabilities = {
32
+ readonly todo: boolean;
33
+ };
34
+ export type TestReportFormat = {
35
+ readonly kind: string;
36
+ readonly extension: string;
37
+ readonly capabilities: TestReportCapabilities;
38
+ parse(input: string): TestRun;
39
+ };
40
+ export type TestRunnerContext = {
41
+ readonly root: string;
42
+ readonly reportFile: string;
43
+ };
44
+ export type TestRunnerCompleted = {
45
+ readonly kind: 'completed';
46
+ readonly exitCode: number;
47
+ readonly stdout: string;
48
+ readonly stderr: string;
49
+ };
50
+ export type TestRunnerUnavailable = {
51
+ readonly kind: 'unavailable';
52
+ readonly message: string;
53
+ readonly detail?: string;
54
+ };
55
+ export type TestRunnerResult = TestRunnerCompleted | TestRunnerUnavailable;
56
+ export type TestRunner = {
57
+ readonly description: string;
58
+ run(ctx: TestRunnerContext): Promise<TestRunnerResult>;
59
+ };
60
+ export declare function testRunBreaches<R extends RuleRef>(run: TestRun, rules: {
61
+ readonly testsPass?: Rule<R>;
62
+ readonly noSkippedTests?: Rule<R>;
63
+ readonly noTodoTests?: Rule<R>;
64
+ }): readonly Breach<R>[];
65
+ export declare function testCounts(run: TestRun): Readonly<Record<TestStatus, number>>;
66
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAEX,KAAK,QAAQ,EACb,KAAK,IAAI,EACT,KAAK,OAAO,EACb,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAElE,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE;QACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAA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AAU,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAO7E"}
package/dist/model.js ADDED
@@ -0,0 +1,50 @@
1
+ import { breach, } from 'redproof';
2
+ function displayName(test) {
3
+ return [...test.suite, test.name].filter(Boolean).join(' > ');
4
+ }
5
+ function testDiagnostic(test, code, message) {
6
+ const failure = test.failure;
7
+ return {
8
+ code,
9
+ message,
10
+ location: test.location,
11
+ ...(failure?.comparison ? { comparison: failure.comparison } : {}),
12
+ ...(failure ? { detail: failure.detail ?? failure.message } : {}),
13
+ };
14
+ }
15
+ export function testRunBreaches(run, rules) {
16
+ const breaches = [];
17
+ if (rules.testsPass) {
18
+ for (const test of run.tests.filter(item => item.status === 'failed')) {
19
+ breaches.push(breach(rules.testsPass, testDiagnostic(test, 'test-failed', displayName(test))));
20
+ }
21
+ }
22
+ if (rules.noSkippedTests) {
23
+ for (const test of run.tests.filter(item => item.status === 'skipped')) {
24
+ breaches.push(breach(rules.noSkippedTests, {
25
+ code: 'test-skipped',
26
+ message: displayName(test),
27
+ location: test.location,
28
+ }));
29
+ }
30
+ }
31
+ if (rules.noTodoTests) {
32
+ for (const test of run.tests.filter(item => item.status === 'todo')) {
33
+ breaches.push(breach(rules.noTodoTests, {
34
+ code: 'test-todo',
35
+ message: displayName(test),
36
+ location: test.location,
37
+ }));
38
+ }
39
+ }
40
+ return breaches;
41
+ }
42
+ export function testCounts(run) {
43
+ return {
44
+ passed: run.tests.filter(test => test.status === 'passed').length,
45
+ failed: run.tests.filter(test => test.status === 'failed').length,
46
+ skipped: run.tests.filter(test => test.status === 'skipped').length,
47
+ todo: run.tests.filter(test => test.status === 'todo').length,
48
+ };
49
+ }
50
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,GAMP,MAAM,UAAU,CAAC;AA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,CAAC,MAAM;KAC9D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { TestReportFormat, TestRun } from '../model.ts';
2
+ export declare function parseJestJson(input: string): TestRun;
3
+ export declare function jestJson(): TestReportFormat;
4
+ //# sourceMappingURL=jest-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest-json.d.ts","sourceRoot":"","sources":["../../src/reports/jest-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,gBAAgB,EAAE,OAAO,EAAc,MAAM,aAAa,CAAC;AAyCnF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAqCpD;AAED,wBAAgB,QAAQ,IAAI,gBAAgB,CAO3C"}
@@ -0,0 +1,58 @@
1
+ function statusOf(status) {
2
+ switch (status) {
3
+ case 'passed':
4
+ return 'passed';
5
+ case 'failed':
6
+ return 'failed';
7
+ case 'todo':
8
+ return 'todo';
9
+ case 'pending':
10
+ case 'skipped':
11
+ case 'disabled':
12
+ return 'skipped';
13
+ default:
14
+ throw new Error(`Unsupported Jest-compatible test status: ${String(status)}.`);
15
+ }
16
+ }
17
+ export function parseJestJson(input) {
18
+ const parsed = JSON.parse(input);
19
+ if (!Array.isArray(parsed.testResults)) {
20
+ throw new Error('Jest-compatible JSON report is missing testResults.');
21
+ }
22
+ const tests = [];
23
+ for (const file of parsed.testResults) {
24
+ if (!Array.isArray(file.assertionResults)) {
25
+ throw new Error('Jest-compatible JSON test result is missing assertionResults.');
26
+ }
27
+ for (const assertion of file.assertionResults) {
28
+ const status = statusOf(assertion.status);
29
+ const failureMessage = assertion.failureMessages?.filter(Boolean).join('\n\n');
30
+ const line = assertion.location?.line ?? null;
31
+ const column = assertion.location?.column ?? null;
32
+ const location = file.name
33
+ ? { file: file.name, line, column }
34
+ : null;
35
+ tests.push({
36
+ name: assertion.title ?? assertion.fullName?.trim() ?? '<unnamed test>',
37
+ suite: (assertion.ancestorTitles ?? []).filter(Boolean),
38
+ file: file.name ?? null,
39
+ status,
40
+ location,
41
+ ...(typeof assertion.duration === 'number' ? { durationMs: assertion.duration } : {}),
42
+ ...(failureMessage
43
+ ? { failure: { message: failureMessage } }
44
+ : {}),
45
+ });
46
+ }
47
+ }
48
+ return { tests };
49
+ }
50
+ export function jestJson() {
51
+ return {
52
+ kind: 'jest-json',
53
+ extension: '.json',
54
+ capabilities: { todo: true },
55
+ parse: parseJestJson,
56
+ };
57
+ }
58
+ //# sourceMappingURL=jest-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest-json.js","sourceRoot":"","sources":["../../src/reports/jest-json.ts"],"names":[],"mappings":"AAwBA,SAAS,QAAQ,CAAC,MAA0B;IAC1C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,SAAS,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,UAAU;YACb,OAAO,SAAS,CAAC;QACnB;YACE,MAAM,IAAI,KAAK,CAAC,4CAA4C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAmB,CAAC;IACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,KAAK,GAAe,EAAE,CAAC;IAE7B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,KAA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AACnB,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,OAAO;QAClB,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;QAC5B,KAAK,EAAE,aAAa;KACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { TestReportFormat, TestRun } from '../model.ts';
2
+ export declare function parseJunitXml(input: string): TestRun;
3
+ export declare function junitXml(): TestReportFormat;
4
+ //# sourceMappingURL=junit-xml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"junit-xml.d.ts","sourceRoot":"","sources":["../../src/reports/junit-xml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAkCvE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CA0CpD;AAED,wBAAgB,QAAQ,IAAI,gBAAgB,CAO3C"}
@@ -0,0 +1,74 @@
1
+ function decodeXml(value) {
2
+ return value
3
+ .replaceAll('&lt;', '<')
4
+ .replaceAll('&gt;', '>')
5
+ .replaceAll('&quot;', '"')
6
+ .replaceAll('&apos;', "'")
7
+ .replaceAll('&amp;', '&');
8
+ }
9
+ function attributes(raw) {
10
+ const attrs = {};
11
+ const re = /([:\w.-]+)\s*=\s*("([^"]*)"|'([^']*)')/g;
12
+ for (let match = re.exec(raw); match; match = re.exec(raw)) {
13
+ attrs[match[1]] = decodeXml(match[3] ?? match[4] ?? '');
14
+ }
15
+ return attrs;
16
+ }
17
+ function element(body, name) {
18
+ const paired = new RegExp(`<${name}\\b([^>]*)>([\\s\\S]*?)<\\/${name}>`, 'i').exec(body);
19
+ if (paired) {
20
+ return { attrs: attributes(paired[1] ?? ''), text: decodeXml((paired[2] ?? '').trim()) };
21
+ }
22
+ const selfClosing = new RegExp(`<${name}\\b([^>]*)\\/>`, 'i').exec(body);
23
+ if (selfClosing) {
24
+ return { attrs: attributes(selfClosing[1] ?? ''), text: '' };
25
+ }
26
+ return null;
27
+ }
28
+ export function parseJunitXml(input) {
29
+ const tests = [];
30
+ const testcase = /<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/gi;
31
+ for (let match = testcase.exec(input); match; match = testcase.exec(input)) {
32
+ const attrs = attributes(match[1] ?? '');
33
+ const body = match[2] ?? '';
34
+ const failure = element(body, 'failure') ?? element(body, 'error');
35
+ const skipped = element(body, 'skipped');
36
+ const status = failure ? 'failed' : skipped ? 'skipped' : 'passed';
37
+ const file = attrs.file ?? null;
38
+ const line = attrs.line ? Number.parseInt(attrs.line, 10) : null;
39
+ const durationSeconds = attrs.time ? Number.parseFloat(attrs.time) : Number.NaN;
40
+ const suite = attrs.classname ? [attrs.classname] : [];
41
+ tests.push({
42
+ name: attrs.name ?? '<unnamed test>',
43
+ suite,
44
+ file,
45
+ status,
46
+ location: file ? { file, line: Number.isFinite(line) ? line : null, column: null } : null,
47
+ ...(Number.isFinite(durationSeconds) ? { durationMs: durationSeconds * 1000 } : {}),
48
+ ...(failure
49
+ ? {
50
+ failure: {
51
+ message: failure.attrs.message ?? (failure.text || 'Test failed.'),
52
+ ...(failure.text ? { detail: failure.text } : {}),
53
+ },
54
+ }
55
+ : {}),
56
+ });
57
+ }
58
+ if (tests.length === 0 && /<testcase\b/i.test(input)) {
59
+ throw new Error('JUnit XML report contains testcase elements that could not be parsed.');
60
+ }
61
+ if (!/<testsuites?\b/i.test(input)) {
62
+ throw new Error('JUnit XML report is missing testsuite/testsuites root content.');
63
+ }
64
+ return { tests };
65
+ }
66
+ export function junitXml() {
67
+ return {
68
+ kind: 'junit-xml',
69
+ extension: '.xml',
70
+ capabilities: { todo: false },
71
+ parse: parseJunitXml,
72
+ };
73
+ }
74
+ //# sourceMappingURL=junit-xml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"junit-xml.js","sourceRoot":"","sources":["../../src/reports/junit-xml.ts"],"names":[],"mappings":"A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CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;QAC7B,KAAK,EAAE,aAAa;KACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { TestRunner, TestRunnerContext } from './model.ts';
2
+ export type CommandArgs = readonly string[] | ((ctx: TestRunnerContext) => readonly string[]);
3
+ export type CommandRunnerOptions = {
4
+ readonly command: string;
5
+ readonly args?: CommandArgs;
6
+ readonly env?: Readonly<Record<string, string>>;
7
+ readonly description?: string;
8
+ };
9
+ export declare function command(options: CommandRunnerOptions): TestRunner;
10
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AAElF,MAAM,MAAM,WAAW,GAAG,SAAS,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,iBAAiB,KAAK,SAAS,MAAM,EAAE,CAAC,CAAC;AAE9F,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAOF,wBAAgB,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,UAAU,CAsDjE"}
package/dist/runner.js ADDED
@@ -0,0 +1,56 @@
1
+ import { spawn } from 'node:child_process';
2
+ function argsFor(args, ctx) {
3
+ if (!args)
4
+ return [];
5
+ return typeof args === 'function' ? args(ctx) : args;
6
+ }
7
+ export function command(options) {
8
+ return {
9
+ description: options.description ?? `run ${options.command}`,
10
+ async run(ctx) {
11
+ const args = argsFor(options.args, ctx);
12
+ return new Promise(resolve => {
13
+ const child = spawn(options.command, args, {
14
+ cwd: ctx.root,
15
+ env: {
16
+ ...process.env,
17
+ REDPROOF_TEST_REPORT: ctx.reportFile,
18
+ ...options.env,
19
+ },
20
+ stdio: ['ignore', 'pipe', 'pipe'],
21
+ });
22
+ let stdout = '';
23
+ let stderr = '';
24
+ child.stdout?.setEncoding('utf8');
25
+ child.stderr?.setEncoding('utf8');
26
+ child.stdout?.on('data', chunk => { stdout += chunk; });
27
+ child.stderr?.on('data', chunk => { stderr += chunk; });
28
+ child.once('error', error => {
29
+ resolve({
30
+ kind: 'unavailable',
31
+ message: `Could not start test command ${options.command}.`,
32
+ detail: error.message,
33
+ });
34
+ });
35
+ child.once('close', (code, signal) => {
36
+ if (signal) {
37
+ const detail = stderr || stdout;
38
+ resolve({
39
+ kind: 'unavailable',
40
+ message: `Test command ${options.command} was terminated by ${signal}.`,
41
+ ...(detail ? { detail } : {}),
42
+ });
43
+ return;
44
+ }
45
+ resolve({
46
+ kind: 'completed',
47
+ exitCode: code ?? 1,
48
+ stdout,
49
+ stderr,
50
+ });
51
+ });
52
+ });
53
+ },
54
+ };
55
+ }
56
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAY3C,SAAS,OAAO,CAAC,IAA6B,EAAE,GAAsB;IACpE,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,OAAO,OAAO,IAAI,KAAK,UAAU,CAAC,C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;wBACnB,OAAO,EAAE,gCAAgC,OAAO,CAAC,OAAO,GAAG;wBAC3D,MAAM,EAAE,KAAK,CAAC,OAAO;qBACtB,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBAEH,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;oBACnC,IAAI,MAAM,EAAE,CAAC;wBACX,MAAM,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC;wBAChC,OAAO,CAAC;4BACN,IAAI,EAAE,aAAa;4BACnB,OAAO,EAAE,gBAAgB,OAAO,CAAC,OAAO,sBAAsB,MAAM,GAAG;4BACvE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;yBAC9B,CAAC,CAAC;wBACH,OAAO;oBACT,CAAC;oBAED,OAAO,CAAC;wBACN,IAAI,EAAE,WAAW;wBACjB,QAAQ,EAAE,IAAI,IAAI,CAAC;wBACnB,MAAM;wBACN,MAAM;qBACP,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@redproof/testing",
3
+ "version": "0.0.0",
4
+ "description": "Redproof adapter for test suites and JUnit XML reports.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "engines": {
16
+ "node": ">=22.6"
17
+ },
18
+ "dependencies": {
19
+ "redproof": "0.0.0"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/schalermthai/redproof.git",
24
+ "directory": "packages/testing"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "license": "Apache-2.0"
30
+ }