Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReferenceError: BroadcastChannel is not defined using jest testing libray

I'm getting error while runing the jest test case using react-testing library

enter image description here

like image 592
KARTHIKEYAN.A Avatar asked Aug 27 '26 15:08

KARTHIKEYAN.A


1 Answers

Alternatively, the BroadcastChannel is also available through the Node native "worker_threads" module.

All you need to do is run this in/before your test:

self.BroadcastChannel = require('worker_threads').BroadcastChannel;
like image 68
icl7126 Avatar answered Aug 29 '26 04:08

icl7126



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!