refactor(major): reimplement, smaller & faster #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I don't know why, but from time to time, I sit and write test / task runners. 🤣
Always trying different ways, different approach, smallest possible implementation and so on. This time, I just realized that 60 lines of code are enough and pretty useful and stable and extensible. As always, code comments for docs are 3-4 times more than the actual code.
I'm back to the idea that we don't need CLI. And it makes sense to be a separate thing. What's the most common case? You write a small library with one test file, in most of the time. You literally don't need transpiling, workers, tons of useless dependencies.
If you need to be fancy and use ES Modules everywhere and your target Node.js version is at least v8.10+, then you can just use the
esm
loader passed to thenode
executable. In case you want Babel or TypeScript, you still and currently can do it: just pass the require hook tonode
binary when running the tests, and to therequire
hook ofnyc
(not to thenode
binary) when running test coverage.But it should be simple, small, fast and enough. Basic & TAP Spec coompliant repoter and let users choose whatever they want.
This time the main purpose was to totally minimize the usage of node built-in modules and whatnot, so to be compatible with the browser. And yes, it works there.
In bonus, just for the fun and profit, I decided to bundle it, so installation times are zero seconds. It was around 18kb as a whole and 6kb minified.
The good and the bad thing is that it not include assertion api - you can choose whatever you want, it works well with both the builtin
assert
and Jest'sexpect
. There are Pros and Cons about that, but for now we will go that way, at least until I create the small and awesomeazy
assertion library that will work well with every testing framework.In future there will be a CLI, of course. But it will be just for more advanced users and more bigger projects.