UNPKG

@sa11y/jest

Version:
29 lines 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerSa11yAutomaticChecks = void 0; /* * Copyright (c) 2025, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ const globals_1 = require("@jest/globals"); const matcher_1 = require("@sa11y/matcher"); const matcher_2 = require("./matcher"); function registerSa11yAutomaticChecks(opts = matcher_1.defaultAutoCheckOpts, renderedDOMSaveOpts = matcher_1.defaultRenderedDOMSaveOpts) { if (!opts.runAfterEach) return; const observer = new MutationObserver(matcher_1.mutationObserverCallback); beforeEach(() => { if (opts.runDOMMutationObserver) { observer.observe(document.body, matcher_1.observerOptions); } }); afterEach(async () => { if (opts.runDOMMutationObserver) observer.disconnect(); await (0, matcher_1.runAutomaticCheck)(opts, renderedDOMSaveOpts, globals_1.expect.getState().testPath, globals_1.expect.getState().currentTestName, matcher_2.isTestUsingFakeTimer); }); } exports.registerSa11yAutomaticChecks = registerSa11yAutomaticChecks; //# sourceMappingURL=automatic.js.map