html-validate 8.7.3 → 8.8.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.
Files changed (73) hide show
  1. package/dist/cjs/browser.js +7 -21
  2. package/dist/cjs/browser.js.map +1 -1
  3. package/dist/cjs/cli.js +468 -451
  4. package/dist/cjs/cli.js.map +1 -1
  5. package/dist/cjs/core-browser.js +9 -20
  6. package/dist/cjs/core-browser.js.map +1 -1
  7. package/dist/cjs/core-nodejs.js +203 -297
  8. package/dist/cjs/core-nodejs.js.map +1 -1
  9. package/dist/cjs/core.js +9511 -10450
  10. package/dist/cjs/core.js.map +1 -1
  11. package/dist/cjs/elements.js +2293 -2296
  12. package/dist/cjs/elements.js.map +1 -1
  13. package/dist/cjs/html-validate.js +148 -169
  14. package/dist/cjs/html-validate.js.map +1 -1
  15. package/dist/cjs/html5.js.map +1 -1
  16. package/dist/cjs/index.js +8 -21
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/jest-diff.js +26 -36
  19. package/dist/cjs/jest-diff.js.map +1 -1
  20. package/dist/cjs/jest.js +8 -8
  21. package/dist/cjs/jest.js.map +1 -1
  22. package/dist/cjs/matcher-utils.js +12 -28
  23. package/dist/cjs/matcher-utils.js.map +1 -1
  24. package/dist/cjs/matchers-jestonly.js +38 -47
  25. package/dist/cjs/matchers-jestonly.js.map +1 -1
  26. package/dist/cjs/matchers.js +196 -196
  27. package/dist/cjs/matchers.js.map +1 -1
  28. package/dist/cjs/meta-helper.js +40 -60
  29. package/dist/cjs/meta-helper.js.map +1 -1
  30. package/dist/cjs/test-utils.js +26 -47
  31. package/dist/cjs/test-utils.js.map +1 -1
  32. package/dist/cjs/tsdoc-metadata.json +1 -1
  33. package/dist/cjs/utils/natural-join.js +10 -23
  34. package/dist/cjs/utils/natural-join.js.map +1 -1
  35. package/dist/cjs/vitest.js +6 -6
  36. package/dist/cjs/vitest.js.map +1 -1
  37. package/dist/es/browser.js +2 -2
  38. package/dist/es/cli.js +467 -454
  39. package/dist/es/cli.js.map +1 -1
  40. package/dist/es/core-browser.js +10 -21
  41. package/dist/es/core-browser.js.map +1 -1
  42. package/dist/es/core-nodejs.js +204 -299
  43. package/dist/es/core-nodejs.js.map +1 -1
  44. package/dist/es/core.js +9506 -10451
  45. package/dist/es/core.js.map +1 -1
  46. package/dist/es/elements.js +2293 -2296
  47. package/dist/es/elements.js.map +1 -1
  48. package/dist/es/html-validate.js +150 -171
  49. package/dist/es/html-validate.js.map +1 -1
  50. package/dist/es/html5.js.map +1 -1
  51. package/dist/es/index.js +3 -3
  52. package/dist/es/jest-diff.js +11 -21
  53. package/dist/es/jest-diff.js.map +1 -1
  54. package/dist/es/jest.js +8 -8
  55. package/dist/es/jest.js.map +1 -1
  56. package/dist/es/matcher-utils.js +12 -28
  57. package/dist/es/matcher-utils.js.map +1 -1
  58. package/dist/es/matchers-jestonly.js +39 -48
  59. package/dist/es/matchers-jestonly.js.map +1 -1
  60. package/dist/es/matchers.js +196 -196
  61. package/dist/es/matchers.js.map +1 -1
  62. package/dist/es/meta-helper.js +40 -60
  63. package/dist/es/meta-helper.js.map +1 -1
  64. package/dist/es/test-utils.js +26 -47
  65. package/dist/es/test-utils.js.map +1 -1
  66. package/dist/es/utils/natural-join.js +10 -23
  67. package/dist/es/utils/natural-join.js.map +1 -1
  68. package/dist/es/vitest.js +6 -6
  69. package/dist/es/vitest.js.map +1 -1
  70. package/dist/tsdoc-metadata.json +1 -1
  71. package/dist/types/browser.d.ts +62 -30
  72. package/dist/types/index.d.ts +89 -32
  73. package/package.json +22 -18
