UNPKG

@sa11y/jest

Version:
39 lines 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerSa11yMatcher = exports.setup = 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 automatic_1 = require("./automatic"); const matcher_2 = require("./matcher"); function setup(opts = matcher_1.defaultSa11yOpts) { const testPath = globals_1.expect.getState().testPath ?? ''; const ignoreImprovedChecks = matcher_1.improvedChecksFilter.some((fileName) => testPath.toLowerCase().includes(fileName.toLowerCase())); if (process.env.SA11Y_AUTO && !ignoreImprovedChecks) { (0, matcher_1.registerRemoveChild)(); } registerSa11yMatcher(); (0, matcher_1.registerCustomSa11yRules)(); const autoCheckOpts = opts.autoCheckOpts; (0, matcher_1.updateAutoCheckOpts)(autoCheckOpts); const renderedDOMSaveOpts = opts.renderedDOMSaveOpts; (0, automatic_1.registerSa11yAutomaticChecks)(autoCheckOpts, renderedDOMSaveOpts); } exports.setup = setup; function registerSa11yMatcher() { if (globals_1.expect !== undefined) { globals_1.expect.extend({ toBeAccessible: matcher_2.toBeAccessible }); } else { throw new Error("Unable to find Jest's expect function." + '\nPlease check your Jest installation and that you have added @sa11y/jest correctly to your jest configuration.' + '\nSee https://github.com/salesforce/sa11y/tree/master/packages/jest#readme for help.'); } } exports.registerSa11yMatcher = registerSa11yMatcher; //# sourceMappingURL=setup.js.map