Posts

Using Ava with Testdouble

Example of a Simple Test Case

Ava is a unique testing framework in that it is one of the few testing frameworks out there that recognizes observable resolution. It also makes asynchronous testing the default option when you write tests ensuring better performance. Another nice feature of Ava is that it has a nicer assertion output display.

Testdouble is an assertion library which specializes in create 'doubles'. Testdouble is different from Sinon because Testdouble will replace the function outright for which it is substituting when mocking out a function or object. It also makes it easier to track using a 'sandbox' API to alleviate the user from having to restore an original replaced function.

Categories: #JavaScript #testing
Tags: #NodeJs
JavaScript - Querying Objects

Data Querying

As JSON/JavaScript objects are heavily relied upon means of accessing data, it is crucial to quickly retrieve certain pieces of information within the object quickly. For simple objects, a couple of loops will suffice in honing in to the exact detail, but most likely, the general object will be more complex.

Categories: #JavaScript
Zola - Include Template

Common Template

Common content that belongs on multiple pages should be situated in a template which should be shared globally. An example of would be a footer, the bottom of the page content that persists across pages. Looking at Tera, the template engine for Zola, the include feature within a template offers the capability to reference other templates.

Categories: #cms
Visual Studio Code Extensions - Quick Picks #6

Markdown Table Formatter

A markdown table's formatting often tends to go awry when there is a need to change the words in the headers which affects the width of columns. It is a laborious process to have to realign all the column content that fall underneath the changed header.

To solve this issue, use the Markdown Table Formatter extension to format markdown tables. This extension will format the 'basic markdown tables' such as the following:

| Food Item  | Items Bought |
|------------|--------------|
| Pineapples | 4            |
| Tomatoes   | 3            |

However, it does not work with Pandoc's grid table markdown output.

Categories: #editor
Vite - Quick Tips #1

More Log Information when Vite Server Runs

Using the -d option with the Vite command in the npm script to have more verbose output for debugging.

// ...
    "scripts": {
        "dev": "vite -d",
        "build": "vite build",
        "preview": "vite preview"
    }
// ...
Categories: #Tooling #javascript
Tags: #frontend