@@ -1,67 +1,58 @@
1
1
  import kleur from 'kleur';
2
2
  import { toMatchSnapshot, toMatchInlineSnapshot } from 'jest-snapshot';
3
- import { G as codeframe } from './core.js';
3
+ import { I as codeframe } from './core.js';
4
4
  import { g as getResults } from './matchers.js';
5
5
  import { d as diverge, i as isThenable } from './matcher-utils.js';
6
6
 
7
7
  const options$1 = {
8
- showLink: false,
9
- showSummary: false,
10
- showSelector: true,
8
+ showLink: false,
9
+ showSummary: false,
10
+ showSelector: true
11
11
  };
12
12
  function createMatcher$1() {
13
- function toMatchCodeframe(actual, ...rest) {
14
- var _a;
15
- /* istanbul ignore next: cant figure out when this would be unset */
16
- const filename = (_a = this.testPath) !== null && _a !== void 0 ? _a : "inline";
17
- const results = getResults(filename, actual);
18
- const enabled = kleur.enabled;
19
- kleur.enabled = false;
20
- const snapshot = codeframe(results, options$1).replace(/\s+$/gm, "");
21
- kleur.enabled = enabled;
22
- /* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --
23
- * the implementation works but the declarations doesn't allow it */
24
- return toMatchSnapshot.call(this, snapshot, ...rest);
25
- }
26
- return diverge(toMatchCodeframe);
13
+ function toMatchCodeframe(actual, ...rest) {
14
+ const filename = this.testPath ?? "inline";
15
+ const results = getResults(filename, actual);
16
+ const enabled = kleur.enabled;
17
+ kleur.enabled = false;
18
+ const snapshot = codeframe(results, options$1).replace(/\s+$/gm, "");
19
+ kleur.enabled = enabled;
20
+ return toMatchSnapshot.call(this, snapshot, ...rest);
21
+ }
22
+ return diverge(toMatchCodeframe);
27
23
  }
28
24
 
29
25
  const options = {
30
- showLink: false,
31
- showSummary: false,
32
- showSelector: true,
26
+ showLink: false,
27
+ showSummary: false,
28
+ showSelector: true
33
29
  };
34
30
  function toMatchInlineCodeframeImpl(context, actual, ...rest) {
35
- var _a;
36
- /* istanbul ignore next: cant figure out when this would be unset */
37
- const filename = (_a = context.testPath) !== null && _a !== void 0 ? _a : "inline";
38
- const results = getResults(filename, actual);
39
- const enabled = kleur.enabled;
40
- kleur.enabled = false;
41
- const snapshot = codeframe(results, options).replace(/\s+$/gm, "");
42
- kleur.enabled = enabled;
43
- /* eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call --
44
- * the implementation works but the declarations doesn't allow it */
45
- return toMatchInlineSnapshot.call(context, snapshot, ...rest);
31
+ const filename = context.testPath ?? "inline";
32
+ const results = getResults(filename, actual);
33
+ const enabled = kleur.enabled;
34
+ kleur.enabled = false;
35
+ const snapshot = codeframe(results, options).replace(/\s+$/gm, "");
36
+ kleur.enabled = enabled;
37
+ return toMatchInlineSnapshot.call(context, snapshot, ...rest);
46
38
  }
47
39
  function createMatcher() {
48
- function toMatchInlineCodeframe(actual, ...rest) {
49
- const context = {
50
- ...this,
51
- /* Capture the original stack frames as they are needed by "jest-snapshot"
52
- * to determine where to write the inline snapshots. When resolving the
53
- * promise the original stack frames are lost and the snapshot will be
54
- * written in this files instaed. */
55
- error: new Error(),
56
- };
57
- if (isThenable(actual)) {
58
- return actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));
59
- }
60
- else {
61
- return toMatchInlineCodeframeImpl(context, actual, ...rest);
62
- }
40
+ function toMatchInlineCodeframe(actual, ...rest) {
41
+ const context = {
42
+ ...this,
43
+ /* Capture the original stack frames as they are needed by "jest-snapshot"
44
+ * to determine where to write the inline snapshots. When resolving the
45
+ * promise the original stack frames are lost and the snapshot will be
46
+ * written in this files instaed. */
47
+ error: new Error()
48
+ };
49
+ if (isThenable(actual)) {
50
+ return actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));
51
+ } else {
52
+ return toMatchInlineCodeframeImpl(context, actual, ...rest);
63
53
  }
