
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@open-wc/testing
Advanced tools
Part of Open Web Components
Open Web Components provides a set of defaults, recommendations and tools to help facilitate your web component project. Our recommendations include: developing, linting, testing, building, tooling, demoing, publishing and automating.
An opinionated package that combines and configures testing libraries to minimize the amount of ceremony required when writing tests.
To help you get started with testing, we recommend reading this article for a great step by step guide.
Exposes all functions of @open-wc/testing-helpers, so that you have a single package to import from:
import { fixture, html } from '@open-wc/testing';
describe('my-test', () => {
it('works', async () => {
const el = await fixture(html`
<my-element></my-element>
`);
});
});
Exposes chai as an es module with useful plugins pre-configured:
@open-wc/semantic-dom-diff for dom tree / snapshot testing:
import { expect, fixture, html } from '@open-wc/testing';
describe('Plugin - semantic-dom-diff', () => {
it('can semantically compare full dom trees', async () => {
const el = await fixture(`<div><!-- comment --><h1>${'Hey'} </h1> </div>`);
expect(el).dom.to.equal('<div><h1>Hey</h1></div>');
});
it('can semantically compare lightDom trees', async () => {
const el = await fixture(`<div><!-- comment --><h1>${'Hey'} </h1> </div>`);
expect(el).lightDom.to.equal('<h1>Hey</h1>');
});
it('can compare against a snapshot', async () => {
const el = await fixture(`<div><!-- comment --><h1>${'Hey'} </h1> </div>`);
expect(el).dom.to.equalSnapshot();
});
});
@open-wc/chai-a11y-axe for a11y testing:
import { expect, fixture, html } from '@open-wc/testing';
describe('my-test', () => {
it('works', async () => {
const el = await fixture(html`
<my-element></my-element>
`);
await expect(el).to.be.accessible();
});
});
chai-dom for dom testing:
import { fixture, expect } from '@open-wc/testing';
describe('Plugin - chai-dom', () => {
it('can check for an exiting css class', async () => {
const el = await fixture(`<div class="foo bar"></div>`);
expect(el).to.have.class('foo');
});
});
FAQs
Testing following open-wc recommendations
The npm package @open-wc/testing receives a total of 39,756 weekly downloads. As such, @open-wc/testing popularity was classified as popular.
We found that @open-wc/testing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.