html-validate 11.1.0 → 11.2.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/dist/cjs/cli.js +7 -1
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/core.js +6 -3
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/{matchers.js → jest-matchers.js} +66 -38
- package/dist/cjs/jest-matchers.js.map +1 -0
- package/dist/cjs/{matcher-utils.js → jest-utils.js} +1 -8
- package/dist/cjs/jest-utils.js.map +1 -0
- package/dist/cjs/jest-worker.js.map +1 -1
- package/dist/cjs/jest.js +10 -13
- package/dist/cjs/jest.js.map +1 -1
- package/dist/cjs/vitest-matchers.js +281 -0
- package/dist/cjs/vitest-matchers.js.map +1 -0
- package/dist/cjs/vitest-utils.js +120 -0
- package/dist/cjs/vitest-utils.js.map +1 -0
- package/dist/cjs/vitest-worker.d.ts +1 -0
- package/dist/cjs/vitest-worker.js +63 -0
- package/dist/cjs/vitest-worker.js.map +1 -0
- package/dist/cjs/vitest.js +9 -7
- package/dist/cjs/vitest.js.map +1 -1
- package/dist/esm/browser.js +1 -1
- package/dist/esm/cli.js +9 -3
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/core-browser.js +1 -1
- package/dist/esm/core-nodejs.js +1 -1
- package/dist/esm/core.js +5 -3
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/html-validate.js +2 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/jest-matchers.js +263 -0
- package/dist/esm/jest-matchers.js.map +1 -0
- package/dist/esm/{matcher-utils.js → jest-utils.js} +3 -9
- package/dist/esm/jest-utils.js.map +1 -0
- package/dist/esm/jest-worker.js.map +1 -1
- package/dist/esm/jest.js +6 -9
- package/dist/esm/jest.js.map +1 -1
- package/dist/esm/{matchers.js → vitest-matchers.js} +62 -45
- package/dist/esm/vitest-matchers.js.map +1 -0
- package/dist/esm/vitest-utils.js +116 -0
- package/dist/esm/vitest-utils.js.map +1 -0
- package/dist/esm/vitest-worker.d.ts +1 -0
- package/dist/esm/vitest-worker.js +62 -0
- package/dist/esm/vitest-worker.js.map +1 -0
- package/dist/esm/vitest.js +9 -7
- package/dist/esm/vitest.js.map +1 -1
- package/dist/types/vitest.d.ts +18 -0
- package/package.json +5 -5
- package/dist/cjs/jest-diff.js +0 -41
- package/dist/cjs/jest-diff.js.map +0 -1
- package/dist/cjs/matcher-utils.js.map +0 -1
- package/dist/cjs/matchers-jestonly.js +0 -44
- package/dist/cjs/matchers-jestonly.js.map +0 -1
- package/dist/cjs/matchers.js.map +0 -1
- package/dist/esm/jest-diff.js +0 -20
- package/dist/esm/jest-diff.js.map +0 -1
- package/dist/esm/matcher-utils.js.map +0 -1
- package/dist/esm/matchers-jestonly.js +0 -41
- package/dist/esm/matchers-jestonly.js.map +0 -1
- package/dist/esm/matchers.js.map +0 -1
|
@@ -2,8 +2,8 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { parseArgs } from 'node:util';
|
|
4
4
|
import kleur from 'kleur';
|
|
5
|
-
import {
|
|
6
|
-
import { M as Mode, m as modeToFlag, C as CLI,
|
|
5
|
+
import { Q as name, a3 as version, S as SchemaValidationError, K as isUserError, q as bugs } from './core.js';
|
|
6
|
+
import { M as Mode, m as modeToFlag, C as CLI, a as haveImportMetaResolve, I as ImportResolveMissingError, d as dump, p as printConfig, i as init, l as lint, h as handleSchemaValidationError } from './cli.js';
|
|
7
7
|
import 'ajv';
|
|
8
8
|
import './elements.js';
|
|
9
9
|
import './meta-helper.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { F as FileSystemConfigLoader, H as HtmlValidate, c as cjsResolver, a as compatibilityCheck, e as esmResolver } from './core-nodejs.js';
|
|
2
|
-
export { A as Attribute,
|
|
2
|
+
export { A as Attribute, C as Config, a as ConfigError, b as ConfigLoader, D as DOMNode, c as DOMTokenList, d as DOMTree, e as DynamicValue, f as EventHandler, H as HtmlElement, M as MetaCopyableProperty, g as MetaTable, N as NestedError, h as Node, P as Parser, i as PerformanceTracker, R as Reporter, j as ResolvedConfig, k as Rule, S as SchemaValidationError, l as Severity, m as StaticConfigLoader, T as TextClassification, n as TextContent, o as TextNode, U as UserError, W as WrappedError, p as ariaNaming, r as classifyNodeText, X as configPresets, w as defineConfig, x as definePlugin, F as formatterFactory, K as isUserError, O as keywordPatternMatcher, Y as ruleExists, Z as sliceLocation, _ as staticResolver, a3 as version, a5 as walk } from './core.js';
|
|
3
3
|
export { C as CLI } from './cli.js';
|
|
4
4
|
export { d as defineMetadata, m as metadataHelper } from './meta-helper.js';
|
|
5
5
|
import 'node:fs';
|
|
@@ -17,4 +17,5 @@ import '@html-validate/stylish';
|
|
|
17
17
|
import 'semver';
|
|
18
18
|
import 'node:path/posix';
|
|
19
19
|
import 'prompts';
|
|
20
|
+
import 'node:util';
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { d as diverge, a as createSyncFn, c as codeframe, i as isThenable } from './jest-utils.js';
|
|
2
|
+
import { v as deepmerge, L as jestWorkerPath } from './core.js';
|
|
3
|
+
import { toMatchSnapshot, toMatchInlineSnapshot } from 'jest-snapshot';
|
|
4
|
+
|
|
5
|
+
function createMatcher$6() {
|
|
6
|
+
function toBeValid(report) {
|
|
7
|
+
if (report.valid) {
|
|
8
|
+
return {
|
|
9
|
+
pass: true,
|
|
10
|
+
message: (
|
|
11
|
+
/* istanbul ignore next */
|
|
12
|
+
() => "Result should not contain error"
|
|
13
|
+
)
|
|
14
|
+
};
|
|
15
|
+
} else {
|
|
16
|
+
const firstError = report.results[0].messages[0];
|
|
17
|
+
return {
|
|
18
|
+
pass: false,
|
|
19
|
+
message: () => `Result should be valid but had error "${firstError.message}"`
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return diverge(toBeValid);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function createMatcher$5() {
|
|
27
|
+
function toBeInvalid(report) {
|
|
28
|
+
if (report.valid) {
|
|
29
|
+
return {
|
|
30
|
+
pass: false,
|
|
31
|
+
message: () => "Result should be invalid but had no errors"
|
|
32
|
+
};
|
|
33
|
+
} else {
|
|
34
|
+
return {
|
|
35
|
+
pass: true,
|
|
36
|
+
message: (
|
|
37
|
+
/* istanbul ignore next */
|
|
38
|
+
() => "Result should not contain error"
|
|
39
|
+
)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return diverge(toBeInvalid);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isMessage(arg) {
|
|
47
|
+
if (!arg || typeof arg !== "object") {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return [
|
|
51
|
+
"ruleId",
|
|
52
|
+
"severity",
|
|
53
|
+
"message",
|
|
54
|
+
"offset",
|
|
55
|
+
"line",
|
|
56
|
+
"column",
|
|
57
|
+
"size",
|
|
58
|
+
"selector",
|
|
59
|
+
"context"
|
|
60
|
+
].some((key) => key in arg);
|
|
61
|
+
}
|
|
62
|
+
function isConfig(arg) {
|
|
63
|
+
if (!arg || typeof arg !== "object") {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return ["root", "extends", "elements", "plugin", "transform", "rules"].some((key) => key in arg);
|
|
67
|
+
}
|
|
68
|
+
function isString(arg) {
|
|
69
|
+
return typeof arg === "string";
|
|
70
|
+
}
|
|
71
|
+
function getMarkup(src) {
|
|
72
|
+
if (typeof HTMLElement !== "undefined" && src instanceof HTMLElement) {
|
|
73
|
+
return src.outerHTML;
|
|
74
|
+
}
|
|
75
|
+
if (typeof src === "string") {
|
|
76
|
+
return src;
|
|
77
|
+
} else {
|
|
78
|
+
throw new TypeError(`Failed to get markup from "${typeof src}" argument`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function createMatcher$4(expect) {
|
|
82
|
+
function toHTMLValidate(actual, arg0, arg1, arg2) {
|
|
83
|
+
const markup = getMarkup(actual);
|
|
84
|
+
const message = isMessage(arg0) ? arg0 : void 0;
|
|
85
|
+
const config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : void 0;
|
|
86
|
+
const filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2;
|
|
87
|
+
return toHTMLValidateImpl.call(this, expect, markup, message, config, filename);
|
|
88
|
+
}
|
|
89
|
+
return diverge(toHTMLValidate);
|
|
90
|
+
}
|
|
91
|
+
function toHTMLValidateImpl(expect, actual, expectedError, userConfig, filename) {
|
|
92
|
+
const defaultConfig = {
|
|
93
|
+
rules: {
|
|
94
|
+
/* jsdom normalizes style so disabling rule when using this matcher or it
|
|
95
|
+
* gets quite noisy when configured with self-closing */
|
|
96
|
+
"void-style": "off"
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const config = deepmerge(defaultConfig, userConfig ?? {});
|
|
100
|
+
const actualFilename = filename ?? this.testPath ?? "inline";
|
|
101
|
+
const syncFn = createSyncFn(jestWorkerPath);
|
|
102
|
+
const report = syncFn(actual, actualFilename, config);
|
|
103
|
+
const pass = report.valid;
|
|
104
|
+
const result = report.results[0];
|
|
105
|
+
if (pass) {
|
|
106
|
+
return { pass, message: () => "HTML is valid when an error was expected" };
|
|
107
|
+
} else {
|
|
108
|
+
if (expectedError) {
|
|
109
|
+
const actual2 = result.messages;
|
|
110
|
+
const expected = expect.arrayContaining([expect.objectContaining(expectedError)]);
|
|
111
|
+
const errorPass = this.equals(actual2, expected);
|
|
112
|
+
const diffString = this.utils.diff(expected, actual2, {
|
|
113
|
+
expand: this.expand,
|
|
114
|
+
aAnnotation: "Expected error",
|
|
115
|
+
bAnnotation: "Actual error"
|
|
116
|
+
});
|
|
117
|
+
const hint = this.utils.matcherHint(".not.toHTMLValidate", void 0, void 0, {
|
|
118
|
+
comment: "expected error"
|
|
119
|
+
});
|
|
120
|
+
const expectedErrorMessage = () => [
|
|
121
|
+
hint,
|
|
122
|
+
"",
|
|
123
|
+
"Expected error to be present:",
|
|
124
|
+
this.utils.printExpected(expectedError),
|
|
125
|
+
/* istanbul ignore next */
|
|
126
|
+
diffString ? `
|
|
127
|
+
${diffString}` : ""
|
|
128
|
+
].join("\n");
|
|
129
|
+
return { pass: !errorPass, message: expectedErrorMessage };
|
|
130
|
+
}
|
|
131
|
+
const errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);
|
|
132
|
+
return {
|
|
133
|
+
pass,
|
|
134
|
+
message: () => ["Expected HTML to be valid but had the following errors:", ""].concat(errors).join("\n")
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function toHaveErrorImpl(context, expect, actual, expected) {
|
|
140
|
+
const flattened = actual.results.flatMap((result) => result.messages);
|
|
141
|
+
const matcher = [expect.objectContaining(expected)];
|
|
142
|
+
const pass = context.equals(flattened, matcher);
|
|
143
|
+
const diffString = context.utils.diff(matcher, flattened, { expand: context.expand });
|
|
144
|
+
const hint = context.utils.matcherHint(".toHaveError");
|
|
145
|
+
const prettyExpected = context.utils.printExpected(matcher);
|
|
146
|
+
const prettyReceived = context.utils.printReceived(flattened);
|
|
147
|
+
const resultMessage = () => {
|
|
148
|
+
return [
|
|
149
|
+
hint,
|
|
150
|
+
"",
|
|
151
|
+
"Expected error to equal:",
|
|
152
|
+
` ${prettyExpected}`,
|
|
153
|
+
"Received:",
|
|
154
|
+
` ${prettyReceived}`,
|
|
155
|
+
/* istanbul ignore next */
|
|
156
|
+
diffString ? `
|
|
157
|
+
Difference:
|
|
158
|
+
|
|
159
|
+
${diffString}` : ""
|
|
160
|
+
].join("\n");
|
|
161
|
+
};
|
|
162
|
+
return { pass, message: resultMessage };
|
|
163
|
+
}
|
|
164
|
+
function createMatcher$3(expect) {
|
|
165
|
+
function toHaveError(actual, arg1, arg2, arg3) {
|
|
166
|
+
if (typeof arg1 === "string") {
|
|
167
|
+
const expected = {
|
|
168
|
+
ruleId: arg1,
|
|
169
|
+
message: arg2
|
|
170
|
+
};
|
|
171
|
+
if (arg3 !== void 0) {
|
|
172
|
+
expected.context = arg3;
|
|
173
|
+
}
|
|
174
|
+
return toHaveErrorImpl(this, expect, actual, expected);
|
|
175
|
+
} else {
|
|
176
|
+
return toHaveErrorImpl(this, expect, actual, arg1);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return diverge(toHaveError);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function createMatcher$2(expect) {
|
|
183
|
+
function toHaveErrors(report, errors) {
|
|
184
|
+
const flattened = report.results.flatMap((result) => result.messages);
|
|
185
|
+
const matcher = errors.map((entry) => {
|
|
186
|
+
if (Array.isArray(entry)) {
|
|
187
|
+
const [ruleId, message] = entry;
|
|
188
|
+
return expect.objectContaining({ ruleId, message });
|
|
189
|
+
} else {
|
|
190
|
+
return expect.objectContaining(entry);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
const pass = this.equals(flattened, matcher);
|
|
194
|
+
const diffString = this.utils.diff(matcher, flattened, { expand: this.expand });
|
|
195
|
+
const resultMessage = () => this.utils.matcherHint(".toHaveErrors") + `
|
|
196
|
+
|
|
197
|
+
Expected error to equal:
|
|
198
|
+
${this.utils.printExpected(matcher)}
|
|
199
|
+
Received:
|
|
200
|
+
${this.utils.printReceived(flattened)}` + /* istanbul ignore next */
|
|
201
|
+
(diffString ? `
|
|
202
|
+
|
|
203
|
+
Difference:
|
|
204
|
+
|
|
205
|
+
${diffString}` : "");
|
|
206
|
+
return { pass, message: resultMessage };
|
|
207
|
+
}
|
|
208
|
+
return diverge(toHaveErrors);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function getResults(filename, value) {
|
|
212
|
+
if (typeof value === "string") {
|
|
213
|
+
const syncFn = createSyncFn(jestWorkerPath);
|
|
214
|
+
const report = syncFn(value, filename, {
|
|
215
|
+
rules: {
|
|
216
|
+
"void-style": "off"
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
return report.results.map((it) => {
|
|
220
|
+
return { ...it, filePath: "inline" };
|
|
221
|
+
});
|
|
222
|
+
} else {
|
|
223
|
+
return value.results;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function createMatcher$1() {
|
|
228
|
+
function toMatchCodeframe(actual, ...rest) {
|
|
229
|
+
const filename = this.testPath ?? "inline";
|
|
230
|
+
const results = getResults(filename, actual);
|
|
231
|
+
const snapshot = codeframe(results).replaceAll(/\s+$/gm, "");
|
|
232
|
+
return toMatchSnapshot.call(this, snapshot, ...rest);
|
|
233
|
+
}
|
|
234
|
+
return diverge(toMatchCodeframe);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function toMatchInlineCodeframeImpl(context, actual, ...rest) {
|
|
238
|
+
const filename = context.testPath ?? "inline";
|
|
239
|
+
const results = getResults(filename, actual);
|
|
240
|
+
const snapshot = codeframe(results).replaceAll(/\s+$/gm, "");
|
|
241
|
+
return toMatchInlineSnapshot.call(context, snapshot, ...rest);
|
|
242
|
+
}
|
|
243
|
+
function toMatchInlineCodeframe(actual, ...rest) {
|
|
244
|
+
const context = {
|
|
245
|
+
...this,
|
|
246
|
+
/* Capture the original stack frames as they are needed by "jest-snapshot"
|
|
247
|
+
* to determine where to write the inline snapshots. When resolving the
|
|
248
|
+
* promise the original stack frames are lost and the snapshot will be
|
|
249
|
+
* written in this files instaed. */
|
|
250
|
+
error: new Error("stacktrace")
|
|
251
|
+
};
|
|
252
|
+
if (isThenable(actual)) {
|
|
253
|
+
return actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));
|
|
254
|
+
} else {
|
|
255
|
+
return toMatchInlineCodeframeImpl(context, actual, ...rest);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function createMatcher() {
|
|
259
|
+
return toMatchInlineCodeframe;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export { createMatcher$1 as a, createMatcher$2 as b, createMatcher as c, createMatcher$3 as d, createMatcher$4 as e, createMatcher$5 as f, createMatcher$6 as g };
|
|
263
|
+
//# sourceMappingURL=jest-matchers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-matchers.js","sources":["../../src/jest/matchers/to-be-valid.ts","../../src/jest/matchers/to-be-invalid.ts","../../src/jest/matchers/to-htmlvalidate.ts","../../src/jest/matchers/to-have-error.ts","../../src/jest/matchers/to-have-errors.ts","../../src/jest/matchers/get-results.ts","../../src/jest/matchers/to-match-codeframe.ts","../../src/jest/matchers/to-match-inline-codeframe.ts"],"sourcesContent":["import { type SyncExpectationResult } from \"expect\";\nimport { type Report } from \"../../reporter\";\nimport { type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeValid(report: Report): SyncExpectationResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t} else {\n\t\t\tconst firstError = report.results[0].messages[0];\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => `Result should be valid but had error \"${firstError.message}\"`,\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeValid);\n}\n\nexport { createMatcher as toBeValid };\n","import { type SyncExpectationResult } from \"expect\";\nimport { type Report } from \"../../reporter\";\nimport { type MaybeAsyncCallback, diverge } from \"../utils\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report, []> {\n\tfunction toBeInvalid(report: Report): SyncExpectationResult {\n\t\tif (report.valid) {\n\t\t\treturn {\n\t\t\t\tpass: false,\n\t\t\t\tmessage: () => \"Result should be invalid but had no errors\",\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tpass: true,\n\t\t\t\tmessage: /* istanbul ignore next */ () => \"Result should not contain error\",\n\t\t\t};\n\t\t}\n\t}\n\treturn diverge(toBeInvalid);\n}\n\nexport { createMatcher as toBeInvalid };\n","import { type expect } from \"@jest/globals\";\nimport deepmerge from \"deepmerge\";\nimport { type MatcherContext, type SyncExpectationResult } from \"expect\";\nimport { type ConfigData } from \"../../config\";\nimport { type Message } from \"../../message\";\nimport { type MaybeAsyncCallback, diverge } from \"../utils\";\nimport { type ValidateStringFn, createSyncFn, jestWorkerPath } from \"../worker\";\n\ntype JestExpect = typeof expect;\n\nfunction isMessage(arg: Arg1 | undefined): arg is Partial<Message> {\n\tif (!arg || typeof arg !== \"object\") {\n\t\treturn false;\n\t}\n\treturn [\n\t\t\"ruleId\",\n\t\t\"severity\",\n\t\t\"message\",\n\t\t\"offset\",\n\t\t\"line\",\n\t\t\"column\",\n\t\t\"size\",\n\t\t\"selector\",\n\t\t\"context\",\n\t].some((key) => key in arg);\n}\n\nfunction isConfig(arg: Arg1 | undefined): arg is ConfigData {\n\tif (!arg || typeof arg !== \"object\") {\n\t\treturn false;\n\t}\n\treturn [\"root\", \"extends\", \"elements\", \"plugin\", \"transform\", \"rules\"].some((key) => key in arg);\n}\n\nfunction isString(arg: Arg1 | undefined): arg is string {\n\treturn typeof arg === \"string\";\n}\n\nfunction getMarkup(src: unknown): string {\n\tif (typeof HTMLElement !== \"undefined\" && src instanceof HTMLElement) {\n\t\treturn (src as { outerHTML: string }).outerHTML;\n\t}\n\t/* istanbul ignore else: prototype only allows string or HTMLElement */\n\tif (typeof src === \"string\") {\n\t\treturn src;\n\t} else {\n\t\tthrow new TypeError(`Failed to get markup from \"${typeof src}\" argument`);\n\t}\n}\n\ntype Arg1 = Partial<Message> | ConfigData | string;\ntype Arg2 = ConfigData | string;\ntype Arg3 = string;\n\nfunction createMatcher(expect: JestExpect): MaybeAsyncCallback<unknown, [Arg1?, Arg2?, Arg3?]> {\n\tfunction toHTMLValidate(\n\t\tthis: MatcherContext,\n\t\tactual: unknown,\n\t\targ0?: Arg1,\n\t\targ1?: Arg2,\n\t\targ2?: Arg3,\n\t): SyncExpectationResult {\n\t\tconst markup = getMarkup(actual);\n\t\tconst message = isMessage(arg0) ? arg0 : undefined;\n\t\tconst config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : undefined; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\tconst filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2; // eslint-disable-line sonarjs/no-nested-conditional -- easier to read than the alternative */\n\t\treturn toHTMLValidateImpl.call(this, expect, markup, message, config, filename);\n\t}\n\treturn diverge(toHTMLValidate);\n}\n\n/* eslint-disable-next-line @typescript-eslint/max-params -- technical debt */\nfunction toHTMLValidateImpl(\n\tthis: MatcherContext,\n\texpect: JestExpect,\n\tactual: string,\n\texpectedError?: Partial<Message>,\n\tuserConfig?: ConfigData,\n\tfilename?: string,\n): SyncExpectationResult {\n\tconst defaultConfig = {\n\t\trules: {\n\t\t\t/* jsdom normalizes style so disabling rule when using this matcher or it\n\t\t\t * gets quite noisy when configured with self-closing */\n\t\t\t\"void-style\": \"off\",\n\t\t},\n\t};\n\tconst config = deepmerge(defaultConfig, userConfig ?? {});\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst actualFilename = filename ?? this.testPath ?? \"inline\";\n\n\tconst syncFn = createSyncFn<ValidateStringFn>(jestWorkerPath);\n\tconst report = syncFn(actual, actualFilename, config);\n\tconst pass = report.valid;\n\tconst result = report.results[0];\n\tif (pass) {\n\t\treturn { pass, message: () => \"HTML is valid when an error was expected\" };\n\t} else {\n\t\tif (expectedError) {\n\t\t\tconst actual = result.messages;\n\t\t\tconst expected = expect.arrayContaining([expect.objectContaining(expectedError)]);\n\t\t\tconst errorPass = this.equals(actual, expected);\n\t\t\tconst diffString = this.utils.diff(expected, actual, {\n\t\t\t\texpand: this.expand,\n\t\t\t\taAnnotation: \"Expected error\",\n\t\t\t\tbAnnotation: \"Actual error\",\n\t\t\t});\n\t\t\tconst hint = this.utils.matcherHint(\".not.toHTMLValidate\", undefined, undefined, {\n\t\t\t\tcomment: \"expected error\",\n\t\t\t});\n\t\t\tconst expectedErrorMessage = (): string =>\n\t\t\t\t[\n\t\t\t\t\thint,\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Expected error to be present:\",\n\t\t\t\t\tthis.utils.printExpected(expectedError),\n\t\t\t\t\t/* istanbul ignore next */ diffString ? `\\n${diffString}` : \"\",\n\t\t\t\t].join(\"\\n\");\n\t\t\treturn { pass: !errorPass, message: expectedErrorMessage };\n\t\t}\n\n\t\tconst errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);\n\t\treturn {\n\t\t\tpass,\n\t\t\tmessage: () =>\n\t\t\t\t[\"Expected HTML to be valid but had the following errors:\", \"\"].concat(errors).join(\"\\n\"),\n\t\t};\n\t}\n}\n\nexport { createMatcher as toHTMLValidate };\n","import { type expect } from \"@jest/globals\";\nimport { type MatcherContext, type SyncExpectationResult } from \"expect\";\nimport { type Message } from \"../../message\";\nimport { type Report } from \"../../reporter\";\nimport { type MaybeAsyncCallback, diverge } from \"../utils\";\n\ntype JestExpect = typeof expect;\n\nfunction toHaveErrorImpl(\n\tcontext: MatcherContext,\n\texpect: JestExpect,\n\tactual: Report,\n\texpected: Partial<Message>,\n): SyncExpectationResult {\n\tconst flattened = actual.results.flatMap((result) => result.messages);\n\tconst matcher = [expect.objectContaining(expected)];\n\tconst pass = context.equals(flattened, matcher);\n\tconst diffString = context.utils.diff(matcher, flattened, { expand: context.expand });\n\tconst hint = context.utils.matcherHint(\".toHaveError\");\n\tconst prettyExpected = context.utils.printExpected(matcher);\n\tconst prettyReceived = context.utils.printReceived(flattened);\n\tconst resultMessage = (): string => {\n\t\treturn [\n\t\t\thint,\n\t\t\t\"\",\n\t\t\t\"Expected error to equal:\",\n\t\t\t` ${prettyExpected}`,\n\t\t\t\"Received:\",\n\t\t\t` ${prettyReceived}`,\n\t\t\t/* istanbul ignore next */ diffString ? `\\nDifference:\\n\\n${diffString}` : \"\",\n\t\t].join(\"\\n\");\n\t};\n\treturn { pass, message: resultMessage };\n}\n\nfunction createMatcher(\n\texpect: JestExpect,\n):\n\t| MaybeAsyncCallback<Report, [Partial<Message>]>\n\t| MaybeAsyncCallback<Report, [string, string, unknown?]> {\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\terror: Partial<Message>,\n\t): SyncExpectationResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\truleId: string,\n\t\tmessage: string,\n\t\tcontext?: unknown,\n\t): SyncExpectationResult;\n\tfunction toHaveError(\n\t\tthis: MatcherContext,\n\t\tactual: Report,\n\t\targ1: string | Partial<Message>,\n\t\targ2?: string,\n\t\targ3?: unknown,\n\t): SyncExpectationResult {\n\t\tif (typeof arg1 === \"string\") {\n\t\t\tconst expected: Partial<Message> = {\n\t\t\t\truleId: arg1,\n\t\t\t\tmessage: arg2,\n\t\t\t};\n\t\t\tif (arg3 !== undefined) {\n\t\t\t\texpected.context = arg3;\n\t\t\t}\n\t\t\treturn toHaveErrorImpl(this, expect, actual, expected);\n\t\t} else {\n\t\t\treturn toHaveErrorImpl(this, expect, actual, arg1);\n\t\t}\n\t}\n\treturn diverge(toHaveError);\n}\n\nexport { createMatcher as toHaveError };\n","/* eslint-disable prefer-template -- technical debt, should be refactored */\n\nimport { type expect } from \"@jest/globals\";\nimport { type MatcherContext, type SyncExpectationResult } from \"expect\";\nimport { type Report } from \"../../reporter\";\nimport { type MaybeAsyncCallback, diverge } from \"../utils\";\n\ntype JestExpect = typeof expect;\n\nfunction createMatcher(\n\texpect: JestExpect,\n): MaybeAsyncCallback<Report, [Array<[string, string] | Record<string, unknown>>]> {\n\tfunction toHaveErrors(\n\t\tthis: MatcherContext,\n\t\treport: Report,\n\t\terrors: Array<[string, string] | Record<string, unknown>>,\n\t): SyncExpectationResult {\n\t\tconst flattened = report.results.flatMap((result) => result.messages);\n\t\tconst matcher = errors.map((entry) => {\n\t\t\tif (Array.isArray(entry)) {\n\t\t\t\tconst [ruleId, message] = entry;\n\t\t\t\treturn expect.objectContaining({ ruleId, message });\n\t\t\t} else {\n\t\t\t\treturn expect.objectContaining(entry);\n\t\t\t}\n\t\t});\n\t\tconst pass = this.equals(flattened, matcher);\n\t\tconst diffString = this.utils.diff(matcher, flattened, { expand: this.expand });\n\t\tconst resultMessage = (): string =>\n\t\t\tthis.utils.matcherHint(\".toHaveErrors\") +\n\t\t\t\"\\n\\n\" +\n\t\t\t\"Expected error to equal:\\n\" +\n\t\t\t` ${this.utils.printExpected(matcher)}\\n` +\n\t\t\t\"Received:\\n\" +\n\t\t\t` ${this.utils.printReceived(flattened)}` +\n\t\t\t/* istanbul ignore next */ (diffString ? `\\n\\nDifference:\\n\\n${diffString}` : \"\");\n\n\t\treturn { pass, message: resultMessage };\n\t}\n\treturn diverge(toHaveErrors);\n}\n\nexport { createMatcher as toHaveErrors };\n","import { type Report, type Result } from \"../../reporter\";\nimport { type ValidateStringFn, createSyncFn, jestWorkerPath } from \"../worker\";\n\n/**\n * @internal\n */\nexport function getResults(filename: string, value: Report | string): Result[] {\n\tif (typeof value === \"string\") {\n\t\tconst syncFn = createSyncFn<ValidateStringFn>(jestWorkerPath);\n\t\tconst report = syncFn(value, filename, {\n\t\t\trules: {\n\t\t\t\t\"void-style\": \"off\",\n\t\t\t},\n\t\t});\n\t\treturn report.results.map((it) => {\n\t\t\treturn { ...it, filePath: \"inline\" };\n\t\t});\n\t} else {\n\t\treturn value.results;\n\t}\n}\n","import { type MatcherContext, type SyncExpectationResult } from \"expect\";\nimport { toMatchSnapshot } from \"jest-snapshot\";\nimport { type Report } from \"../../reporter\";\nimport { type MaybeAsyncCallback, codeframe, diverge } from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nfunction createMatcher(): MaybeAsyncCallback<Report | string, [Array<string | object>]> {\n\tfunction toMatchCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | string,\n\t\t...rest: Array<string | object>\n\t): SyncExpectationResult {\n\t\t/* istanbul ignore next: cant figure out when this would be unset */\n\t\tconst filename = this.testPath ?? \"inline\";\n\t\tconst results = getResults(filename, actual);\n\t\tconst snapshot = codeframe(results).replaceAll(/\\s+$/gm, \"\");\n\n\t\t/* eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t\t * the implementation works but the declarations doesn't allow it */\n\t\treturn (toMatchSnapshot as any).call(this, snapshot, ...rest);\n\t}\n\treturn diverge(toMatchCodeframe);\n}\n\nexport { createMatcher as toMatchCodeframe };\n","import {\n\ttype AsyncExpectationResult,\n\ttype MatcherContext,\n\ttype SyncExpectationResult,\n} from \"expect\";\nimport { toMatchInlineSnapshot } from \"jest-snapshot\";\nimport { type Report } from \"../../reporter\";\nimport { codeframe, isThenable } from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nfunction toMatchInlineCodeframeImpl(\n\tcontext: MatcherContext,\n\tactual: Report | string,\n\t...rest: Array<string | object>\n): SyncExpectationResult {\n\t/* istanbul ignore next: cant figure out when this would be unset */\n\tconst filename = context.testPath ?? \"inline\";\n\tconst results = getResults(filename, actual);\n\tconst snapshot = codeframe(results).replaceAll(/\\s+$/gm, \"\");\n\n\t/* eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --\n\t * the implementation works but the declarations doesn't allow it */\n\treturn (toMatchInlineSnapshot as any).call(context, snapshot, ...rest);\n}\n\ntype ToMatchInlineCodeframeMatcher = (\n\tthis: MatcherContext,\n\tactual: Report | Promise<Report> | string,\n\t...rest: Array<string | object>\n) => SyncExpectationResult | Promise<SyncExpectationResult>;\n\nfunction toMatchInlineCodeframe(\n\tthis: MatcherContext,\n\tactual: Report | Promise<Report> | string,\n\t...rest: Array<string | object>\n): SyncExpectationResult | AsyncExpectationResult {\n\tconst context = {\n\t\t...this,\n\n\t\t/* Capture the original stack frames as they are needed by \"jest-snapshot\"\n\t\t * to determine where to write the inline snapshots. When resolving the\n\t\t * promise the original stack frames are lost and the snapshot will be\n\t\t * written in this files instaed. */\n\t\terror: new Error(\"stacktrace\"),\n\t};\n\n\tif (isThenable(actual)) {\n\t\treturn actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));\n\t} else {\n\t\treturn toMatchInlineCodeframeImpl(context, actual, ...rest);\n\t}\n}\n\nfunction createMatcher(): ToMatchInlineCodeframeMatcher {\n\treturn toMatchInlineCodeframe;\n}\n\nexport { createMatcher as toMatchInlineCodeframe };\n"],"names":["createMatcher","actual"],"mappings":";;;;AAIA,SAASA,eAAA,GAAgD;AACxD,EAAA,SAAS,UAAU,MAAA,EAAuC;AACzD,IAAA,IAAI,OAAO,KAAA,EAAO;AACjB,MAAA,OAAO;AAAA,QACN,IAAA,EAAM,IAAA;AAAA,QACN,OAAA;AAAA;AAAA,UAAoC,MAAM;AAAA;AAAA,OAC3C;AAAA,IACD,CAAA,MAAO;AACN,MAAA,MAAM,aAAa,MAAA,CAAO,OAAA,CAAQ,CAAC,CAAA,CAAE,SAAS,CAAC,CAAA;AAC/C,MAAA,OAAO;AAAA,QACN,IAAA,EAAM,KAAA;AAAA,QACN,OAAA,EAAS,MAAM,CAAA,sCAAA,EAAyC,UAAA,CAAW,OAAO,CAAA,CAAA;AAAA,OAC3E;AAAA,IACD;AAAA,EACD;AACA,EAAA,OAAO,QAAQ,SAAS,CAAA;AACzB;;AChBA,SAASA,eAAA,GAAgD;AACxD,EAAA,SAAS,YAAY,MAAA,EAAuC;AAC3D,IAAA,IAAI,OAAO,KAAA,EAAO;AACjB,MAAA,OAAO;AAAA,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ACR;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as codeFrameColumns, B as getEndLocation, G as getStartLocation } from './core.js';
|
|
2
2
|
import { MessageChannel, Worker, receiveMessageOnPort } from 'node:worker_threads';
|
|
3
3
|
import { l as legacyRequire } from './core-nodejs.js';
|
|
4
4
|
|
|
@@ -51,12 +51,6 @@ function diverge(fn) {
|
|
|
51
51
|
return diverged;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
function flattenMessages(report) {
|
|
55
|
-
return report.results.reduce((aggregated, result) => {
|
|
56
|
-
return aggregated.concat(result.messages);
|
|
57
|
-
}, []);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
54
|
const INT32_BYTES = 4;
|
|
61
55
|
const syncFnCache = /* @__PURE__ */ new Map();
|
|
62
56
|
const sharedBuffer = new SharedArrayBuffer(INT32_BYTES);
|
|
@@ -118,5 +112,5 @@ function createSyncFn(workerPath) {
|
|
|
118
112
|
return syncFn;
|
|
119
113
|
}
|
|
120
114
|
|
|
121
|
-
export {
|
|
122
|
-
//# sourceMappingURL=
|
|
115
|
+
export { createSyncFn as a, codeframe as c, diverge as d, isThenable as i };
|
|
116
|
+
//# sourceMappingURL=jest-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-utils.js","sources":["../../src/jest/utils/codeframe.ts","../../src/jest/utils/is-thenable.ts","../../src/jest/utils/diverge.ts","../../src/jest/worker/create-sync-fn.ts"],"sourcesContent":["import { type Message } from \"../../message\";\nimport { type Result } from \"../../reporter\";\nimport { codeFrameColumns } from \"../../utils/code-frame-columns\";\nimport { getEndLocation, getStartLocation } from \"../../utils/message-location\";\n\n/**\n * Gets the formatted output for a given message.\n * @param message - The object that represents this message.\n * @param parentResult - The result object that this message belongs to.\n * @returns The formatted output.\n */\nfunction formatMessage(message: Message, parentResult: Result): string {\n\tconst type = message.severity === 2 ? \"error\" : \"warning\";\n\tconst msg = message.message.replace(/([^ ])\\.$/, \"$1\");\n\tconst ruleId = `(${message.ruleId})`;\n\tconst sourceCode = parentResult.source;\n\tconst firstLine = [`${type}:`, msg, ruleId].join(\" \");\n\tconst result = [firstLine];\n\n\t/* istanbul ignore next: safety check from original implementation */\n\tif (sourceCode) {\n\t\tconst output = codeFrameColumns(sourceCode, {\n\t\t\tstart: getStartLocation(message),\n\t\t\tend: getEndLocation(message, sourceCode),\n\t\t});\n\t\tresult.push(output);\n\t}\n\n\tresult.push(`Selector: ${message.selector ?? \"-\"}`);\n\n\treturn result.join(\"\\n\");\n}\n\n/**\n * Codeframe formatter based on ESLint codeframe.\n *\n * @internal\n */\nexport function codeframe(results: Result[]): string {\n\tlet errors = 0;\n\tlet warnings = 0;\n\n\tconst resultsWithMessages = results.filter((result) => result.messages.length > 0);\n\n\tconst output = resultsWithMessages\n\t\t.reduce<string[]>((resultsOutput, result) => {\n\t\t\tconst messages = result.messages.map((message) => {\n\t\t\t\treturn `${formatMessage(message, result)}\\n\\n`;\n\t\t\t});\n\n\t\t\terrors += result.errorCount;\n\t\t\twarnings += result.warningCount;\n\n\t\t\treturn resultsOutput.concat(messages);\n\t\t}, [])\n\t\t.join(\"\\n\");\n\n\treturn errors + warnings > 0 ? output : \"\";\n}\n","/**\n * @internal\n */\nexport function isThenable<T>(value: T | Promise<T>): value is Promise<T> {\n\treturn value && typeof value === \"object\" && \"then\" in value && typeof value.then === \"function\";\n}\n","import {\n\ttype AsyncExpectationResult,\n\ttype MatcherContext,\n\ttype SyncExpectationResult,\n} from \"expect\";\nimport { isThenable } from \"./is-thenable\";\n\ntype SyncCallback<T, TArgs extends unknown[]> = (\n\tthis: MatcherContext,\n\tactual: T,\n\t...args: TArgs\n) => SyncExpectationResult;\n\n/**\n * @internal\n */\nexport interface MaybeAsyncCallback<TActual, TArgs extends unknown[]> {\n\t(this: MatcherContext, actual: TActual, ...args: TArgs): SyncExpectationResult;\n\t(this: MatcherContext, actual: Promise<TActual>, ...args: TArgs): AsyncExpectationResult;\n}\n\n/**\n * Creates a wrapped function based on the passed function.\n *\n * The returned function takes either a `T` or `Promise<T>`. If `T` the result\n * will be synchronous or if `Promise<T>` the result will be asynchronous.\n *\n * In practice this means that if you pass a synchronous object into it you will\n * maintain synchronous code but if you pass an asynchronous object you must\n * await the result.\n *\n * @internal\n */\nexport function diverge<T, TArgs extends unknown[]>(\n\tfn: SyncCallback<T, TArgs>,\n): MaybeAsyncCallback<T, TArgs> {\n\tfunction diverged(this: MatcherContext, actual: T, ...args: TArgs): SyncExpectationResult;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: Promise<T>,\n\t\t...args: TArgs\n\t): AsyncExpectationResult;\n\tfunction diverged(\n\t\tthis: MatcherContext,\n\t\tactual: T | Promise<T>,\n\t\t...args: TArgs\n\t): SyncExpectationResult | AsyncExpectationResult {\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => fn.call(this, resolved, ...args));\n\t\t} else {\n\t\t\treturn fn.call(this, actual, ...args);\n\t\t}\n\t}\n\treturn diverged;\n}\n","import {\n\ttype MessagePort,\n\tMessageChannel,\n\tWorker,\n\treceiveMessageOnPort,\n} from \"node:worker_threads\";\nimport { legacyRequire } from \"../../resolve\";\nimport {\n\ttype AnyAsyncFn,\n\ttype AnyFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype Syncify,\n\ttype WorkerToMainError,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\n/**\n * This is all based on the synckit library but without all the extra stuff such\n * as typescript, esbuld, pnp etc.\n */\n\nconst INT32_BYTES = 4;\nconst syncFnCache = new Map<string, AnyFn>();\nconst sharedBuffer = new SharedArrayBuffer(INT32_BYTES);\nconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\nfunction isWorkerError<T>(value: WorkerToMainMessage<T>): value is WorkerToMainError {\n\treturn \"error\" in value;\n}\n\nfunction receiveMessageWithId<R>(port: MessagePort, expectedId: number): WorkerToMainMessage<R> {\n\t/* wait for the semaphore to be raised before receiving message */\n\tconst timeout = 30000;\n\tconst status = Atomics.wait(sharedBufferView, 0, 0, timeout);\n\tAtomics.store(sharedBufferView, 0, 0);\n\n\t/* handle timeout or unexpected errors */\n\tif (![\"ok\", \"not-equal\"].includes(status)) {\n\t\tconst abortMsg: MainToWorkerCommandMessage = {\n\t\t\tid: expectedId,\n\t\t\tcmd: \"abort\",\n\t\t};\n\t\tport.postMessage(abortMsg);\n\t\tthrow new Error(`Internal error: Atomics.wait() failed: ${status}`);\n\t}\n\n\t/* the worker process will post the message before raising the semaphore, we\n\t * should not reach this part of the code unless there is a message waiting to\n\t * be read */\n\tconst reply = receiveMessageOnPort(port) as { message: WorkerToMainMessage<R> };\n\tconst { id, ...message } = reply.message;\n\n\tif (id < expectedId) {\n\t\treturn receiveMessageWithId(port, expectedId);\n\t}\n\n\tif (expectedId !== id) {\n\t\tthrow new Error(`Internal error: Expected id ${String(expectedId)} but got id ${String(id)}`);\n\t}\n\n\treturn { id, ...message };\n}\n\nfunction startWorkerThread<R, T extends AnyAsyncFn<R>>(\n\tworkerPath: string,\n): (...args: Parameters<T>) => R {\n\tconst { port1: mainPort, port2: workerPort } = new MessageChannel();\n\tconst workerPathUrl = legacyRequire.resolve(workerPath);\n\tconst worker = new Worker(workerPathUrl, {\n\t\teval: false,\n\t\tworkerData: { sharedBuffer, workerPort },\n\t\ttransferList: [workerPort],\n\t});\n\n\tlet nextID = 0;\n\n\tconst syncFn = (...args: Parameters<T>): R => {\n\t\tconst id = nextID++;\n\t\tconst msg: MainToWorkerMessage<Parameters<T>> = { id, args };\n\n\t\tworker.postMessage(msg);\n\n\t\tconst reply = receiveMessageWithId<R>(mainPort, id);\n\n\t\tif (isWorkerError(reply)) {\n\t\t\tthrow new Error(reply.error);\n\t\t}\n\n\t\treturn reply.result;\n\t};\n\n\tworker.unref();\n\n\treturn syncFn;\n}\n\nexport function createSyncFn<T extends AnyAsyncFn<R>, R = unknown>(workerPath: string): Syncify<T> {\n\tconst cachedSyncFn = syncFnCache.get(workerPath);\n\tif (cachedSyncFn) {\n\t\treturn cachedSyncFn as Syncify<T>;\n\t}\n\n\tconst syncFn = startWorkerThread<R, T>(workerPath);\n\tsyncFnCache.set(workerPath, syncFn);\n\treturn syncFn as Syncify<T>;\n}\n"],"names":[],"mappings":";;;;AAWA,SAAS,aAAA,CAAc,SAAkB,YAAA,EAA8B;AACtE,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,QAAA,KAAa,CAAA,GAAI,OAAA,GAAU,SAAA;AAChD,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAQ,aAAa,IAAI,CAAA;AACrD,EAAA,MAAM,MAAA,GAAS,CAAA,CAAA,EAAI,OAAA,CAAQ,MAAM,CAAA,CAAA,CAAA;AACjC,EAAA,MAAM,aAAa,YAAA,CAAa,MAAA;AAChC,EAAA,MAAM,SAAA,GAAY,CAAC,CAAA,EAAG,IAAI,KAAK,GAAA,EAAK,MAAM,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AACpD,EAAA,MAAM,MAAA,GAAS,CAAC,SAAS,CAAA;AAGzB,EAAA,IAAI,UAAA,EAAY;AACf,IAAA,MAAM,MAAA,GAAS,iBAAiB,UAAA,EAAY;AAAA,MAC3C,KAAA,EAAO,iBAAiB,OAAO,CAAA;AAAA,MAC/B,GAAA,EAAK,cAAA,CAAe,OAAA,EAAS,UAAU;AAAA,KACvC,CAAA;AACD,IAAA,MAAA,CAAO,KAAK,MAAM,CAAA;AAAA,EACnB;AAEA,EAAA,MAAA,CAAO,IAAA,CAAK,CAAA,UAAA,EAAa,OAAA,CAAQ,QAAA,IAAY,GAAG,CAAA,CAAE,CAAA;AAElD,EAAA,OAAO,MAAA,CAAO,KAAK,IAAI,CAAA;AACxB;AAOO,SAAS,UAAU,OAAA,EAA2B;AACpD,EAAA,IAAI,MAAA,GAAS,CAAA;AACb,EAAA,IAAI,QAAA,GAAW,CAAA;AA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,WAAA,CAAY,GAAA,CAAI,YAAY,MAAM,CAAA;AAClC,EAAA,OAAO,MAAA;AACR;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-worker.js","sources":["../../src/jest/worker/worker.ts"],"sourcesContent":["import { type MessagePort, parentPort, workerData } from \"node:worker_threads\";\nimport { type ConfigData } from \"../../config\";\nimport { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype AnyAsyncFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\ninterface WorkerData {\n\tsharedBuffer: SharedArrayBuffer;\n\tworkerPort: MessagePort;\n}\n\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- false positive, it is used in nested functions */\nfunction runAsWorker<R = unknown, T extends AnyAsyncFn<R> = AnyAsyncFn<R>>(fn: T): void {\n\tif (!workerData) {\n\t\treturn;\n\t}\n\n\tconst { workerPort, sharedBuffer } = workerData as WorkerData;\n\tconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\n\t/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- better crash at runtime if not set */\n\tparentPort!.on(\"message\", ({ id, args }: MainToWorkerMessage<Parameters<T>>) => {\n\t\tasync function inner(): Promise<void> {\n\t\t\tlet isAborted = false;\n\t\t\tconst handleAbortMessage = (msg: MainToWorkerCommandMessage): void => {\n\t\t\t\tif (msg.id === id && msg.cmd === \"abort\") {\n\t\t\t\t\tisAborted = true;\n\t\t\t\t}\n\t\t\t};\n\t\t\tworkerPort.on(\"message\", handleAbortMessage);\n\t\t\tlet msg: WorkerToMainMessage<R>;\n\t\t\ttry {\n\t\t\t\tmsg = { id, result: await fn(...args) };\n\t\t\t} catch (error: unknown) {\n\t\t\t\tmsg = {\n\t\t\t\t\tid,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t};\n\t\t\t}\n\t\t\tworkerPort.off(\"message\", handleAbortMessage);\n\n\t\t\t/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- it may have been set by `handleAbortMessage` */\n\t\t\tif (isAborted) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tworkerPort.postMessage(msg);\n\t\t\tAtomics.add(sharedBufferView, 0, 1);\n\t\t\tAtomics.notify(sharedBufferView, 0);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises -- should not happen\n\t\tinner();\n\t});\n}\n\nfunction validateString(markup: string, filename: string, config: ConfigData): Promise<Report> {\n\tconst loader = new FileSystemConfigLoader({\n\t\textends: [\"html-validate:recommended\"],\n\t});\n\tconst htmlvalidate = new HtmlValidate(loader);\n\treturn htmlvalidate.validateString(markup, filename, config);\n}\n\nexport type ValidateStringFn = typeof validateString;\n\nrunAsWorker(validateString);\n"],"names":["msg"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAS,YAAkE,EAAA,EAAa;AACvF,EAAA,IAAI,CAAC,UAAA,EAAY;AAChB,IAAA;AAAA,EACD;AAEA,EAAA,MAAM,EAAE,UAAA,EAAY,YAAA,EAAa,GAAI,UAAA;AACrC,EAAA,MAAM,gBAAA,GAAmB,IAAI,UAAA,CAAW,YAAA,EAAc,GAAG,CAAC,CAAA;AAG1D,EAAA,UAAA,CAAY,GAAG,SAAA,EAAW,CAAC,EAAE,EAAA,EAAI,MAAK,KAA0C;AAC/E,IAAA,eAAe,KAAA,GAAuB;AACrC,MAAA,IAAI,SAAA,GAAY,KAAA;AAChB,MAAA,MAAM,kBAAA,GAAqB,CAACA,IAAAA,KAA0C;AACrE,QAAA,IAAIA,IAAAA,CAAI,EAAA,KAAO,EAAA,IAAMA,IAAAA,CAAI,QAAQ,OAAA,EAAS;AACzC,UAAA,SAAA,GAAY,IAAA;AAAA,QACb;AAAA,MACD,CAAA;AACA,MAAA,UAAA,CAAW,EAAA,CAAG,WAAW,kBAAkB,CAAA;AAC3C,MAAA,IAAI,GAAA;AACJ,MAAA,IAAI;AACH,QAAA,GAAA,GAAM,EAAE,EAAA,EAAI,MAAA,EAAQ,MAAM,EAAA,CAAG,GAAG,IAAI,CAAA,EAAE;AAAA,MACvC,SAAS,KAAA,EAAgB;AACxB,QAAA,GAAA,GAAM;AAAA,UACL,EAAA;AAAA,UACA,OAAO,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK;AAAA,SAC7D;AAAA,MACD;AACA,MAAA,UAAA,CAAW,GAAA,CAAI,WAAW,kBAAkB,CAAA;AAG5C,MAAA,IAAI,SAAA,EAAW;AACd,QAAA;AAAA,MACD;AACA,MAAA,UAAA,CAAW,YAAY,GAAG,CAAA;AAC1B,MAAA,OAAA,CAAQ,GAAA,CAAI,gBAAA,EAAkB,CAAA,EAAG,CAAC,CAAA;AAClC,MAAA,OAAA,CAAQ,MAAA,CAAO,kBAAkB,CAAC,CAAA;AAAA,IACnC;AAEA,IAAA,KAAA,EAAM;AAAA,EACP,CAAC,CAAA;AACF;AAEA,SAAS,cAAA,CAAe,MAAA,EAAgB,QAAA,EAAkB,MAAA,EAAqC;AAC9F,EAAA,MAAM,MAAA,GAAS,IAAI,sBAAA,CAAuB;AAAA,IACzC,OAAA,EAAS,CAAC,2BAA2B;AAAA,GACrC,CAAA;AACD,EAAA,MAAM,YAAA,GAAe,IAAI,YAAA,CAAa,MAAM,CAAA;AAC5C,EAAA,OAAO,YAAA,CAAa,cAAA,CAAe,MAAA,EAAQ,QAAA,EAAU,MAAM,CAAA;AAC5D;AAIA,WAAA,CAAY,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"jest-worker.js","sources":["../../src/jest/worker/jest-worker.ts"],"sourcesContent":["import { type MessagePort, parentPort, workerData } from \"node:worker_threads\";\nimport { type ConfigData } from \"../../config\";\nimport { FileSystemConfigLoader } from \"../../config/loaders/file-system\";\nimport { HtmlValidate } from \"../../htmlvalidate\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype AnyAsyncFn,\n\ttype MainToWorkerCommandMessage,\n\ttype MainToWorkerMessage,\n\ttype WorkerToMainMessage,\n} from \"./types\";\n\ninterface WorkerData {\n\tsharedBuffer: SharedArrayBuffer;\n\tworkerPort: MessagePort;\n}\n\n/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- false positive, it is used in nested functions */\nfunction runAsWorker<R = unknown, T extends AnyAsyncFn<R> = AnyAsyncFn<R>>(fn: T): void {\n\tif (!workerData) {\n\t\treturn;\n\t}\n\n\tconst { workerPort, sharedBuffer } = workerData as WorkerData;\n\tconst sharedBufferView = new Int32Array(sharedBuffer, 0, 1);\n\n\t/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- better crash at runtime if not set */\n\tparentPort!.on(\"message\", ({ id, args }: MainToWorkerMessage<Parameters<T>>) => {\n\t\tasync function inner(): Promise<void> {\n\t\t\tlet isAborted = false;\n\t\t\tconst handleAbortMessage = (msg: MainToWorkerCommandMessage): void => {\n\t\t\t\tif (msg.id === id && msg.cmd === \"abort\") {\n\t\t\t\t\tisAborted = true;\n\t\t\t\t}\n\t\t\t};\n\t\t\tworkerPort.on(\"message\", handleAbortMessage);\n\t\t\tlet msg: WorkerToMainMessage<R>;\n\t\t\ttry {\n\t\t\t\tmsg = { id, result: await fn(...args) };\n\t\t\t} catch (error: unknown) {\n\t\t\t\tmsg = {\n\t\t\t\t\tid,\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t};\n\t\t\t}\n\t\t\tworkerPort.off(\"message\", handleAbortMessage);\n\n\t\t\t/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- it may have been set by `handleAbortMessage` */\n\t\t\tif (isAborted) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tworkerPort.postMessage(msg);\n\t\t\tAtomics.add(sharedBufferView, 0, 1);\n\t\t\tAtomics.notify(sharedBufferView, 0);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises -- should not happen\n\t\tinner();\n\t});\n}\n\nfunction validateString(markup: string, filename: string, config: ConfigData): Promise<Report> {\n\tconst loader = new FileSystemConfigLoader({\n\t\textends: [\"html-validate:recommended\"],\n\t});\n\tconst htmlvalidate = new HtmlValidate(loader);\n\treturn htmlvalidate.validateString(markup, filename, config);\n}\n\nexport type ValidateStringFn = typeof validateString;\n\nrunAsWorker(validateString);\n"],"names":["msg"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAS,YAAkE,EAAA,EAAa;AACvF,EAAA,IAAI,CAAC,UAAA,EAAY;AAChB,IAAA;AAAA,EACD;AAEA,EAAA,MAAM,EAAE,UAAA,EAAY,YAAA,EAAa,GAAI,UAAA;AACrC,EAAA,MAAM,gBAAA,GAAmB,IAAI,UAAA,CAAW,YAAA,EAAc,GAAG,CAAC,CAAA;AAG1D,EAAA,UAAA,CAAY,GAAG,SAAA,EAAW,CAAC,EAAE,EAAA,EAAI,MAAK,KAA0C;AAC/E,IAAA,eAAe,KAAA,GAAuB;AACrC,MAAA,IAAI,SAAA,GAAY,KAAA;AAChB,MAAA,MAAM,kBAAA,GAAqB,CAACA,IAAAA,KAA0C;AACrE,QAAA,IAAIA,IAAAA,CAAI,EAAA,KAAO,EAAA,IAAMA,IAAAA,CAAI,QAAQ,OAAA,EAAS;AACzC,UAAA,SAAA,GAAY,IAAA;AAAA,QACb;AAAA,MACD,CAAA;AACA,MAAA,UAAA,CAAW,EAAA,CAAG,WAAW,kBAAkB,CAAA;AAC3C,MAAA,IAAI,GAAA;AACJ,MAAA,IAAI;AACH,QAAA,GAAA,GAAM,EAAE,EAAA,EAAI,MAAA,EAAQ,MAAM,EAAA,CAAG,GAAG,IAAI,CAAA,EAAE;AAAA,MACvC,SAAS,KAAA,EAAgB;AACxB,QAAA,GAAA,GAAM;AAAA,UACL,EAAA;AAAA,UACA,OAAO,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK;AAAA,SAC7D;AAAA,MACD;AACA,MAAA,UAAA,CAAW,GAAA,CAAI,WAAW,kBAAkB,CAAA;AAG5C,MAAA,IAAI,SAAA,EAAW;AACd,QAAA;AAAA,MACD;AACA,MAAA,UAAA,CAAW,YAAY,GAAG,CAAA;AAC1B,MAAA,OAAA,CAAQ,GAAA,CAAI,gBAAA,EAAkB,CAAA,EAAG,CAAC,CAAA;AAClC,MAAA,OAAA,CAAQ,MAAA,CAAO,kBAAkB,CAAC,CAAA;AAAA,IACnC;AAEA,IAAA,KAAA,EAAM;AAAA,EACP,CAAC,CAAA;AACF;AAEA,SAAS,cAAA,CAAe,MAAA,EAAgB,QAAA,EAAkB,MAAA,EAAqC;AAC9F,EAAA,MAAM,MAAA,GAAS,IAAI,sBAAA,CAAuB;AAAA,IACzC,OAAA,EAAS,CAAC,2BAA2B;AAAA,GACrC,CAAA;AACD,EAAA,MAAM,YAAA,GAAe,IAAI,YAAA,CAAa,MAAM,CAAA;AAC5C,EAAA,OAAO,YAAA,CAAa,cAAA,CAAe,MAAA,EAAQ,QAAA,EAAU,MAAM,CAAA;AAC5D;AAIA,WAAA,CAAY,cAAc,CAAA"}
|
package/dist/esm/jest.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { expect } from '@jest/globals';
|
|
2
|
-
import { c as createMatcher, a as createMatcher$1 } from './matchers
|
|
3
|
-
import
|
|
4
|
-
import { d as diff } from './jest-diff.js';
|
|
5
|
-
import 'jest-snapshot';
|
|
6
|
-
import './matcher-utils.js';
|
|
2
|
+
import { c as createMatcher, a as createMatcher$1, b as createMatcher$2, d as createMatcher$3, e as createMatcher$4, f as createMatcher$5, g as createMatcher$6 } from './jest-matchers.js';
|
|
3
|
+
import './jest-utils.js';
|
|
7
4
|
import './core.js';
|
|
8
5
|
import 'ajv';
|
|
9
6
|
import './elements.js';
|
|
@@ -21,14 +18,14 @@ import 'node:path';
|
|
|
21
18
|
import 'node:fs/promises';
|
|
22
19
|
import 'node:url';
|
|
23
20
|
import 'node:module';
|
|
24
|
-
import 'jest-
|
|
21
|
+
import 'jest-snapshot';
|
|
25
22
|
|
|
26
23
|
expect.extend({
|
|
27
24
|
toBeValid: createMatcher$6(),
|
|
28
25
|
toBeInvalid: createMatcher$5(),
|
|
29
|
-
toHTMLValidate: createMatcher$4(expect
|
|
30
|
-
toHaveError: createMatcher$3(expect
|
|
31
|
-
toHaveErrors: createMatcher$2(expect
|
|
26
|
+
toHTMLValidate: createMatcher$4(expect),
|
|
27
|
+
toHaveError: createMatcher$3(expect),
|
|
28
|
+
toHaveErrors: createMatcher$2(expect),
|
|
32
29
|
toMatchCodeframe: createMatcher$1(),
|
|
33
30
|
toMatchInlineCodeframe: createMatcher()
|
|
34
31
|
});
|
package/dist/esm/jest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest.js","sources":["../../src/jest/
|
|
1
|
+
{"version":3,"file":"jest.js","sources":["../../src/jest/index.ts"],"sourcesContent":["import { expect } from \"@jest/globals\";\nimport \"./augmentation\";\n\nimport {\n\ttoBeInvalid,\n\ttoBeValid,\n\ttoHTMLValidate,\n\ttoHaveError,\n\ttoHaveErrors,\n\ttoMatchCodeframe,\n\ttoMatchInlineCodeframe,\n} from \"./matchers\";\n\nexpect.extend({\n\ttoBeValid: toBeValid(),\n\ttoBeInvalid: toBeInvalid(),\n\ttoHTMLValidate: toHTMLValidate(expect),\n\ttoHaveError: toHaveError(expect),\n\ttoHaveErrors: toHaveErrors(expect),\n\ttoMatchCodeframe: toMatchCodeframe(),\n\ttoMatchInlineCodeframe: toMatchInlineCodeframe(),\n});\n"],"names":["toBeValid","toBeInvalid","toHTMLValidate","toHaveError","toHaveErrors","toMatchCodeframe","toMatchInlineCodeframe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAaA,MAAA,CAAO,MAAA,CAAO;AAAA,EACb,WAAWA,eAAA,EAAU;AAAA,EACrB,aAAaC,eAAA,EAAY;AAAA,EACzB,cAAA,EAAgBC,gBAAe,MAAM,CAAA;AAAA,EACrC,WAAA,EAAaC,gBAAY,MAAM,CAAA;AAAA,EAC/B,YAAA,EAAcC,gBAAa,MAAM,CAAA;AAAA,EACjC,kBAAkBC,eAAA,EAAiB;AAAA,EACnC,wBAAwBC,aAAA;AACzB,CAAC,CAAA"}
|