#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 ...
#jest #node #javascript #testingJest Array/Object partial match with objectContaining and arrayContainingIt’s possible to do partial matches on Arrays and Objects in Jest using expect.objectContaining and expect.arrayContaining. expect has some powerful matcher methods to do things like the above partial matches. Using Jest at an advanced level means using tools like these to ...
#javascript #jest #node #testingJest explicitly or arbitrarily force fail() a testWhen testing code with Jest, it can sometimes be useful to fail a test arbitrarily. This post goes through a few scenarios where that might be useful and how to fail a Jest test explicitly/in a forced manner. It also presents more idiomatic Jest patterns that could be used interc ...
#node #javascript #pythonHow to integrate Python/Ruby/PHP/shell script with Node.js using child_process.spawn or child_process.execThere are occasions when running a Python/Ruby/PHP shell script from Node.js is necessary. This post looks at best practices around leveraging child_process.spawn and child_process.exec to encapsulate this call in Node.js/JavaScript. The goal here is to have an interoperability l ...
#javascript #jest #node #es6 #testingJest Full and Partial Mock/Spy of CommonJS and ES6 Module ImportsJavaScript import/require module testing do’s and don’ts with Jest The example repository is available at github.com/HugoDF/mock-spy-module-import. This post goes through how to achieve different types of module mocking scenarios with Jest. From simple Import interce ...