JavaScript language tests

2 min read
A lesser-known resource for exploring JavaScript APIs.
Photo of a green field filled with yellow flowers around sunset.

Photo taken in the outskirts of Berlin.

When picking up the API for a new tool, it's always been the fastest for me to look at examples as a starting point before jumping into the detailed docs. I think this is widely acknowledged as the best learning path; most documentation sites begin with a "quick start" guide before sending you into pages and pages of detailed references.

Quick starts are great because they provide a light mental model of how the thing works in seconds instead of minutes. It's a 'show, don't tell' approach to teaching. Plus, you're often able to paste the quick start sample into your own code and immediately get the feeling of progress. This is a really important aspect of teaching.

Anyway, how does all of this relate to the title of the post? Well, I basically stumbled upon a collection of examples for every JavaScript API – the test suites:

https://github.com/tc39/test262/blob/main/test

I came upon this while learning about how new JavaScript features land. New language APIs are evaluated in a multi-stage proposal process carried out by the TC39 group. The proposal will have one or more "champions" leading it and pushing it forward. As the proposal matures and advances to later stages, an extensive test suite must be submitted and reviewed.

You may have heard about the new Error.isError API. But how does it work? We have some examples in the MDN docs, but the test suite has even more. Have you maybe wondered how it might interact with Error constructors?

Well, probably not. But there you go :)

Discuss on Bluesky