Skip to content

Commit 8ec672a

Browse files
committed
Update
1 parent 8a1c992 commit 8ec672a

File tree

5 files changed

+62
-21
lines changed

5 files changed

+62
-21
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.coverage
2-
.jest_cache
2+
.jest
33
build
44
node_modules

jest.config.ts

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,61 @@
1-
export default {
2-
roots: [
3-
'<rootDir>/test'
4-
],
5-
testMatch: [
6-
'**/?(*.)+(spec|test).+(ts|tsx)'
7-
],
8-
transform: {
9-
'^.+\\.(ts|tsx)$': 'ts-jest'
10-
},
1+
/**
2+
* @see https://jestjs.io/docs/configuration
3+
*/
4+
const config = {
5+
// The directory where Jest should store its cached dependency information.
6+
cacheDirectory: '.jest',
7+
8+
/**
9+
* Automatically clears all information stored in the mockFn.mock.calls, mockFn.mock.instances and mockFn.mock.results arrays before every test.
10+
* Often this is useful when you want to clean up a mocks usage data between two assertions.
11+
* Beware that this will replace mockFn.mock, not just these three properties!
12+
* You should, therefore, avoid assigning mockFn.mock to other variables, temporary or not, to make sure you don't access stale data.
13+
*
14+
* @see https://jestjs.io/docs/configuration#clearmocks-boolean
15+
* @see https://jestjs.io/docs/jest-object#jestclearallmocks
16+
* @see https://jestjs.io/docs/mock-function-api#mockfnmockclear
17+
*/
18+
clearMocks: true,
19+
20+
// Indicates whether the coverage information should be collected while executing the test
1121
collectCoverage: true,
22+
23+
// The directory where Jest should output its coverage files
1224
coverageDirectory: '.coverage',
13-
coverageProvider: 'v8',
14-
coveragePathIgnorePatterns: ['/node_modules/'],
25+
26+
// A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter can be used.
1527
coverageReporters: ['text', 'lcov'],
16-
cacheDirectory: '.jest_cache'
17-
}
28+
29+
/**
30+
* This will be used to configure minimum threshold enforcement for coverage results.
31+
* Thresholds can be specified as global, as a glob, and as a directory or file path.
32+
* If thresholds aren't met, jest will fail.
33+
* Thresholds specified as a positive number are taken to be the minimum percentage required.
34+
* Thresholds specified as a negative number represent the maximum number of uncovered entities allowed.
35+
*/
36+
coverageThreshold: {
37+
global: {
38+
branches: 80,
39+
functions: 80,
40+
lines: 80,
41+
statements: -10,
42+
},
43+
},
44+
45+
moduleNameMapper: {
46+
'src/(.*)': '<rootDir>/src/$1',
47+
},
48+
49+
// A preset that is used as a base for Jest's configuration.
50+
preset: 'ts-jest',
51+
52+
// A list of paths to directories that Jest should use to search for files in.
53+
roots: ['<rootDir>/test'],
54+
55+
// The glob patterns Jest uses to detect test files.
56+
testMatch: ['**/?(*.)+(test).+(ts|tsx)'],
57+
58+
verbose: true,
59+
};
60+
61+
export default config;

src/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/sum.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sum from '../src/sum';
1+
import sum from 'src/sum';
22

33
test('basic', () => {
44
const a = 3;

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// "outDir": "build", /* Specify an output folder for all emitted files. */
21
{
32
"compilerOptions": {
43
"baseUrl": "./",
@@ -11,7 +10,8 @@
1110
"skipLibCheck": true,
1211
"strict": false,
1312
"forceConsistentCasingInFileNames": true,
14-
"noEmit": true,
13+
"outDir": "build",
14+
"noEmit": false,
1515
"esModuleInterop": true,
1616
"module": "esnext",
1717
"moduleResolution": "node",

0 commit comments

Comments
 (0)