@sa11y/jest 7.1.4 → 7.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,6 +20,7 @@ Accessibility matcher for [Jest](https://jestjs.io)
20
20
  - [Limitations](#limitations)
21
21
  - [Disabled Checks](#disabled-checks)
22
22
  - [Related Packages](#related-packages)
23
+ - [Options](#options)
23
24
 
24
25
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
25
26
 
@@ -52,6 +53,14 @@ const { setup } = require('@sa11y/jest'); // CommonJS
52
53
  import { setup } from '@sa11y/jest'; // ES6
53
54
  // Register the sa11y matcher
54
55
  setup();
56
+
57
+ // Register with custom options for automatic checks and DOM saving
58
+ setup({
59
+ autoCheckOpts: { runAfterEach: true, cleanupAfterEach: true },
60
+ renderedDOMSaveOpts: {
61
+ /* your RenderedDOMSaveOpts here */
62
+ },
63
+ });
55
64
  ```
56
65
 
57
66
  - Add or Modify the Jest config at project root to invoke the Jest setup file as setup above.
@@ -169,6 +178,14 @@ setup({ autoCheckOpts: { runAfterEach: true } });
169
178
 
170
179
  // To optionally cleanup the body after running a11y checks
171
180
  setup({ autoCheckOpts: { runAfterEach: true, cleanupAfterEach: true } });
181
+
182
+ // To customize how/where the rendered DOM is saved during automatic checks
183
+ setup({
184
+ autoCheckOpts: { runAfterEach: true },
185
+ renderedDOMSaveOpts: {
186
+ /* your RenderedDOMSaveOpts here */
187
+ },
188
+ });
172
189
  ```
173
190
 
174
191
  ### Using environment variables
@@ -283,3 +300,17 @@ Automatic checks currently has the following limitations.
283
300
  ## Related Packages
284
301
 
285
302
  - [`@sa11y/matcher`](../matcher/README.md): Provides the core accessibility checking APIs used by this package. Use it directly for custom test runners or advanced integrations.
303
+
304
+ ### Options
305
+
306
+ - `autoCheckOpts`: Options for automatic accessibility checks (see below)
307
+ - `renderedDOMSaveOpts`: Options for saving the rendered DOM during automatic checks. Allows customizing how and where the DOM is saved for debugging or reporting purposes. See [`@sa11y/matcher` RenderedDOMSaveOpts](../matcher/README.md#rendereddomsaveopts) for details.
308
+
309
+ **autoCheckOpts:**
310
+
311
+ - `runAfterEach`: Run after each test (for integration with test runners)
312
+ - `cleanupAfterEach`: Clean up the DOM after checking
313
+ - `consolidateResults`: Deduplicate results
314
+ - `filesFilter`: Array of file path substrings to skip automatic checks for
315
+ - `runDOMMutationObserver`: Enable DOM mutation observer mode
316
+ - `enableIncompleteResults`: Include incomplete results
@@ -1,3 +1,3 @@
1
- import type { AutoCheckOpts } from '@sa11y/matcher';
2
- export declare function registerSa11yAutomaticChecks(opts?: AutoCheckOpts): void;
1
+ import type { AutoCheckOpts, RenderedDOMSaveOpts } from '@sa11y/matcher';
2
+ export declare function registerSa11yAutomaticChecks(opts?: AutoCheckOpts, renderedDOMSaveOpts?: RenderedDOMSaveOpts): void;
3
3
  //# sourceMappingURL=automatic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"automatic.d.ts","sourceRoot":"","sources":["../src/automatic.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,aAAoC,GAAG,IAAI,CAc7F"}
1
+ {"version":3,"file":"automatic.d.ts","sourceRoot":"","sources":["../src/automatic.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,wBAAgB,4BAA4B,CACxC,IAAI,GAAE,aAAoC,EAC1C,mBAAmB,GAAE,mBAAgD,GACtE,IAAI,CAoBN"}
package/dist/automatic.js CHANGED
@@ -10,7 +10,7 @@ exports.registerSa11yAutomaticChecks = void 0;
10
10
  const globals_1 = require("@jest/globals");
11
11
  const matcher_1 = require("@sa11y/matcher");
12
12
  const matcher_2 = require("./matcher");
13
- function registerSa11yAutomaticChecks(opts = matcher_1.defaultAutoCheckOpts) {
13
+ function registerSa11yAutomaticChecks(opts = matcher_1.defaultAutoCheckOpts, renderedDOMSaveOpts = matcher_1.defaultRenderedDOMSaveOpts) {
14
14
  if (!opts.runAfterEach)
15
15
  return;
16
16
  const observer = new MutationObserver(matcher_1.mutationObserverCallback);
@@ -22,7 +22,7 @@ function registerSa11yAutomaticChecks(opts = matcher_1.defaultAutoCheckOpts) {
22
22
  afterEach(async () => {
23
23
  if (opts.runDOMMutationObserver)
24
24
  observer.disconnect();
25
- await (0, matcher_1.runAutomaticCheck)(opts, globals_1.expect.getState().testPath, matcher_2.isTestUsingFakeTimer);
25
+ await (0, matcher_1.runAutomaticCheck)(opts, renderedDOMSaveOpts, globals_1.expect.getState().testPath, globals_1.expect.getState().currentTestName, matcher_2.isTestUsingFakeTimer);
26
26
  });
27
27
  }
28
28
  exports.registerSa11yAutomaticChecks = registerSa11yAutomaticChecks;
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAiBA,wBAAgB,KAAK,CAAC,IAAI,gDAAmB,GAAG,IAAI,CAanD;AACD,wBAAgB,oBAAoB,IAAI,IAAI,CAU3C"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAiBA,wBAAgB,KAAK,CAAC,IAAI,gDAAmB,GAAG,IAAI,CAenD;AACD,wBAAgB,oBAAoB,IAAI,IAAI,CAU3C"}
package/dist/setup.js CHANGED
@@ -21,7 +21,8 @@ function setup(opts = matcher_1.defaultSa11yOpts) {
21
21
  (0, matcher_1.registerCustomSa11yRules)();
22
22
  const autoCheckOpts = opts.autoCheckOpts;
23
23
  (0, matcher_1.updateAutoCheckOpts)(autoCheckOpts);
24
- (0, automatic_1.registerSa11yAutomaticChecks)(autoCheckOpts);
24
+ const renderedDOMSaveOpts = opts.renderedDOMSaveOpts;
25
+ (0, automatic_1.registerSa11yAutomaticChecks)(autoCheckOpts, renderedDOMSaveOpts);
25
26
  }
26
27
  exports.setup = setup;
27
28
  function registerSa11yMatcher() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sa11y/jest",
3
- "version": "7.1.4",
3
+ "version": "7.2.0-alpha.2",
4
4
  "description": "Accessibility testing matcher for Jest",
5
5
  "license": "BSD-3-Clause",
6
6
  "homepage": "https://github.com/salesforce/sa11y/tree/master/packages/jest#readme",
@@ -24,10 +24,10 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@jest/test-result": "^27",
27
- "@sa11y/assert": "7.1.4",
28
- "@sa11y/format": "7.1.4",
29
- "@sa11y/matcher": "7.1.4",
30
- "@sa11y/preset-rules": "7.1.4",
27
+ "@sa11y/assert": "7.2.0-alpha.2",
28
+ "@sa11y/format": "7.2.0-alpha.2",
29
+ "@sa11y/matcher": "7.2.0-alpha.2",
30
+ "@sa11y/preset-rules": "7.2.0-alpha.2",
31
31
  "jest-matcher-utils": "^27"
32
32
  },
33
33
  "peerDependencies": {
@@ -35,8 +35,8 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@jest/globals": "28.1.3",
38
- "@sa11y/common": "7.1.4",
39
- "@sa11y/test-utils": "7.1.4"
38
+ "@sa11y/common": "7.2.0-alpha.2",
39
+ "@sa11y/test-utils": "7.2.0-alpha.2"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"
@@ -44,5 +44,5 @@
44
44
  "engines": {
45
45
  "node": "^18 || ^20"
46
46
  },
47
- "gitHead": "258e6f748dcee8e91328c9342a21ae8cd90c533c"
47
+ "gitHead": "064631247ec53ade5ea3658c4bee71125633f96d"
48
48
  }