#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 ...
#alpinejs #javascriptTips for real-world Alpine.jsAlpine Day 2021 Talk: tackling Alpine FAQs, common issues & web patterns with Alpine.js ...
#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 ...
#cypress #testing #javascriptCypress Scroll Position AssertionsThis post goes through approaches to asserting on the scroll position. First we’ll see how to assert that we’re at the top of the page. Next we’ll look at 2 approaches to assert that we’ve scrolled to an element. The examples for this post are available at ...
#javascript #typescriptWhat is the "?." JavaScript/TypeScript operatorIn JavaScript and TypeScript, the “?.” operator is called optional chaining. It works in a similar fashion to the . (chaining) operator, except that it short-circuits instead of causing an error when a value is null or undefined. That means const obj = {}; console.log ...
#html #javascriptDisable a HTML <a> link/anchor tagHere are 2 ways to disable a HTML <a> link/anchor element using CSS or by using inline JavaScript. ...
#alpinejs #javascriptAn accessible Alpine.js menu toggleThe “Hello World” of JavaScript frameworks and libraries seems to have become the todo app. In the case of Alpine.js a todo app is almost too large to showcase Alpine’s core benefits and use case. Another issue with a lot of JavaScript examples is that they fore ...
#alpinejs #javascriptAlpine.js in-depth: listen to JavaScript events using x-onThe core Alpine.js functionality beyond toggling visibility, displaying data in HTML textContent and binding HTML attributes to data is listening for events using Alpine.js. Listening to events with x-on is usually coupled with state updates, for example we can create the followi ...
#alpinejs #javascriptAlpine.js in-depth: reactive HTML attribute binding with x-bindWe’ve seen how to print out values using x-text and toggle visibility of elements based on them with x-show. We’ll now see how to set the value of HTML attributes using x-bind. In this example we’ll display and image based on data that’s in our Alpine.js i ...
#alpinejs #javascriptShow/hide in Alpine.js with x-showIn Alpine.js the directive used to toggle visibility of an element is x-show. Per the Alpine.js README, “x-show toggles the display: none; style on the element depending if the expression resolves to true or false”. ...