News for hackers. Stuff that matters.
Re:Modern Node.js Patterns by serguzest on Sunday August 03, 2025 @05:27PM (#44779984)
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.
Re:Modern Node.js Patterns by vinnymac on Sunday August 03, 2025 @05:41PM (#44780084)
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.

Re:Modern Node.js Patterns by serguzest on Sunday August 03, 2025 @08:14PM (#44780988)
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.
Re:Modern Node.js Patterns by tkzed49 on Sunday August 03, 2025 @05:34PM (#44780028)
assertions in node test feel very "technically correct but kind of ugly" compared to jest, but I'll use it anyway
Re:Modern Node.js Patterns by serguzest on Sunday August 03, 2025 @08:27PM (#44781057)
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)
                })
            );