Skip to content

Add a block unit-test harness with @web/test-runner#14

Merged
benpeter merged 2 commits into
mainfrom
conti-test-harness
Jul 25, 2026
Merged

Add a block unit-test harness with @web/test-runner#14
benpeter merged 2 commits into
mainfrom
conti-test-harness

Conversation

@benpeter

Copy link
Copy Markdown
Collaborator

Fix #13

Introduce a unit-test harness for block JavaScript.

The project had lint but no tests. This adds @web/test-runner with @esm-bundle/chai and sinon. Tests run in a real headless Chrome, so decorate() and the scripts/aem.js helpers it imports run for real. There is no build step and no config file, matching how Adobe EDS projects test blocks.

Seed tests cover the three interactive blocks:

  • promo-bar: collapsed toggle, the panel content wrapper, inert wiring, secondary button link, and expand and collapse.
  • carousel: one slide per row, arrows, dots, counter, image optimization, current-slide inert state, next, wrap-around, and dot jump.
  • perfect-fit: three item buttons, a hidden modal, opening on the matching tab, Escape close with focus restore, and prevented form submit.

CI runs npm test on every push, under xvfb, before the linters.

Testing: npm test runs 18 tests, all passing, in about 1 second. npm run lint passes. No product code changed, so there is no page to preview for this PR.

Introduce unit tests for the custom blocks, run in a real headless Chrome
via @web/test-runner. No build step and no config file, matching how Adobe
EDS projects test blocks.

Cover the three interactive blocks: promo-bar, carousel, and perfect-fit.
Each test builds the authored DOM, calls decorate(), and asserts on the
result. Promo-bar collapse and expand, carousel navigation and wrap-around,
and the perfect-fit modal open, close, and tab selection.

CI runs the tests on every push, under xvfb, before the linters. Run
locally with npm test. 18 tests, all passing.
@aem-code-sync

aem-code-sync Bot commented Jul 25, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run all PSI checks
  • Re-run failed PSI checks
  • Re-sync branch
Commits

@benpeter
benpeter merged commit 30ebeae into main Jul 25, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce a block unit-test harness

1 participant