
Show HN: Baretest – A Minimalistic Alternative to Jest - tipiirai
https://volument.com/baretest
======
tmikaeld
This is actually something I've been looking for, to be able to test script
size constrained serverless scripts!

Does it work when minified, or does it need node?

(By the way, you should probably not require an account to be on your waiting
list)

~~~
volument
Great to hear! Can you shed some light on "script size constrained serverless
scripts"? Would possibly make a good FAQ entry.

And yes. Bareserver needs Node currently and is not designed for client-side
testing. It's trivial to add if needed.

Made it more clear that account is not needed and email is enough. Thanks!

~~~
tmikaeld
My use case is for Cloudflare Workers specifically, they have a max-size of
1MB per script and even while doing tests locally in node - the actual worker
behave differently, so the only way to really test units is by adding the
tests directly to the script. So you see the dilemma with that..

------
usually_wrong
> Jest is 57,540 lines of TypeScript

Jesus. Didn't know it is _that_ big.

~~~
lmiller1990
Considering the huge amount of features, and the LOC added for type
definitions etc (when compared to regular JS) it isn't that surprising.

~~~
volument
I wouldn't be surprised to see a test runner with the same features done in
1000–5000 lines.

------
lmiller1990
I'm not this is really an alternative, at least a direct alternative, to Jest.
Jest is much larger - but you get a LOT more functionality, so this isn't
really surprising. You don't just get a test runner, you can a fully fledged
testing environment.

I haven't found Jest to be a bottleneck at all, but all the other stuff
(transpiling TS, rendering a DOM for React component tests, etc...). Jest
supports all this out of the box, more or less, or with a few plugins -
baretest doesn't. I guess you have to configure external libraries (jsdom,
webpack, babel?) to do this with baretest. Now your tests are slow, like in
Jest! Turns out the test runner isn't the bottleneck, but all the other stuff
that happens before the actual execution.

Some real benchmarks would make this article much more convincing - and not
just with a basic "sum" function, but various examples (some simple node
tests, some API tests, some jsdom tests...)

I don't think baretest or minimalist libraries are bad, but I also don't think
anyone using Jest could really consider this an alternative, unless your use
case is very simple.

~~~
volument
Good points. Just want to point out that comparing with a basic "sum" function
measures the performance of the test runner and leaves out the time it takes
to run the application code. Baretest has little overhead so it is good for
testing the actively developed code with the `only` function.

With Baretest all the custom things you do like transpiling TS or rendering
React is done outside the test runner. This way it can test cases of any
complexity.

~~~
lmiller1990
In that case, will this really cut down on time to see the test result? Won't
I have to trigger my TS/React build, then run the test (two separate actions,
difficult to automate this).

Again, I like simple... but it seems like to move from Jest to baretest I'd be
giving up a lot, in terms of both features and time from saving my file to
seeing the test result.

------
k__
Seems more like an alternative for Tape to me.

~~~
volument
True. However, according to "The State of JavaScript" [1] Jest is the most
popular option these days and it is chosen because it is simple, lightweight,
fast, and easy [2] — all of which are the reasons one would choose Baretest.

[1]:
[https://2019.stateofjs.com/testing/](https://2019.stateofjs.com/testing/)

[2]:
[https://2018.stateofjs.com/testing/jest/](https://2018.stateofjs.com/testing/jest/)

