jeudi 11 juin 2020

Sharing global context between test suites in mocha

Keeping test suites as isolated as possible is generally a good practice. However, my use case requires a global context to be shared between all my test suites. This context would be generated in my setup hook that runs within a beforeAll and would contain a variety of properties that should only be created once and cleaned up after all system tests have completed.

My current solution leverages the NodeJS.Global object. I'm currently appending a config object containing everything I need but I'm wondering if there's a better solution out there.

Any suggestion is greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire