Hacker News new | ask | show | jobs
by azangru 1865 days ago
> 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

1 comments

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