Closed Drarig29 closed 2 years ago
I'm trying to run unit tests for my API on the server-side. But I get:
window is not defined
https://github.com/bytesbay/web3-token/blob/a77579931a606f06239b9f06021a8b587f749cd9/src/lib/sign/sign.js#L106-L108
I believe you tried to check if the window object exists here with the optional chaining operator.
But it doesn't work like that. You should check with typeof window === 'undefined' instead.
typeof window === 'undefined'
If you do that, the lib will entirely work both on Node.js and in the browser.
I'm trying to run unit tests for my API on the server-side. But I get:
https://github.com/bytesbay/web3-token/blob/a77579931a606f06239b9f06021a8b587f749cd9/src/lib/sign/sign.js#L106-L108
I believe you tried to check if the window object exists here with the optional chaining operator.
But it doesn't work like that. You should check with
typeof window === 'undefined'
instead.If you do that, the lib will entirely work both on Node.js and in the browser.