64
- return toMatchInlineCodeframe;
54
+ }
55
+ return toMatchInlineCodeframe;
65
56
  }
66
57
 
67
58
  export { createMatcher as a, createMatcher$1 as c };
@@ -1 +1 @@
1
- {"version":3,"file":"matchers-jestonly.js","sources":["../../../src/jest/matchers/to-match-codeframe.ts","../../../src/jest/matchers/to-match-inline-codeframe.ts"],"sourcesContent":[null,null],"names":["options","createMatcher"],"mappings":";;;;;;AAYA,MAAMA,SAAO,GAAqB;AACjC,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,YAAY,EAAE,IAAI;CAClB,CAAC;AAEF,SAASC,eAAa,GAAA;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MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACnE,IAAA,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;AAExB;AACoE;IACpE,OAAQ,qBAA6B,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;AACxE,CAAC;AAQD,SAAS,aAAa,GAAA;AACrB,IAAA,SAAS,sBAAsB,CAE9B,MAAyC,EACzC,GAAG,IAA4B,EAAA;AAE/B,QAAA,MAAM,OAAO,GAAG;AACf,YAAA,GAAG,IAAI;AAEP;;;AAGoC;YACpC,KAAK,EAAE,IAAI,KAAK,EAAE;SAClB,CAAC;AAEF,QAAA,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;AACvB,YAAA,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;SACzF;aAAM;YACN,OAAO,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;SAC5D;KACD;AAED,IAAA,OAAO,sBAAsB,CAAC;AAC/B;;;;"}
1
+ {"version":3,"file":"matchers-jestonly.js","sources":["../../src/jest/matchers/to-match-codeframe.ts","../../src/jest/matchers/to-match-inline-codeframe.ts"],"sourcesContent":["import kleur from \"kleur\";\nimport { toMatchSnapshot } from \"jest-snapshot\";\nimport { codeframe, type CodeframeOptions } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport {\n\ttype MatcherContext,\n\ttype MatcherResult,\n\ttype MaybeAsyncCallback,\n\tdiverge,\n} from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\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): MatcherResult {\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 enabled = kleur.enabled;\n\t\tkleur.enabled = false;\n\t\tconst snapshot = codeframe(results, options).replace(/\\s+$/gm, \"\");\n\t\tkleur.enabled = enabled;\n\n\t\t/* eslint-disable-next-line @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 kleur from \"kleur\";\nimport { toMatchInlineSnapshot } from \"jest-snapshot\";\nimport { codeframe, type CodeframeOptions } from \"../../formatters/codeframe\";\nimport { type Report } from \"../../reporter\";\nimport { type MatcherContext, type MatcherResult, isThenable } from \"../utils\";\nimport { getResults } from \"./get-results\";\n\nconst options: CodeframeOptions = {\n\tshowLink: false,\n\tshowSummary: false,\n\tshowSelector: true,\n};\n\nfunction toMatchInlineCodeframeImpl(\n\tcontext: MatcherContext,\n\tactual: Report | string,\n\t...rest: Array<string | object>\n): MatcherResult {\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 enabled = kleur.enabled;\n\tkleur.enabled = false;\n\tconst snapshot = codeframe(results, options).replace(/\\s+$/gm, \"\");\n\tkleur.enabled = enabled;\n\n\t/* eslint-disable-next-line @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) => MatcherResult | Promise<MatcherResult>;\n\nfunction createMatcher(): ToMatchInlineCodeframeMatcher {\n\tfunction toMatchInlineCodeframe(\n\t\tthis: MatcherContext,\n\t\tactual: Report | Promise<Report> | string,\n\t\t...rest: Array<string | object>\n\t): MatcherResult | Promise<MatcherResult> {\n\t\tconst context = {\n\t\t\t...this,\n\n\t\t\t/* Capture the original stack frames as they are needed by \"jest-snapshot\"\n\t\t\t * to determine where to write the inline snapshots. When resolving the\n\t\t\t * promise the original stack frames are lost and the snapshot will be\n\t\t\t * written in this files instaed. */\n\t\t\terror: new Error(),\n\t\t};\n\n\t\tif (isThenable(actual)) {\n\t\t\treturn actual.then((resolved) => toMatchInlineCodeframeImpl(context, resolved, ...rest));\n\t\t} else {\n\t\t\treturn toMatchInlineCodeframeImpl(context, actual, ...rest);\n\t\t}\n\t}\n\n\treturn toMatchInlineCodeframe;\n}\n\nexport { createMatcher as toMatchInlineCodeframe };\n"],"names":["options","createMatcher"],"mappings":";;;;;;AAYA,MAAMA,SAA4B,GAAA;AAAA,EACjC,QAAU,EAAA,KAAA;AAAA,EACV,WAAa,EAAA,KAAA;AAAA,EACb,YAAc,EAAA,IAAA;AACf,CAAA,CAAA;AAEA,SAASC,eAA+E,GAAA;AACvF,EAAS,SAAA,gBAAA,CAER,WACG,IACa,EAAA;AAEhB,IAAM,MAAA,QAAA,GAAW,KAAK,QAAY,IAAA,QAAA,CAAA;AAClC,IAAM,MAAA,OAAA,GAAU,UAAW,CAAA,QAAA,EAAU,MAAM,CAAA,CAAA;AAC3C,IAAA,MAAM,UAAU,KAAM,CAAA,OAAA,CAAA;AACtB,IAAA,KAAA,CAAM,OAAU,GAAA,KAAA,CAAA;AAChB,IAAA,MAAM,WAAW,SAAU,CAAA,OAAA,EAASD,SAAO,CAAE,CAAA,OAAA,CAAQ,UAAU,EAAE,CAAA,CAAA;AACjE,IAAA,KAAA,CAAM,OAAU,GAAA,OAAA,CAAA;AAIhB,IAAA,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,OAAO,0BAA2B,CAAA,OAAA,EAAS,MAAQ,EAAA,GAAG,IAAI,CAAA,CAAA;AAAA,KAC3D;AAAA,GACD;AAEA,EAAO,OAAA,sBAAA,CAAA;AACR;;;;"}
@@ -3,234 +3,234 @@ import { d as deepmerge, H as HtmlValidate } from './core.js';
3
3
  import { F as FileSystemConfigLoader } from './core-nodejs.js';
