From 1de850726b7cd7676aa8c18cf419624ff655ddb3 Mon Sep 17 00:00:00 2001 From: Devon Powell Date: Tue, 30 Jul 2024 13:37:05 -0400 Subject: [PATCH] Split out axe tests --- src/create.js | 4 ++-- src/generators/{test-unit => test-unit-axe}/index.js | 6 ++++-- .../templates/configured/_README.md | 3 +++ .../templates/configured/_element.axe.js} | 8 +------- .../templates/configured/_element.test.js | 12 ++++++++++++ .../templates/configured/_package.json | 3 ++- .../templates/static/.github/workflows/ci.yml | 4 +++- .../templates/static/test/.eslintrc.json | 0 8 files changed, 27 insertions(+), 13 deletions(-) rename src/generators/{test-unit => test-unit-axe}/index.js (82%) rename src/generators/{test-unit => test-unit-axe}/templates/configured/_README.md (84%) rename src/generators/{test-unit/templates/configured/_element.test.js => test-unit-axe/templates/configured/_element.axe.js} (59%) create mode 100644 src/generators/test-unit-axe/templates/configured/_element.test.js rename src/generators/{test-unit => test-unit-axe}/templates/configured/_package.json (51%) rename src/generators/{test-unit => test-unit-axe}/templates/static/.github/workflows/ci.yml (85%) rename src/generators/{test-unit => test-unit-axe}/templates/static/test/.eslintrc.json (100%) diff --git a/src/create.js b/src/create.js index 28d73f0..c3b4dbb 100755 --- a/src/create.js +++ b/src/create.js @@ -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 = { @@ -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); diff --git a/src/generators/test-unit/index.js b/src/generators/test-unit-axe/index.js similarity index 82% rename from src/generators/test-unit/index.js rename to src/generators/test-unit-axe/index.js index 89d5a66..006f8cd 100644 --- a/src/generators/test-unit/index.js +++ b/src/generators/test-unit-axe/index.js @@ -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)); } diff --git a/src/generators/test-unit/templates/configured/_README.md b/src/generators/test-unit-axe/templates/configured/_README.md similarity index 84% rename from src/generators/test-unit/templates/configured/_README.md rename to src/generators/test-unit-axe/templates/configured/_README.md index 3387832..8713603 100644 --- a/src/generators/test-unit/templates/configured/_README.md +++ b/src/generators/test-unit-axe/templates/configured/_README.md @@ -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 ``` diff --git a/src/generators/test-unit/templates/configured/_element.test.js b/src/generators/test-unit-axe/templates/configured/_element.axe.js similarity index 59% rename from src/generators/test-unit/templates/configured/_element.test.js rename to src/generators/test-unit-axe/templates/configured/_element.axe.js index 802996a..0bbc8b9 100644 --- a/src/generators/test-unit/templates/configured/_element.test.js +++ b/src/generators/test-unit-axe/templates/configured/_element.axe.js @@ -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 %>', () => { @@ -10,10 +10,4 @@ describe('<%= className %>', () => { }); }); - describe('constructor', () => { - it('should construct', () => { - runConstructor('<%= tagName %>'); - }); - }); - }); diff --git a/src/generators/test-unit-axe/templates/configured/_element.test.js b/src/generators/test-unit-axe/templates/configured/_element.test.js new file mode 100644 index 0000000..93412f9 --- /dev/null +++ b/src/generators/test-unit-axe/templates/configured/_element.test.js @@ -0,0 +1,12 @@ +import '../<%= hyphenatedName %>.js'; +import { runConstructor } from '@brightspace-ui/testing'; + +describe('<%= className %>', () => { + + describe('constructor', () => { + it('should construct', () => { + runConstructor('<%= tagName %>'); + }); + }); + +}); diff --git a/src/generators/test-unit/templates/configured/_package.json b/src/generators/test-unit-axe/templates/configured/_package.json similarity index 51% rename from src/generators/test-unit/templates/configured/_package.json rename to src/generators/test-unit-axe/templates/configured/_package.json index c70cd58..fa72568 100644 --- a/src/generators/test-unit/templates/configured/_package.json +++ b/src/generators/test-unit-axe/templates/configured/_package.json @@ -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": { diff --git a/src/generators/test-unit/templates/static/.github/workflows/ci.yml b/src/generators/test-unit-axe/templates/static/.github/workflows/ci.yml similarity index 85% rename from src/generators/test-unit/templates/static/.github/workflows/ci.yml rename to src/generators/test-unit-axe/templates/static/.github/workflows/ci.yml index 07216ae..52559fd 100644 --- a/src/generators/test-unit/templates/static/.github/workflows/ci.yml +++ b/src/generators/test-unit-axe/templates/static/.github/workflows/ci.yml @@ -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 diff --git a/src/generators/test-unit/templates/static/test/.eslintrc.json b/src/generators/test-unit-axe/templates/static/test/.eslintrc.json similarity index 100% rename from src/generators/test-unit/templates/static/test/.eslintrc.json rename to src/generators/test-unit-axe/templates/static/test/.eslintrc.json