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', () => {});
-
-
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 threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
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
-
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 more replies
New conversation -
-
-
When I first saw ‘describe’ I was super confused where it was coming from. This was before type-aware js-IDEs so couldn’t ‘click’ them. Also more recently a member of our team wanted to try Jest but got lots of typescript errors as the globals clashed with Mocha’s
-
I feel it wouldn’t have become a pattern in node if JavaScript test frameworks hadn’t targeted browsers first, where libraries always added to global scope
End of conversation
New conversation -
-
-
Don’t care either way.
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 