You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I was trying to test our components using Jest's Node.js environment instead of JSDom.
/** * @jest-environment node */importComponentfrom'metal-component';importAlertfrom'../src/Alert';describe('Alert.node',()=>{it('should not fail on the server side',()=>{constalert=Component.renderToString(Alert);expect(alert).not.toBeNull();});});
After an hour trying to understand why Jest was throwing client-side errors when it shouldn't, I realized it's because they set NODE_ENV equals test [1] and we use that same value on isServerSide [2].
I don't know what was the reason behind that, but I think that line shouldn't exist. Sure, I could just set a different value to that environment variable, but as we move into having components that also compile on the server, I think it's important to have a isServerSide that we can rely on. Otherwise, people would just create their own like what was done on WeDeploy's Console.
Today I was trying to test our components using Jest's Node.js environment instead of JSDom.
After an hour trying to understand why Jest was throwing client-side errors when it shouldn't, I realized it's because they set
NODE_ENV
equalstest
[1] and we use that same value onisServerSide
[2].I don't know what was the reason behind that, but I think that line shouldn't exist. Sure, I could just set a different value to that environment variable, but as we move into having components that also compile on the server, I think it's important to have a
isServerSide
that we can rely on. Otherwise, people would just create their own like what was done on WeDeploy's Console.[1] jestjs/jest#3370
[2] https://github.com/metal/metal.js/blob/master/packages/metal/src/coreNamed.js#L307
The text was updated successfully, but these errors were encountered: