When you're using a testing framework, do you prefer your test declarations to be global variables like Mocha or Jest? Or to have explicit imports like Ava? import test from 'ava'; test('title', () => {}); vs. // global.test test('title', () => {});
-
Show this thread
-
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
4 replies 0 retweets 23 likesShow this thread -
Replying to @stagingandlive @CosmosInner
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.
1 reply 0 retweets 0 likes
Replying to @sebmck @CosmosInner
Jest also adds an `expect` global (and maybe others?).
3:10 PM - 13 Apr 2019
0 replies
0 retweets
0 likes
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 