Skip to content

Commit

Permalink
Split out axe tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devpow112 committed Jul 30, 2024
1 parent 34d0cf7 commit 1de8507
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { run as setupElement } from './generators/wc-lit-element/index.js';
import { run as setupLocalization } from './generators/localization/index.js';
import { run as setupRelease } from './generators/release/index.js';
import { run as setupStaticSite } from './generators/static-site/index.js';
import { run as setupTestUnit } from './generators/test-unit/index.js';
import { run as setupTestUnitAxe } from './generators/test-unit-axe/index.js';
import { run as setupTestVdiff } from './generators/test-vdiff/index.js';

const generatorTypes = {
Expand Down Expand Up @@ -148,7 +148,7 @@ async function executeComponentGenerator() {

setupDefaultContent(options);
setupElement(options);
setupTestUnit(options);
setupTestUnitAxe(options);
if (options.vdiff) setupTestVdiff(options);
setupDemo(options);
if (options.localization) setupLocalization(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export function run(templateData) {
`${__dirname}/templates/configured/_README.md`,
`${getDestinationPath(templateData.hyphenatedName)}/README.md`
);

copyFile(
`${__dirname}/templates/configured/_element.test.js`,
`${getDestinationPath(templateData.hyphenatedName)}/test/${templateData.hyphenatedName}.test.js`
);
copyFile(
`${__dirname}/templates/configured/_element.axe.js`,
`${getDestinationPath(templateData.hyphenatedName)}/test/${templateData.hyphenatedName}.axe.js`
);
replaceText(`${getDestinationPath(templateData.hyphenatedName)}/test/${templateData.hyphenatedName}.test.js`, templateData);

copyFilesInDir(`${__dirname}/templates/static`, getDestinationPath(templateData.hyphenatedName));
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ npm run lint:eslint
# stylelint
npm run lint:style

# accessibility tests
npm run test:axe

# unit tests
npm run test:unit
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '../<%= hyphenatedName %>.js';
import { expect, fixture, html, runConstructor } from '@brightspace-ui/testing';
import { expect, fixture, html } from '@brightspace-ui/testing';

describe('<%= className %>', () => {

Expand All @@ -10,10 +10,4 @@ describe('<%= className %>', () => {
});
});

describe('constructor', () => {
it('should construct', () => {
runConstructor('<%= tagName %>');
});
});

});
12 changes: 12 additions & 0 deletions src/generators/test-unit-axe/templates/configured/_element.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import '../<%= hyphenatedName %>.js';
import { runConstructor } from '@brightspace-ui/testing';

describe('<%= className %>', () => {

describe('constructor', () => {
it('should construct', () => {
runConstructor('<%= tagName %>');
});
});

});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"scripts": {
"test": "npm run lint && npm run test:unit",
"test": "npm run lint && npm run test:axe && npm run test:unit",
"test:axe": "d2l-test-runner axe --chrome",
"test:unit": "d2l-test-runner"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ jobs:
run: npm run lint:eslint
- name: Lint (CSS)
run: npm run lint:style
- name: Unit Tests
- name: Accessibility tests
run: npm run test:axe
- name: Unit tests
run: npm run test:unit

0 comments on commit 1de8507

Please sign in to comment.