Hacker News new | ask | show | jobs
by intellix 1868 days ago
How is the built in testing? I'm a bit wary because Jest is so good and wonder if it can compete on every front it's baking in.

It reminds me of Angular coming with it's own Router, Forms, Animations and then since they're provided officially, alternatives don't get created and then the half of the team leaves and the packages are abandoned.

2 comments

> How is the built in testing?

Much more minimalist than Jest. Very similar to Node's built-in testing [0].

- I don't believe the test environment is recreated between test files

- No way to mock imported modules, as far as I understand. I don't believe the built-in testing has any mocking or spying functionality at all

- No describe/it/expect syntax that Jest inherited from Jasmine (I am not sure where it came from initially — was it from RSpec?)

- The above means that there is no nesting of test blocks

- No setup or teardown functions (beforeAll, beforeEach, afterAll or afterEach)

On the other hand, it's fast. And it doesn't swallow up console logs, like Jest can do. No magic to it at all.

[0] - https://nodejs.org/dist/latest-v14.x/docs/api/assert.html

There are third party modules for providing many of those things. I created 2 modules for testing.

This module has describe/it functions with setup/teardown hooks. It supports nesting test blocks. I think the built in assertion functions are quite good so I didn't bother creating an expect function although there are other third party modules that provide that functionality.

https://deno.land/x/test_suite

I had difficulty getting sinon to work earlier on so I wrote a similar module in TypeScript for creating spys, stubs, and faking time.

https://deno.land/x/mock

I know a fella working on a Deno port of Ava (https://github.com/avajs/ava). When that and Koa are ported or compatible, I'll be giving Deno a legitimate go.
FYI https://github.com/oakserver/oak is a port of Koa for Deno.
Deno test has been fine. oak exists for koa like middleware oriented servers