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 @sebmck
I much prefer imports as it also usually means your test framework lets your test executable without a test runner. But also the more general rule of: explicit > implicit
2 replies 0 retweets 7 likes -
Replying to @ReBeccaOrg @sebmck
Being able to run tests directly from vanilla Node is an essential simplification IMO. node test.js I hope more people begin to value this when selecting a testing approach.
3 replies 1 retweet 15 likes -
Replying to @robpalmer2 @ReBeccaOrg
What do you expect that to do? Actually run your tests? Or just execute that file with no errors?
2 replies 0 retweets 2 likes -
Replying to @sebmck @robpalmer2
I expect test output for that one file... I come from the cross-language tap ecosystem, where direct test output is defined protocol that's consumed by test runners. Because it's a protocol, I've written tap tests in everything from C to MySQL.
1 reply 0 retweets 8 likes
Ahh. I guess I come from (and helped create) a world where when I want to run my JS, it has to be processed anyway, so there’s always at least one level of indirection.
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 