---
title: "Simple tests for dark scenarios"
publication: "Node Weekly"
issue: 494
published_at: "2023-07-11"
canonical_url: "https://nodeweekly.com/issues/494"
---

Plus Node adds mock timers, Spotify gives us a TypeScript SDK, and the state of the npm registry in 2023. |        

#​494 — July 11, 2023 

[Read on the Web](https://nodeweekly.com/issues/494)  

Together with [![Memetria\](https://res.cloudinary.com/cpress/image/upload/c_fill,g_auto,w_600,h_145/e_make_transparent/co_white,e_outline:7/vvpdctzacmq3xehpvwps.png)](https://dashboard.memetria.com/nodeweekly) 

![Node.js Weekly](https://res.cloudinary.com/cpress/image/upload/v1653576619/lgfqinzbdqttwmhvljxb.png) 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60,q_auto/mgs62nkbz2g3ms218iar.jpg)](https://nodejs.org/en/blog/release/v20.4.0)  

[Node v20.4.0 Introduces Mock Timers](https://nodejs.org/en/blog/release/v20.4.0) — The latest release of Node includes a new [`MockTimers` API](https://github.com/nodejs/node/pull/47775) that can make any tests involving time-dependent functionality more reliable and deterministic by mocking `setTimeout`, `setInterval`, `[node:timers](https://nodejs.org/api/timers.html)`, and more. 

Rafael Gonzaga   

[Testing the _Dark Scenarios_ of Your Node App](https://practica.dev/blog/testing-the-dark-scenarios-of-your-nodejs-application/) — An interesting look at some examples of easily overlooked but nonetheless important tests to have in your app or package. What happens when a service times out, code is mutating things it shouldn’t, or you have zombie processes milling around? These are some of the ‘dark scenarios’ you can easily be prepared for. 

Yoni Goldberg and Raz Luvaton   [![\](https://copm.s3.amazonaws.com/5fcdd124.png)](https://dashboard.memetria.com/nodeweekly) 

[Memetria: Secure, Scalable Redis 7 Hosting](https://dashboard.memetria.com/nodeweekly) — High performance Redis hosting with large key tracking, detailed metrics, and a superior uptime record. 

Memetria sponsor    

[Getting Started with Vector Databases in Node](https://thecodebarbarian.com/getting-started-with-vector-databases-in-node-js.html) — Storing and manipulating vectors has become a popular topic recently because of the advent of large language models, such as those used by systems like ChatGPT. “Embeddings” are vectors that can represent semantic concepts and be stored and compared against each other. Valeri quickly shows us how to create a basic topic classification tool using Node and the [Chroma](https://www.trychroma.com/) vector database. 

Valeri Karpov   

[TypeScript and ECMAScript Modules in Node.js](https://www.typescriptlang.org/docs/handbook/esm-node.html) — An official docs page focusing on the use of ESM with Node.js in TypeScript projects. We’ve linked to this before, but it’s a handy document that continues to be updated. 

Microsoft   

_ASIDES:_ 

- The folks at Sandworm have shared [a look at the state of the npm registry](https://blog.sandworm.dev/state-of-npm-2023-the-overview) including lots of trivia, a little history, and stats on how many packages there are, how big the packages are, and the most commonly used package keywords.
- [Deno 1.35](https://deno.com/blog/v1.35) has been released with [yet more Node and npm compatibility improvements](https://deno.com/blog/v1.35#improvements-to-npm-and-node-compatibility). Node packages including Astro, Axios, Discord.js, Parcel, Redis and the AWS SDK are now confirmed to work with the alternative JS runtime.   

[Multithreading with Worker Threads in Node](https://blog.appsignal.com/2023/07/05/multithreading-with-worker-threads-in-nodejs.html) — A basic introduction to the idea of working with multiple threads. 

Camilo Reyes   

[Using Insecure `npm` Defaults to Steal macOS Keyboard Shortcuts](https://snyk.io/blog/using-insecure-npm-package-manager-defaults/) — Don’t try this at home, folks. 
Yagiz Nizipli   

🛠 Code & Tools 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60,q_auto/mfcw8bmtrkf5hhogydtf.jpg)](https://github.com/junhoyeo/threads-api)  

[threads-api: Unofficial Client API for Meta's _Threads_](https://github.com/junhoyeo/threads-api) — A way to use [Meta’s Twitter-a-like](https://about.fb.com/news/2023/07/introducing-threads-new-app-text-sharing/) from Node? This seems like the sort of thing that won’t work in a month or two, but who knows.. many Instagram libraries have done very well despite a lack of official support. 

Junho Yeo   

🎵 [Spotify Unveils a TypeScript SDK for its Web API](https://developer.spotify.com/blog/2023-07-03-typescript-sdk) — Now this _is_ officially supported. The popular music streaming service has long had a Web API for getting information about songs, managing playlists, controlling playback, etc. and now there’s an officially supported TypeScript SDK for it. This post includes some handy examples. 

Jo Franchetti (Spotify)   

[Late to the AI Bandwagon? Transition to Top AI/ML Roles with Interview Kickstart](https://learn.interviewkickstart.com/course/machine-learning-course?utm_source=cooperpress&utm_campaign=cooperpress_mlswitchup) — Join FREE webinar to learn more. Train with FAANG+ AI/ML engineers. Capstone project for hands-on experience. Up to 15 mock interviews. 

Interview Kickstart sponsor   

[Hakk: An Auto Updating In-Context Node REPL](https://github.com/arthuredelstein/hakk) — You’re already familiar with Node’s REPL, but this goes a step further by hot reloading your app’s code (that you’re working on in your usual editor) and maintaining a REPL for tinkering within the app’s context at the same time. 

Arthur Edelstein   

[Tinypool 0.7: An Even Smaller Node.js Worker Pool Library](https://github.com/tinylibs/tinypool) — A fork of the powerful [Piscina](https://github.com/piscinajs/piscina) that aims for fewer depdencies and a smaller footprint overall. 

Tinylibs        

📰 Classifieds   

💻 Hired makes job hunting easy-instead of chasing recruiters, companies approach you with salary details up front. [Create a free profile now](https://hired.com/join/?utm_source=newsletter&utm_medium=sponsor&utm_campaign=%28b2c%29%28l-all%29%28r-all%29%28cooper-nodeweekly%29&utm_content=find-your-next-job). 

--- 

☑️ _SurveyJS_ is a dual open source/commercial form and survey management system that lets you create dynamic surveys using JSON or a form builder. You can try [a demo of the SurveyJS form builder here.](https://surveyjs.io/create-free-survey) 

--- 

📧 Did you know we have [a Postgres newsletter too?](https://postgresweekly.com/) We cover everything from SQL through to the latest in vector storage, GIS, hosted platforms, and Postgres extensions.     

_Classifieds_ are a new way to share projects or services you may find useful, with a mix of free and paid options. 

More details to follow.       

- [Article Extractor 7.3](https://github.com/extractus/article-extractor)
 ↳ Fetches a URL, extracts the main content. [Now supports](https://github.com/extractus/article-extractor/releases/tag/v7.3.0) `AbortSignal`.
- [Expresso TS 1.5](https://github.com/expressots/expressots)
 ↳ Lightweight server-side app framework.
- [Zip It and Ship It 9.13](https://github.com/netlify/zip-it-and-ship-it)
 ↳ Package Node Lambda functions for deployment.
- [pnpm 8.6.7](https://github.com/pnpm/pnpm/releases/tag/v8.6.7) – Alternative package manager.
- [fnm 1.35.0](https://github.com/Schniz/fnm)
 ↳ Fast Node.js version manager.
- [Official MongoDB Node.js Driver 5.7](https://github.com/mongodb/node-mongodb-native/releases/tag/v5.7.0)
- [Official ArangoDB JS Driver 8.4](https://github.com/arangodb/arangojs/releases/tag/v8.4.0)
- [Fastify 4.19.2](https://github.com/fastify/fastify/releases/tag/v4.19.2)    

**Got a link for us?** Reply and tell us. We can't include everything but we'll look at anything you send. _Thanks!_ 

--- 

**Sponsorship:** Email `[kristina@cooperpress.com](mailto:kristina@cooperpress.com)` for details. 

--- 

Published by Cooper Press Ltd.
Fairfield Enterprise Centre, Louth, LN11 0LS, United Kingdom 

[Cancel your subscription](https://nodeweekly.com/leave/*|UID|*) or [change your address](https://nodeweekly.com/edit_subscription/*|UID|*).
