#node:test #node #testing #javascriptNode.js Native Test RunnerIf 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 ...
#javascript #react #nodeWhy 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 ...
#javascript #jsdoc #typescript #nodeHow to get type-checking and generate TypeScript Typing declaration (types.d.ts) from JSDoc annotationsHow 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 ...
#ava #Testing #node #javascriptAVA: pass or fail a test if an environment variable is missing/emptyIn 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 ...
#node #javascript #typescriptUse microbundle for a TypeScript npm moduleFor 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 ...
#eleventy #alpinejs #javascript #nodeHow to migrate a bunch of HTML pages (Alpine.js Playground) to EleventyAlpine.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. ...
#javascript #nodeAdvantages and Disadvantages of Node.jsJavaScript 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 ...
#javascript #node #testing #deploymentManaging Your Videos With HTML and JavaScriptThis 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 ...
#jest #testing #javascript #nodeJest set, clear and reset mock/spy/stub implementationBetween 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 ...
#jest #testing #javascript #nodeJest .fn() and .spyOn() spy/stub/mock assertion referenceWhere 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 ...