4
4
 
5
5
  function createMatcher$4() {
6
- function toBeValid(report) {
7
- if (report.valid) {
8
- return {
9
- pass: true,
10
- message: /* istanbul ignore next */ () => "Result should not contain error",
11
- };
12
- }
13
- else {
14
- const firstError = report.results[0].messages[0];
15
- return {
16
- pass: false,
17
- message: () => `Result should be valid but had error "${firstError.message}"`,
18
- };
19
- }
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
+ };
20
21
  }
21
- return diverge(toBeValid);
22
+ }
23
+ return diverge(toBeValid);
22
24
  }
23
25
 
24
26
  function createMatcher$3() {
25
- function toBeInvalid(report) {
26
- if (report.valid) {
27
- return {
28
- pass: false,
29
- message: () => "Result should be invalid but had no errors",
30
- };
31
- }
32
- else {
33
- return {
34
- pass: true,
35
- message: /* istanbul ignore next */ () => "Result should not contain error",
36
- };
37
- }
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
+ };
38
41
  }
39
- return diverge(toBeInvalid);
42
+ }
43
+ return diverge(toBeInvalid);
40
44
  }
41
45
 
42
46
  function isMessage(arg) {
43
- if (!arg) {
44
- return false;
45
- }
46
- return Boolean(arg.ruleId ||
47
- arg.severity ||
48
- arg.message ||
49
- arg.offset ||
50
- arg.line ||
51
- arg.column ||
52
- arg.size ||
53
- arg.selector ||
54
- arg.context);
47
+ if (!arg) {
48
+ return false;
49
+ }
50
+ return Boolean(
51
+ arg.ruleId || arg.severity || arg.message || arg.offset || arg.line || arg.column || arg.size || arg.selector || arg.context
52
+ );
55
53
  }
