• Home
  • Books
  • Jest
  • Alpine.js
  • JavaScript
  • Node
  • More...
  • Search
  • About
  • Gear & Setup

Node.js

A collection of 49 posts

#node #testing #javascript

Node.js Native Test Runner

If anyone missed it, Node.js 18 includes a test runner/test definition module (node --test and node:test respectively). node:test exports a test function and you can run the Node CLI with a --test flag which does some basic search/matching for test files. Full Documentation: node ...

  • Hugo Di Francesco
    Author
3 min read
#javascript #react #node

Why doesn't React.useEffect run on React server-side renders (SSR)?

Why doesn’t React.useEffect run during a server-side render (SSR) for example when using it inside a Next.js application? The obvious spots in the docs for information like this are the React docs on useEffect and the React docs on string/static rendering neither of which m ...

  • Hugo Di Francesco
    Author
3 min read
#javascript #jsdoc #typescript #node

How to get type-checking and generate TypeScript Typing declaration (types.d.ts) from JSDoc annotations

How to achieve TypeScript-like behaviour in Vanilla JavaScript using JSDoc and @ts-check in VSCode: that’s the purpose of this post. TypeScript is a JavaScript superset with types. It solves one of the big problems with JavaScript, which is “what parameters does this ...

  • Hugo Di Francesco
    Author
5 min read
#ava #Testing #node #javascript

AVA: pass or fail a test if an environment variable is missing/empty

In a recent project I needed to fail/pass some AVA if a runtime environment variable was unset or empty. Here’s how I solved this issue. AVA is a test runner for Node.js with a concise API, detailed error output, embrace of new language features and process isolation that l ...

  • Hugo Di Francesco
    Author
3 min read
#node #javascript #typescript

Use microbundle for a TypeScript npm module

For those looking to write a package and publish it to npm, TypeScript + microbundle is a low-friction way to build a high-quality library. I’ve created a GitHub repository template with microbundle, TypeScript, ava and xo. You can find it at github.com/HugoDF/microbundle-t ...

  • Hugo Di Francesco
    Author
4 min read
#eleventy #alpinejs #javascript #node

How to migrate a bunch of HTML pages (Alpine.js Playground) to Eleventy

Alpine.js Playground was recently migrated from custom build scripts & HTML pages to leverage Eleventy. For context, Alpine.js Playground’s custom build scripts + HTML files had the following pros and cons. Pros: simple very simple, everything is in the scripts folder. ...

  • Hugo Di Francesco
    Author
9 min read
#javascript #node

Advantages and Disadvantages of Node.js

JavaScript is perhaps the most highly regarded of the different programming languages out there, and in terms of client-side programming languages, there are few tools that are peers to JavaScript. In terms of web development, it is clear that JavaScript has a very important role ...

  • Hugo Di Francesco
    Author
5 min read
#javascript #node #testing #deployment

Managing Your Videos With HTML and JavaScript

This article explains how to manage video content with HTML and JavaScript. Video content has become a significant part of Internet use, and it plays a large role in user experience. The ability to effectively include video content in your sites can help you improve user experien ...

  • Gilad David Maayan
    Author
6 min read
#jest #testing #javascript #node

Jest set, clear and reset mock/spy/stub implementation

Between test runs we need mocked/spied on imports and functions to be reset so that assertions don’t fail due to stale calls (from a previous test). This is a way to mitigate what little statefulness is in the system. In unit tests of complex systems, it’s not always ...

  • Hugo Di Francesco
    Author
7 min read
#jest #testing #javascript #node

Jest .fn() and .spyOn() spy/stub/mock assertion reference

Where other JavaScript testing libraries would lean on a specific stub/spy library like Sinon - Standalone test spies, stubs and mocks for JavaScript. Works with any unit testing framework., Jest comes with stubs, mocks and spies out of the box. This post looks at how to instanti ...

  • Hugo Di Francesco
    Author
6 min read
Page 1 of 5  Previous Posts →

Get The Jest Handbook (100 pages)

Take your JavaScript testing to the next level by learning the ins and outs of Jest, the top JavaScript testing library.

Find out more close
Code with Hugo
Latest Posts Twitter Github Medium