➜ 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
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
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
| 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
| import { sum } from "./dummy"; | |
| test("Dummy unit test", () => { | |
| const actual = sum(1, 2); | |
| expect(actual).toBe(3); | |
| }); |
➜ jest-with-typescript git:(main) ✗ npx jest
PASS source/dummy.test.ts
✓ Dummy unit test (1 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.526 s, estimated 2 s
Ran all test suites.
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
| module.exports = { | |
| // skipped other properties | |
| roots: [ | |
| '<rootDir>/source/' // pointing to tests directory | |
| ] | |
| }; |
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
| module.exports = { | |
| // skipped other properties | |
| modulePathIgnorePatterns: [ | |
| "<rootDir>/build/" | |
| ] | |
| }; |
PASS build/dummy.test.js
PASS source/dummy.test.ts
Test Suites: 2 passed, 2 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 2.009 s
Ran all test suites.
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 { fetch } from "./data"; | |
| it("returns name successfully", async () => { | |
| const actual = await fetch(); | |
| expect(actual.data.name).toBe("Turksat 5A"); | |
| }); |