I am testing a bevy of async code that relies on a global configuration. I know global state is evil, but this is state that would not change in production, but must change in testing to account for various configurations. Since the resulting code is async it squashes the global config down to the last configuration made. I'm currently getting around this issue with the following bash script:
find -name "*.spec.js" | xargs -l1 jasmine-node
There are other ways to get around this, but being able to run each spec in its own parser instance would be a nice option.
I can't think of any other ways to get around it, if you'd like to take a stab at writing the code I'd be happy to review it for merge...
A few ideas:
I would need a little more detail to advise beyond the above
👍 the first one is what we do at my job.
@Lastalas I had considered after/beforeEach, but it just seems like a hulking mass of cruft to introduce. The others I'm not quite sure about, attaching to process seems like an interesting idea. The specs live here if you want to take a look: https://github.com/eborden/promiscuous/tree/master/spec
if you use the --config option on the command line, you can add variables to the sandbox that are accessible via process.env