lundi 16 décembre 2019

Failing enzyme test using process.env

I am working on a component in React that depends on the AWS sandbox environment config endpoint with

this.environment = this.environment || await requestLocalGet('/config');

in componentDidMount and this.environment = null set in the constructor.

I have two tests that are currently failing with the error Error: Uncaught [TypeError: Cannot read property 'nodeEnv' of null] that test for a state change in the error variable. However, when I set this.environment = '' the tests pass. I do need to set it as null for consistency purposes so I am not able to keep it as an empty string. I am not sure how to fix my tests for them to pass.

Aucun commentaire:

Enregistrer un commentaire