Pros of globals: - You'll be requiring them anyway - Easier for a test runner to inject Cons: - Globals introduces more environment variance - Have to explicitly tell your linter/typechecker that they're valid globals
-
-
Show this thread
-
Also another con is that it makes it significantly harder to introduce new testing utilities provided by the framework. You'll either need to tack it onto an existing global or introduce another one.
Show this thread
End of conversation
New conversation -
-
-
You wont have a consistent environment. Globals will be available in one environment (the one your tests run in), and your production one (where your normal code runs). It's not really an issue with globals because you can't really accidentaly refer to them.
-
Jest also adds an `expect` global (and maybe others?).
End of conversation
New conversation -
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Test framework, or test runner?
-
Jest, mocha, and ava are all kinda both right?
- 4 more replies
New conversation -
-
-
I guess, in practice, I've never really cared and it hasn't mattered in anything I've worked on. But I've always thought it was gross that most testing frameworks and runners use globals.
-
I will say that the use of globals encourages creating more globals to follow suit. Which isn't good. I'm guilty of that, and I always regretted it.
- 1 more reply
New conversation -
-
-
Can I vote “no strong opinion, as long as the docs are clear”?
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 