top | item 44779984

(no title)

serguzest | 7 months ago

I love Node's built-in testing and how it integrates with VSCode's test runner. But I still miss Jest matchers. The Vitest team ported Jest matchers for their own use. I wish there were a similar compatibility between Jest matchers and Node testing as well.

discuss

order

vinnymac|7 months ago

Currently for very small projects I use the built in NodeJS test tooling.

But for larger and more complex projects, I tend to use Vitest these days. At 40MBs down, and most of the dependency weight falling to Vite (33MBs and something I likely already have installed directly), it's not too heavy of a dependency.

serguzest|7 months ago

It is based on vite and a bundler has no place in my backend. Vite is based on roll-up, roll-up uses some other things such as swc. I want to use typescript projects and npm workspaces which vite doesn't seem to care about.

tkzed49|7 months ago

assertions in node test feel very "technically correct but kind of ugly" compared to jest, but I'll use it anyway

serguzest|7 months ago

yes but consider this Jest code, replicating such in node testing is painful. testing code should be DSL-like, should be very easy to read.

            expect(bar).toEqual(
                expect.objectContaining({
                    symbol: `BTC`,
                    interval: `hour`,
                    timestamp: expect.any(Number),
                    o: expect.any(Number),
                    h: expect.any(Number),
                    l: expect.any(Number),
                    c: expect.any(Number),
                    v: expect.any(Number)
                })
            );