Skip to content

Commit

Permalink
Add typescript example
Browse files Browse the repository at this point in the history
  • Loading branch information
mattphillips committed Sep 28, 2022
1 parent 7dbdf04 commit 469d778
Show file tree
Hide file tree
Showing 7 changed files with 2,286 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Expect custom message example

## Installation

```
yarn
```

## Running test

```
yarn test
```
10 changes: 10 additions & 0 deletions examples/typescript/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[tj]s?(x)"],
testPathIgnorePatterns: ["/node_modules/"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
setupFilesAfterEnv: ["jest-chain"],
};
18 changes: 18 additions & 0 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "jest-chain-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"license": "MIT",
"dependencies": {},
"devDependencies": {
"@types/jest": "^29.0.0",
"jest": "^29.0.2",
"jest-chain": "*",
"ts-jest": "^28.0.8",
"typescript": "^4.8.2"
}
}
3 changes: 3 additions & 0 deletions examples/typescript/src/sum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const sum = (a: number, b: number): number => a + b;

export default sum;
7 changes: 7 additions & 0 deletions examples/typescript/test/sum.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sum from "../src/sum";

describe("Test math", () => {
test("Commutative Law of Addition", () => {
expect(sum(1, 2)).toBe(sum(2, 1)).toEqual(sum(2, 1));
});
});
18 changes: 18 additions & 0 deletions examples/typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"baseUrl": "./",
"esModuleInterop": true,
"strict": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noEmit": true
},

"files": ["node_modules/jest-chain/types/index.d.ts"],
"include": ["src/**/*", "test/**/*"],
"exclude": ["node_modules"]
}
2,216 changes: 2,216 additions & 0 deletions examples/typescript/yarn.lock

Large diffs are not rendered by default.

0 comments on commit 469d778

Please sign in to comment.