Skip to content

Commit

Permalink
feat: axe ally accessibility testing
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Apr 28, 2021
1 parent c50907a commit 0cb9875
Show file tree
Hide file tree
Showing 282 changed files with 4,166 additions and 3,074 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"name": "jest instrument",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"cwd": "${workspaceFolder}/core/instrument",
"args": ["jest-tests"],
"args": ["extract-component"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
Expand Down
7 changes: 7 additions & 0 deletions core/core/src/node-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ export const getCSSBundleName = (options: BuildProps): string =>

export const getCSSFilePath = (options: BuildProps): string =>
path.join(getDistFolder(options), options.cssFileName || defCssFileName);

export const resolveSnapshotFile = (testFilePath: string): string =>
path.resolve(
path.dirname(testFilePath),
'__snapshots__',
`${path.basename(testFilePath)}.snap`,
);
19 changes: 10 additions & 9 deletions core/instrument/src/misc/jest-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
findJestConfig,
getRelatedTests,
} from '@component-controls/jest-extract';
import { resolveSnapshotFile } from '@component-controls/core/node-utils';
import { JestTests } from '@component-controls/core';
import { CachedFileResource } from './chached-file';

Expand All @@ -32,15 +33,14 @@ export const extractTests = async (
},
file,
) => {
acc.testFiles.push(...getRelatedTests(file));
const snapshotFolder = path.join(path.dirname(file), '__snapshots__');
if (fs.existsSync(snapshotFolder)) {
acc.snapshotFiles.push(
...fs
.readdirSync(snapshotFolder)
.map(f => path.resolve(snapshotFolder, f)),
);
}
const testFiles = getRelatedTests(file);
acc.testFiles.push(...testFiles);
testFiles.forEach(f => {
const snapshotFile = resolveSnapshotFile(f);
if (fs.existsSync(snapshotFile)) {
acc.snapshotFiles.push(snapshotFile);
}
});
if (!acc.coverageFiles.includes(file)) {
acc.coverageFiles.push(file);
}
Expand All @@ -53,6 +53,7 @@ export const extractTests = async (
...tests.testFiles,
...tests.coverageFiles,
...tests.snapshotFiles,
...files,
]);
const cachedResults = cached.get();
if (cachedResults) {
Expand Down
170 changes: 109 additions & 61 deletions core/instrument/test/extract-component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,84 +155,132 @@ describe('extract-component', () => {
testFilePath: 'Table.test.ts',
testResults: [
{
ancestorTitles: ['Table'],
failureDetails: [],
failureMessages: [],
fullName: 'Table overview',
location: null,
numPassingAsserts: 0,
ancestorTitles: ['Table', 'overview'],
fullName: 'Table overview snapshot',
status: 'passed',
title: 'overview',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table'],
failureDetails: [],
failureMessages: [],
fullName: 'Table noHeader',
location: null,
numPassingAsserts: 0,
ancestorTitles: ['Table', 'overview'],
fullName: 'Table overview accessibility',
status: 'passed',
title: 'noHeader',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table'],
failureDetails: [],
failureMessages: [],
fullName: 'Table sortable',
location: null,
numPassingAsserts: 0,
ancestorTitles: ['Table', 'noHeader'],
fullName: 'Table noHeader snapshot',
status: 'passed',
title: 'sortable',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table'],
failureDetails: [],
failureMessages: [],
fullName: 'Table filterable',
location: null,
numPassingAsserts: 0,
ancestorTitles: ['Table', 'noHeader'],
fullName: 'Table noHeader accessibility',
status: 'passed',
title: 'filterable',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table'],
ancestorTitles: ['Table', 'sortable'],
fullName: 'Table sortable snapshot',
status: 'passed',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
failureMessages: [],
fullName: 'Table grouping',
location: null,
},
{
ancestorTitles: ['Table', 'sortable'],
fullName: 'Table sortable accessibility',
status: 'passed',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table', 'filterable'],
fullName: 'Table filterable snapshot',
status: 'passed',
title: 'grouping',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table'],
ancestorTitles: ['Table', 'filterable'],
fullName: 'Table filterable accessibility',
status: 'passed',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
failureMessages: [],
fullName: 'Table editing',
location: null,
},
{
ancestorTitles: ['Table', 'grouping'],
fullName: 'Table grouping snapshot',
status: 'passed',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table', 'grouping'],
fullName: 'Table grouping accessibility',
status: 'passed',
title: 'editing',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table'],
ancestorTitles: ['Table', 'editing'],
fullName: 'Table editing snapshot',
status: 'passed',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
failureMessages: [],
fullName: 'Table rowSelect',
location: null,
},
{
ancestorTitles: ['Table', 'editing'],
fullName: 'Table editing accessibility',
status: 'passed',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table', 'rowSelect'],
fullName: 'Table rowSelect snapshot',
status: 'passed',
title: 'rowSelect',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table'],
ancestorTitles: ['Table', 'rowSelect'],
fullName: 'Table rowSelect accessibility',
status: 'passed',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
failureMessages: [],
fullName: 'Table pagination',
location: null,
},
{
ancestorTitles: ['Table', 'pagination'],
fullName: 'Table pagination snapshot',
status: 'passed',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table', 'pagination'],
fullName: 'Table pagination accessibility',
status: 'passed',
title: 'pagination',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
},
],
},
Expand All @@ -246,22 +294,22 @@ describe('extract-component', () => {
pct: 98.04,
},
functions: {
total: 10,
total: 11,
covered: 7,
skipped: 0,
pct: 70,
pct: 63.64,
},
statements: {
total: 56,
covered: 55,
total: 57,
covered: 56,
skipped: 0,
pct: 98.21,
pct: 98.25,
},
branches: {
total: 49,
total: 50,
covered: 40,
skipped: 0,
pct: 81.63,
pct: 80,
},
},
'TableFilter.tsx': {
Expand Down Expand Up @@ -310,10 +358,10 @@ describe('extract-component', () => {
pct: 95.24,
},
branches: {
total: 20,
covered: 15,
total: 22,
covered: 16,
skipped: 0,
pct: 75,
pct: 72.73,
},
},
'TableRowSelection.tsx': {
Expand All @@ -336,10 +384,10 @@ describe('extract-component', () => {
pct: 100,
},
branches: {
total: 0,
covered: 0,
total: 2,
covered: 1,
skipped: 0,
pct: 100,
pct: 50,
},
},
'useTableLayout.ts': {
Expand Down
Loading

0 comments on commit 0cb9875

Please sign in to comment.