@cxl/spec
v1.0.1
Published
This library provides a comprehensive testing framework tailored for browser environments, offering utilities for defining tests, assertions, DOM manipulations, event handling, mocking, spying, and accessibility checks.
Readme
@cxl/spec
This library provides a comprehensive testing framework tailored for browser environments, offering utilities for defining tests, assertions, DOM manipulations, event handling, mocking, spying, and accessibility checks.
Project Details
Installation
npm install @cxl/specFeatures
- Define synchronous and asynchronous tests and test suites with
TestandTestApi. - Assertions for equality, partial matching, buffer comparison, throwing errors, and custom assertions.
- DOM manipulation helpers and connected test DOM containers.
- Event expectation and testing utilities with promise-based APIs.
- Mocking and spying of functions and properties.
- Accessibility testing integration.
- Advanced time mocking for
setTimeout,setInterval, andrequestAnimationFrame. - Actions like hover, tap, click, type, and press with runner command integration.
- Figure-based visual testing support.
- Structured JSON result output for tests.
Defining Tests
import { spec } from '@cxl/spec';
spec('Example test', async test => {
test.ok(true, 'This test should pass');
test.equal(1 + 1, 2, 'Math works');
await test.testElement('test a DOM element', async a => {
const el = a.element('div');
a.ok(el instanceof HTMLElement, 'Element created');
});
});