56
54
  function isConfig(arg) {
57
- if (!arg) {
58
- return false;
59
- }
60
- return Boolean(arg.root || arg.extends || arg.elements || arg.plugin || arg.transform || arg.rules);
55
+ if (!arg) {
56
+ return false;
57
+ }
58
+ return Boolean(
59
+ arg.root || arg.extends || arg.elements || arg.plugin || arg.transform || arg.rules
60
+ );
61
61
  }
62
62
  function isString(arg) {
63
- return typeof arg === "string";
63
+ return typeof arg === "string";
64
64
  }
65
65
  function getMarkup(src) {
66
- if (typeof HTMLElement !== "undefined" && src instanceof HTMLElement) {
67
- return src.outerHTML;
68
- }
69
- /* istanbul ignore else: prototype only allows string or HTMLElement */
70
- if (typeof src === "string") {
71
- return src;
72
- }
73
- else {
74
- throw new Error(`Failed to get markup from "${typeof src}" argument`);
75
- }
66
+ if (typeof HTMLElement !== "undefined" && src instanceof HTMLElement) {
67
+ return src.outerHTML;
68
+ }
69
+ if (typeof src === "string") {
70
+ return src;
71
+ } else {
72
+ throw new Error(`Failed to get markup from "${typeof src}" argument`);
73
+ }
76
74
  }
77
75
  function createMatcher$2(expect, diff) {
78
- function toHTMLValidate(actual, arg0, arg1, arg2) {
79
- const markup = getMarkup(actual);
80
- const message = isMessage(arg0) ? arg0 : undefined;
81
- const config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : undefined;
82
- const filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2;
83
- return toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);
84
- }
85
- return diverge(toHTMLValidate);
76
+ function toHTMLValidate(actual, arg0, arg1, arg2) {
77
+ const markup = getMarkup(actual);
78
+ const message = isMessage(arg0) ? arg0 : void 0;
79
+ const config = isConfig(arg0) ? arg0 : isConfig(arg1) ? arg1 : void 0;
80
+ const filename = isString(arg0) ? arg0 : isString(arg1) ? arg1 : arg2;
81
+ return toHTMLValidateImpl.call(this, expect, diff, markup, message, config, filename);
82
+ }
83
+ return diverge(toHTMLValidate);
86
84
  }
