Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Semantic-UI-React could not enable debug

I am using semantic-ui-react and I am trying to create snapshot tests using jest. However, I keep getting this message. Could someone shed some light on this? I am using semantic with nextjs.

console.error node_modules/fbjs/lib/warning.js:36
      Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
    console.error node_modules/semantic-ui-react/dist/commonjs/lib/debug.js:30
      Semantic-UI-React could not enable debug.
    console.error node_modules/semantic-ui-react/dist/commonjs/lib/debug.js:31
      TypeError: Cannot read property 'debug' of undefined
like image 610
Niall Avatar asked Apr 06 '26 19:04

Niall


2 Answers

This warning is produced when debug can't deal with localStorage, but it shouldn't be called for tests. Make sure that the ENV vars are set correctly, you need to have NODE_ENV=test.

like image 168
Oleksandr Fediashov Avatar answered Apr 09 '26 09:04

Oleksandr Fediashov


For those who can't solve the problem with setting NODE_ENV=test. Anotherr option is to use or extend some test setup script (ie mocha -r setup.js):

// if you run Enzyme tests then you probably already have this import which creates global.window object
import 'jsdom-global/register'

global.window.localStorage = {};

For me both options work. I am running my tests on Linux.

like image 30
Sobik Avatar answered Apr 09 '26 07:04

Sobik



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!