How to test ts files with jest

see the instructions on jest"s official website to download ts-jest, but I don"t know how to use it, and no clear tutorials have been found. Please help me

Feb.28,2021

first step to install the package:

yarn add -D typescript jest ts-jest @types/jest

step 2: initialize project-related configuration files:
generate tsconfig.json:

tsc --init

create jest.config.js:

module.exports = {
  transform: {
    '^.+\\.tsx?$': 'ts-jest',
  },
  testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}

directory structure:

clipboard.png

base.spec.ts:


:

clipboard.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b22487-2b5fa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b22487-2b5fa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?