tailwindcss/jest/customMatchers.js

22 lines
578 B
JavaScript

expect.extend({
// Compare two CSS strings with all whitespace removed
// This is probably naive but it's fast and works well enough.
toMatchCss(received, argument) {
function stripped(str) {
return str.replace(/\s/g, '').replace(/;/g, '')
}
if (stripped(received) === stripped(argument)) {
return {
message: () => `expected ${received} not to match CSS ${argument}`,
pass: true,
}
} else {
return {
message: () => `expected ${received} to match CSS ${argument}`,
pass: false,
}
}
},
})