How to use Node global in tests and custom reporter code? #15197
Unanswered
laurentsd
asked this question in
Questions and Help
Replies: 1 comment
-
I did check that the test and the reporter were running in two different Node processes which would explain why the global object is not the same. Other than writing into a file I can't think of any easy way to share the results then. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to store some test information in Node's global object (globalThis) so that I can use it in my custom reporter.
In the test code I set this flag when the testbed cannot be cleaned up:
My custom reporter is inspired from the Mocha tutorial: https://mochajs.org/api/tutorial-custom-reporter.html:
I don't understand why globalThis['testStatus'] is seen as undefined in the reporter when I can console.log it in the test code. Is it because globalThis is not really global to Node when running the test and executing the reporter? i.e. those are 2 different processes and I need to find another way to share test results in my reporter code?
Thanks for the help!
Beta Was this translation helpful? Give feedback.
All reactions