Using TypeScript with Jest
Learn how to test TypeScript source code and write test code in TypeScript in this lesson.
We'll cover the following...
Installing and configuring TypeScript
The starter project for this lesson contains source code and tests written in TypeScript in the src
folder. We’ll recognize the validEmailDomain
function from previous lessons.
TypeScript can be installed by running the following in a terminal:
npm install --save-dev typescript
TypeScript is configured by a file called tsconfig.json
. Create this file in the root of the project with the following content:
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"esModuleInterop": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
...