87
85
  function toHTMLValidateImpl(expect, diff, actual, expectedError, userConfig, filename) {
88
- var _a;
89
- const defaultConfig = {
90
- rules: {
91
- /* jsdom normalizes style so disabling rule when using this matcher or it
92
- * gets quite noisy when configured with self-closing */
93
- "void-style": "off",
94
- },
95
- };
96
- const config = deepmerge(defaultConfig, userConfig !== null && userConfig !== void 0 ? userConfig : {});
97
- /* istanbul ignore next: cant figure out when this would be unset */
98
- const actualFilename = (_a = filename !== null && filename !== void 0 ? filename : this.testPath) !== null && _a !== void 0 ? _a : "inline";
99
- const loader = new FileSystemConfigLoader({
100
- extends: ["html-validate:recommended"],
101
- });
102
- const htmlvalidate = new HtmlValidate(loader);
103
- const report = htmlvalidate.validateStringSync(actual, actualFilename, config);
104
- const pass = report.valid;
105
- const result = report.results[0];
106
- if (pass) {
107
- return { pass, message: () => "HTML is valid when an error was expected" };
86
+ const defaultConfig = {
87
+ rules: {
88
+ /* jsdom normalizes style so disabling rule when using this matcher or it
89
+ * gets quite noisy when configured with self-closing */
90
+ "void-style": "off"
108
91
  }
109
- else {
110
- if (expectedError) {
111
- const actual = result.messages;
112
- const expected = expect.arrayContaining([expect.objectContaining(expectedError)]);
113
- const errorPass = this.equals(actual, expected);
114
- const diffString = diff
115
- ? diff(expected, actual, {
116
- expand: this.expand,
117
- aAnnotation: "Expected error",
118
- bAnnotation: "Actual error",
119
- })
120
- : /* istanbul ignore next */ undefined;
121
- const hint = this.utils.matcherHint(".not.toHTMLValidate", undefined, undefined, {
122
- comment: "expected error",
123
- });
124
- const expectedErrorMessage = () => [
125
- hint,
126
- "",
127
- "Expected error to be present:",
128
- this.utils.printExpected(expectedError),
129
- /* istanbul ignore next */ diffString ? `\n${diffString}` : "",
130
- ].join("\n");
131
- return { pass: !errorPass, message: expectedErrorMessage, actual, expected };
132
- }
133
- const errors = result.messages.map((message) => ` ${message.message} [${message.ruleId}]`);
134
- return {
135
- pass,
136
- message: () => ["Expected HTML to be valid but had the following errors:", ""].concat(errors).join("\n"),
137
- };
92
+ };
93
+ const config = deepmerge(defaultConfig, userConfig ?? {});
94
+ const actualFilename = filename ?? this.testPath ?? "inline";
95
+ const loader = new FileSystemConfigLoader({
96
+ extends: ["html-validate:recommended"]
97
+ });
98
+ const htmlvalidate = new HtmlValidate(loader);
99
+ const report = htmlvalidate.validateStringSync(actual, actualFilename, config);
100
+ const pass = report.valid;
101
+ const result = report.results[0];
102
+ if (pass) {
103
+ return { pass, message: () => "HTML is valid when an error was expected" };
104
+ } else {
105
+ if (expectedError) {
106
+ const actual2 = result.messages;
107
+ const expected = expect.arrayContaining([expect.objectContaining(expectedError)]);
108
+ const errorPass = this.equals(actual2, expected);
109
+ const diffString = diff ? diff(expected, actual2, {
110
+ expand: this.expand,
111
+ aAnnotation: "Expected error",
112
+ bAnnotation: "Actual error"
113
+ }) : (
114
+ /* istanbul ignore next */
115
+ void 0
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, actual: actual2, expected };
138
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
+ }
139
137
  }
140
138
 
141
139
  function toHaveErrorImpl(context, expect, diff, actual, expected) {
142
- const flattened = flattenMessages(actual);
143
- const matcher = [expect.objectContaining(expected)];
144
- const pass = context.equals(flattened, matcher);
145
- const diffString = diff
146
- ? diff(matcher, flattened, { expand: context.expand })
147
- : /* istanbul ignore next */ undefined;
148
- const hint = context.utils.matcherHint(".toHaveError");
149
- const prettyExpected = context.utils.printExpected(matcher);
150
- const prettyReceived = context.utils.printReceived(flattened);
151
- const resultMessage = () => {
152
- return [
153
- hint,
154
- "",
155
- "Expected error to equal:",
156
- ` ${prettyExpected}`,
157
- "Received:",
158
- ` ${prettyReceived}`,
159
- /* istanbul ignore next */ diffString ? `\nDifference:\n\n${diffString}` : "",
160
- ].join("\n");
161
- };
162
- return { pass, message: resultMessage, actual: flattened, expected: matcher };
140
+ const flattened = flattenMessages(actual);
141
+ const matcher = [expect.objectContaining(expected)];
142
+ const pass = context.equals(flattened, matcher);
143
+ const diffString = diff ? diff(matcher, flattened, { expand: context.expand }) : (
144
+ /* istanbul ignore next */
145
+ void 0
146
+ );
147
+ const hint = context.utils.matcherHint(".toHaveError");
148
+ const prettyExpected = context.utils.printExpected(matcher);
149
+ const prettyReceived = context.utils.printReceived(flattened);
150
+ const resultMessage = () => {
151
+ return [
152
+ hint,
153
+ "",
154
+ "Expected error to equal:",
155
+ ` ${prettyExpected}`,
156
+ "Received:",
157
+ ` ${prettyReceived}`,
158
+ /* istanbul ignore next */
159
+ diffString ? `
160
+ Difference:
161
+
162
+ ${diffString}` : ""
163
+ ].join("\n");
164
+ };
165
+ return { pass, message: resultMessage, actual: flattened, expected: matcher };
163
166
  }
164
167
  function createMatcher$1(expect, diff) {
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) {
172
- /* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- this is supposed to accept anything */
173
- expected.context = arg3;
174
- }
175
- return toHaveErrorImpl(this, expect, diff, actual, expected);
176
- }
177
- else {
178
- return toHaveErrorImpl(this, expect, diff, actual, arg1);
179
- }
168
+ function toHaveError(actual, arg1, arg2, arg3) {
169
+ if (typeof arg1 === "string") {
170
+ const expected = {
171
+ ruleId: arg1,
172
+ message: arg2
173
+ };
174
+ if (arg3) {
175
+ expected.context = arg3;
176
+ }
177
+ return toHaveErrorImpl(this, expect, diff, actual, expected);
178
+ } else {
179
+ return toHaveErrorImpl(this, expect, diff, actual, arg1);
180
180
  }
181
- return diverge(toHaveError);
181
+ }
182
+ return diverge(toHaveError);
182
183
  }
183
184
 
184
- /* eslint-disable prefer-template -- technical debt, should be refactored */
185
185
  function createMatcher(expect, diff) {
186
- function toHaveErrors(report, errors) {
187
- const flattened = flattenMessages(report);
188
- const matcher = errors.map((entry) => {
189
- if (Array.isArray(entry)) {
190
- const [ruleId, message] = entry;
191
- return expect.objectContaining({ ruleId, message });
192
- }
193
- else {
194
- return expect.objectContaining(entry);
195
- }
196
- });
197
- const pass = this.equals(flattened, matcher);
198
- const diffString = diff
199
- ? diff(matcher, flattened, { expand: this.expand })
200
- : /* istanbul ignore next */ undefined;
201
- const resultMessage = () => this.utils.matcherHint(".toHaveErrors") +
202
- "\n\n" +
203
- "Expected error to equal:\n" +
204
- ` ${this.utils.printExpected(matcher)}\n` +
205
- "Received:\n" +
206
- ` ${this.utils.printReceived(flattened)}` +
207
- /* istanbul ignore next */ (diffString ? `\n\nDifference:\n\n${diffString}` : "");
208
- return { pass, message: resultMessage };
209
- }
210
- return diverge(toHaveErrors);
186
+ function toHaveErrors(report, errors) {
187
+ const flattened = flattenMessages(report);
188
+ const matcher = errors.map((entry) => {
189
+ if (Array.isArray(entry)) {
190
+ const [ruleId, message] = entry;
191
+ return expect.objectContaining({ ruleId, message });
192
+ } else {
193
+ return expect.objectContaining(entry);
194
+ }
195
+ });
196
+ const pass = this.equals(flattened, matcher);
197
+ const diffString = diff ? diff(matcher, flattened, { expand: this.expand }) : (
198
+ /* istanbul ignore next */
199
+ void 0
200
+ );
201
+ const resultMessage = () => this.utils.matcherHint(".toHaveErrors") + `
202
+
203
+ Expected error to equal:
204
+ ${this.utils.printExpected(matcher)}
205
+ Received:
206
+ ${this.utils.printReceived(flattened)}` + /* istanbul ignore next */
207
+ (diffString ? `
208
+
209
+ Difference:
210
+
211
+ ${diffString}` : "");
212
+ return { pass, message: resultMessage };
213
+ }
214
+ return diverge(toHaveErrors);
211
215
  }
212
216
 
213
- /**
214
- * @internal
215
- */
216
217
  function getResults(filename, value) {
217
- if (typeof value === "string") {
218
- const loader = new FileSystemConfigLoader({
219
- extends: ["html-validate:recommended"],
220
- });
221
- const htmlvalidate = new HtmlValidate(loader);
222
- const report = htmlvalidate.validateStringSync(value, filename, {
223
- rules: {
224
- "void-style": "off",
225
- },
226
- });
227
- return report.results.map((it) => {
228
- return { ...it, filePath: "inline" };
229
- });
230
- }
231
- else {
232
- return value.results;
233
- }
218
+ if (typeof value === "string") {
219
+ const loader = new FileSystemConfigLoader({
220
+ extends: ["html-validate:recommended"]
221
+ });
222
+ const htmlvalidate = new HtmlValidate(loader);
223
+ const report = htmlvalidate.validateStringSync(value, filename, {
224
+ rules: {
225
+ "void-style": "off"
226
+ }
227
+ });
228
+ return report.results.map((it) => {
229
+ return { ...it, filePath: "inline" };
230
+ });
231
+ } else {
232
+ return value.results;
233
+ }
234
234
  }
235
235
 
236
236
  export { createMatcher$3 as a, createMatcher$2 as b, createMatcher$4 as c, createMatcher$1 as d, createMatcher as e, getResults as g };