`isChromatic` fails in non-browser environment
Closed this issue · 2 comments
Bug report
I have some code that runs in both snapshots as well as in vitest (node), and I need to set a parameter differently between the two, so I tried to use isChromatic()
. However, that fails in vitest with:
Cannot read properties of undefined (reading 'match')
From this line:
Line 8 in 5b928dc
Perhaps a guard could be added before checking match
there?
I've gotten a similar failure / issue when using isChromatic
in a react-native application (it's an RN + RN-web app which we run Chromatic on the web variant of).
In this case though, the failure didn't come from location.href
being undefined, but from navigator.userAgent
(line above line linked in this report) being undefined in a RN context.
Happy to propose a fix for both if you're accepting contribs :)