➜ jest-with-typescript git:(main) ✗ npx jest
FAIL source/dummy.test.ts
✕ Dummy unit test (3 ms)
...
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sum } from "./dummy"; | |
test("Dummy unit test", () => { | |
const actual = sum(1, 2); | |
expect(actual).toBe(3); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const sum = (a: number, b: number) => { | |
return a + b; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("Dummy unit test", () => { | |
const actual = null; // not implemented yet | |
expect(actual).toBe(1); | |
}); |
➜ jest-with-typescript git:(main) ✗ npx jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /Users/anthonyng/Repo/jest-with-typescript
2 files checked.
testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 0 matches
testPathIgnorePatterns: /node_modules/ - 2 matches
testRegex: - 0 matches
Pattern: - 0 matches
Redis is used to support the message queue. Run below command to run the offical Redis container
$ docker run --name my-redis-container -p 6379:6379 -d redis
(Optional) To access Redis, check this gist
Install @babel/cli, @babel/core, @babel/node, and @babel/preset-env
yarn add --dev @babel/cli @babel/core @babel/node @babel/preset-env
Create .babelrc
{