|
5 | 5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause |
6 | 6 | */ |
7 | 7 |
|
8 | | -import { runAutomaticCheck, skipTest, registerCustomSa11yRules } from '../src'; |
| 8 | +import { runAutomaticCheck, skipTest, skipTestByName, registerCustomSa11yRules } from '../src'; |
9 | 9 |
|
10 | 10 | import { |
11 | 11 | beforeEachSetup, |
@@ -106,6 +106,39 @@ describe('automatic checks call', () => { |
106 | 106 | } |
107 | 107 | ); |
108 | 108 |
|
| 109 | + |
| 110 | + test.each([ |
| 111 | + ['my test name', undefined, false], |
| 112 | + ['my test name', [], false], |
| 113 | + ['my test name', ['my test'], true], |
| 114 | + ['my test name', ['MY TEST'], true], |
| 115 | + ['my test name', ['my test', 'other'], true], |
| 116 | + ['my test name', ['other'], false], |
| 117 | + ['my test name', ['my test name extra'], false], |
| 118 | + ])( |
| 119 | + 'should filter test by name as expected with args # %#', |
| 120 | + (testName: string, testsFilter: string[] | undefined, expectedResult: boolean) => { |
| 121 | + expect(skipTestByName(testName, testsFilter)).toBe(expectedResult); |
| 122 | + } |
| 123 | + ); |
| 124 | + |
| 125 | + it('should skip auto checks when test name is excluded using testsFilter', async () => { |
| 126 | + document.body.innerHTML = domWithA11yIssues; |
| 127 | + await expect( |
| 128 | + runAutomaticCheck( |
| 129 | + { testsFilter: ['non-matching-name', testName] }, |
| 130 | + { renderedDOMDumpDirPath: '' }, |
| 131 | + testPath, |
| 132 | + testName |
| 133 | + ) |
| 134 | + ).resolves.toBeUndefined(); |
| 135 | + }); |
| 136 | + |
| 137 | + it('should run auto checks when test name is not excluded using testsFilter', async () => { |
| 138 | + document.body.innerHTML = domWithA11yIssues; |
| 139 | + await expect(runAutomaticCheck({ testsFilter: ['non-matching-name'] }, {}, testPath, testName)).rejects.toThrow(); |
| 140 | + }); |
| 141 | + |
109 | 142 | it('should skip auto checks when file is excluded using filter', async () => { |
110 | 143 | document.body.innerHTML = domWithA11yIssues; |
111 | 144 | await expect( |
@@ -199,6 +232,7 @@ describe('automatic.ts exports', () => { |
199 | 232 | cleanupAfterEach: true, |
200 | 233 | consolidateResults: true, |
201 | 234 | filesFilter: [], |
| 235 | + testsFilter: [], |
202 | 236 | runDOMMutationObserver: false, |
203 | 237 | enableIncompleteResults: false, |
204 | 238 | }); |
|
0 commit comments