software
-

Again, we’ll be continuing the series on Jest testing today – it’s been a while since I’ve written a post here, so sorry about that! Today I’m going to try to explain mocks, which could be interesting(!) Mocks When you test things, you often want to provide a “fake” version of some functionality, rather than…
-

In part 3, the focus is on utilizing unit tests by employing spies to monitor function calls without requiring access to their internal workings. The example provided demonstrates how to verify that a function, setAriaHidden, correctly adds the “aria-hidden” attribute using Jest for testing and spying. Further discussions on mocks and stubs are planned.
-

The content discusses the fundamentals of unit testing, specifically the steps of Arrange, Act, and Assert. It provides a simple example using the `add` function and demonstrates how to write a corresponding test using Jest. The author plans to explore advanced features in future content. Comments and feedback are welcomed.
-

Unit testing is essential for ensuring expected behaviors in web applications. The article introduces Jest, a popular framework for JavaScript unit testing. It explains project setup with yarn and Jest, highlighting the choice of jsdom test environment. Babel setup is also detailed with necessary dependencies and configuration. Detailed steps are provided for thorough comprehension.
-

In my previous posts, I discussed creating a Markdown renderer with code highlighting and basic charts. Now, let’s talk about custom formatting of string interpolation using backticks in JavaScript. By creating a function, you can render Markdown-formatted strings using the MD`# Hello world` syntax. This approach offers endless possibilities for custom rendering.
-

So, in the second part of Make Your Mark(Down), we added charts/graphs and syntax highlighting to our Markdown control using Mermaid and highlight.js. We created a custom renderer for code to ensure expected behavior. By modifying the code, we achieved the desired formatting. The full snippet is available with additional details.
-

So, I made this cool tool based on another one I found online. It’s a simple text area with a Markdown preview. Just use Yarn to install marked and its types, and then create a component for the Markdown code. The code does the rest – easy peasy! Let me know if you have any…
-

So, in my last post, I promised to talk about async/await, and here we are. When your code has lots of nested blocks, it can get confusing. With async and await, you can wait for a result without using a bunch of .then statements. Just mark your function with async and use the await keyword.…
-

TLDR; JavaScript Promises are simpler than you think! They handle async code, with resolve and reject outcomes. You can chain them and handle errors easily. A finally block helps clean up resources. You can create custom promises, like an uploader for server requests. Next up, I might tackle async/await, or just cry into my coffee!
-
I have learned something, I have learned that JS (and conversely in some cases TS) is a bitch when it comes to scoping (and, conversely, why we had `self` throughout a code-base). So, basically, if a function definition is thus: the scoping means that `this` points to the function definition, so in order to reference…
