Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why CSS.supports() is failing when running it with jest

I am trying to run a test that has CSS.supports() function in it.

describe('something', () => {
    it('fails',() => {
        CSS.supports('display', 'flex');
    } )
})

I get this error: ReferenceError: CSS is not defined.

Shouldn't JSDOM support this function? Thanks!

like image 295
Pistolpete . Avatar asked Nov 05 '25 05:11

Pistolpete .


1 Answers

This is not implemented in JSDom, but you can code around it by checking if CSS.supports exists and then the tests won't fail like so:

const supportsDvh = CSS.supports && CSS.supports('height: 100dvh');
like image 52
Justin Jenkins Avatar answered Nov 06 '25 20:11

Justin Jenkins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!