Fixing it.only type error in Jest

If you are getting a type error with it.only in Jest, it could be due to incorrect TypeScript typings or incompatible versions of Jest and TypeScript.

To resolve this issue, you can try the following steps:

Make sure you have the latest versions of Jest and its TypeScript typings installed in your project.

npm install --save-dev jest @types/jest
Verify that your tsconfig.json file includes the necessary TypeScript configuration for Jest. It should have the following settings:
{
  "compilerOptions": {
    "types": ["jest"]
  }
}

Ensure that your test file has the correct import statement for it.only:

import { it } from '@jest/globals';

This import is necessary when using TypeScript with Jest to avoid type errors.

If the issue persists, please provide more details about the specific error message you are receiving so that I can assist you further.

Front-End
TypeScript: type aliases to check type equality

This post is to analyse how the type equality check by using type aliases proposed by Matt Pocock in his twitter post. These type aliases allow us to elegantly express type equality checks in unit tests. All we need to do is to pass the output and expected types in …

Front-End
yup conditional validation example

Here’s an example of a Yup validation logic where the first input field is optional but, if filled, it must contain only alphabetic characters, and the second input field is required: import * as Yup from “yup”; const validationSchema = Yup.object().shape({ firstField: Yup.string().matches(/^[A-Za-z]*$/, { message: “First field must contain only …

Front-End
How to set up auto-fix on save by using the project’s Eslint config with VS Code

This is a quick instruction to set up auto-fix on save by using the project’s eslint config with VS Code. It works for both TS and JS. 1. Install ESLint plugin for VS Code. 2. Add config to VS code Go to Code -> Preference -> Settings (or press cmd …