Compiled

@compiled/jest

Jest testing utilities. For help with testing read the testing guide.

npm install @compiled/jest --save-dev

Jest matcher

Assert styles in your unit tests.

import { toHaveCompiledCss } from '@compiled/jest';

expect.extend({
  toHaveCompiledCss,
});
expect(element).toHaveCompiledCss(property-name, value, ?options);
expect(element).toHaveCompiledCss({ [propertyName]: value }, ?options);

Media queries

Narrows the assertion down to any valid media query.

expect(element).toHaveCompiledCss('color', 'red', {
  media: '(min-width: 300px)',
});

Pseudo selectors

Narrows the assertion down to any valid pseudo selector.

expect(element).toHaveCompiledCss('color', 'red', {
  target: ':hover',
});

Suggest changes to this page ➚