What's New on Node.js Test Runner and Why it's Game-changing

Rate this content
Bookmark

Node's new test runner is pretty cool but not many people are using it yet. In my talk, I'll show you all the neat stuff it can do, including some features I worked on. We'll take a look under the hood of Node to see how mocks work and how to use them. I'll also chat about what's next for the runner and what to expect down the line. Get ready to up your testing game with native assertions and keep things running fast!

Lucas Santos
Lucas Santos
17 min
04 Apr, 2024

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The Node.js Test Runner is presented as a better alternative to Jest, offering more flexibility and improved performance. It supports TypeScript out of the box and provides comprehensive test suite visualization. The test runner has native support for code coverage and upcoming features include module mocking and improved filtering. Shifting to the test runner is simple and helps the community grow.

1. Introduction to Node.js Test Runner

Short description:

Hello, everybody. Today, we're going to talk about the Node.js Test Runner. I'm Luca Santos, a senior software engineer at OpenVault. You can reach out to me on Twitter and Instagram at elsantos.dev.

Hello, everybody. Today, we're going to talk about the Node.js Test Runner. So first of all, I'm going to introduce myself. My name is Luca Santos. I am one of the senior software engineers there at OpenVault today. I live in Sweden. I'm originally from Brazil. And you can reach out to me on any of my social networks. So basically, there's the ones in the bottom there. It's Twitter.elsantos.dev, Instagram.elsantos.dev. You know, you get the idea. Luca is a very common name in Brazil. So basically, I had to, you know, choose DNS over Nix in social networks. So just put the social network name followed by .elsantos.dev. Or if you are in doubt on any social networks that you want to talk to me, just .elsantos.dev is going to take you to my main page where everything is. Okay? I'm super open to talk about anything. So just reach out to me, and it's going to be super nice.

2. The Benefits of the Node.js Test Runner

Short description:

My goal with this talk is to make you ditch Jest for something better, the Node.js test runner. Jest is outdated and has limitations. The Node.js test runner is actively improved and offers more flexibility. The current test runners are difficult to configure, especially for TypeScript, and often require additional libraries that can slow down your project. They also lack interoperability and can be inflexible.

Next up, I'm going to share my goal in this talk for you. Like, what is the goal that I have with this talk? It's to make you ditch Jest in the end. That is simple as that. I don't hate Jest. I actually use it a lot. But I had my fair share of problems. And I think it's time to move on, right? I think it's time that we need something new, something better. Jest is super old, right? It's very good, but the time has passed, right?

So I'm going to do this. I'm going to present you something that is possibly better. But why possibly better? Well, because the Node.js test runner is still being actively improved. So there's a bunch of things that are happening. There are a bunch of things that we already have, but there's still a bunch of things missing. So you can help there if you want, okay?

But first, what is bad about the current environment? Why do we need another test runner? Isn't today enough? Isn't what we have today enough? So basically, the first thing is that they're too difficult to configure, especially for TypeScript. And they do a lot of things. Like configuring Jest is a pain. It's a super big configuration file. They do a lot of stuff. They do transforming, they do parsing, they do moving, they assert, they have coverage. It's just too many stuff. And this makes them slow, right? Because, well, it's a lot of stuff. And then you have a concept that they call yall, which is basically yet another library on top of your project. Because runners, in my opinion, should be a thing from your runtime. You shouldn't be able to install, you shouldn't install another library to have a runner. And remember, every other library, every package that install on top of your project is a code that you don't maintain, but yet you rely on it, right? So if something happens, you're gonna pay the price. And test runners, they seem to not want to interoperate with each other. They make sure that you will only be able to use them and nothing else. So it's very difficult to change from one to the other. They're completely different stuff. Most of them are pretty opinionated. So they are either super extensible or not extensible at all.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

How Bun Makes Building React Apps Simpler & Faster
React Day Berlin 2022React Day Berlin 2022
9 min
How Bun Makes Building React Apps Simpler & Faster
Bun’s builtin JSX transpiler, hot reloads on the server, JSX prop punning, macro api, automatic package installs, console.log JSX support, 4x faster serverside rendering and more make Bun the best runtime for building React apps
Node.js Compatibility in Deno
Node Congress 2022Node Congress 2022
34 min
Node.js Compatibility in Deno
Can Deno run apps and libraries authored for Node.js? What are the tradeoffs? How does it work? What’s next?
Bun, Deno, Node.js? Recreating a JavaScript runtime from Scratch - Understand magic behind Node.js
Node Congress 2023Node Congress 2023
29 min
Bun, Deno, Node.js? Recreating a JavaScript runtime from Scratch - Understand magic behind Node.js
Bun, Deno, and many other JavaScript runtimes have been hyped, but do you know why? Is it that easy to make a runtime from scratch?

I've been researching the secret behind Node.js' power and why there are so many new JavaScript runtimes coming up. Breaking down each key component used on Node.js I've come to interesting conclusions that many people used to say whereas in practice it works a bit differently.

In this talk, attendees will learn the concepts used to create a new JavaScript runtime. They're going to go through an example of how to make a JavaScript runtime by following what's behind the scenes on the Node.js project using C++. They'll learn the relationship between Chrome's V8 and Libuv and what makes one JavaScript runtime better than others.

This talk will cover the following topics:
- What's a JavaScript Engine - V8
- Why Node.js uses Libuv
- How to create a JS Runtime from scratch
Eval all the strings! - Hardened JavaScript
Node Congress 2023Node Congress 2023
8 min
Eval all the strings! - Hardened JavaScript
This talk is about SecureEcmaScript and Compartments which are TC39 proposals, and I'm working on tooling to make these concepts usable with people championing those proposals.
This is a first-hand account of the future of JavaScript security.
SES + tooling (LavaMoat or Endo) is making limiting access to network, fs, core modules or globals possible on a per-package basis.
I want to show how they work, what possibilities they open and how to make that future happen today with some effort.
To me this is the final step in securing npm supply chain - even if a package gets taken over by bad actors, it won't be able to hurt me.
The Future of JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
The Future of JavaScript Runtimes
JavaScript was born in the browser, Node brought it to the server embracing unix primitives and async I/O and lately Cloudflare Workers & Deno Deploy have brought it to the edge. Let’s take a look at where JavaScript runtimes are heading and how it will shape the software we write.
Roll you own JavaScript runtime
Node Congress 2023Node Congress 2023
21 min
Roll you own JavaScript runtime
In this talk, we’ll create a small JavaScript runtime from scratch in Rust. We’ll leverage the same ecosystem of components that Deno uses to show that rolling a bespoke runtime fitting your needs is simple and fun in 2023

Workshops on related topic

Build Peer-to-Peer Applications with Pear Runtime
JSNation 2024JSNation 2024
152 min
Build Peer-to-Peer Applications with Pear Runtime
WorkshopFree
David Mark Clements
David Mark Clements
Learn how to rapidly build peer-to-peer applications with Pear Runtime. No servers required. Understand peer-to-peer paradigms and construct applications from well-defined building blocks. This workshop will cover how to create both Desktop and Terminal applications (with discussion for Mobile) that work entirely peer-to-peer from anywhere in the world. By the end of this workshop you should know how to build a new type of highly scalable application with entirely reduced infrastructural costs (~0) along with suitable architectures and best practices for peer-to-peer applications. From the creator of Pear Runtime and the company that brings us keet.io. Table of content:- Introducing Pear- Initial Q & A- Getting Setup- Creating a Pear Desktop Application- Sharing a Pear Application- Running a Pear Application- Creating a Pear Terminal Application- Releasing a Pear Application- Architectural Discussions- Wrap-up Q & A