Skip to content

Commit e0bf57a

Browse files
committed
Remove mocha in favor of jest
1 parent 0c8186d commit e0bf57a

22 files changed

+16039
-11211
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ lt.log
66
.nyc_output
77
coverage
88
.eslintcache
9+
.cache
910

1011
#docs
1112
/docs/index.html

jest.config.ts

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import * as path from 'path';
2+
import type { Config } from '@jest/types';
3+
4+
const isCI = process.env.CI === 'true';
5+
6+
const config: Config.InitialOptions = {
7+
displayName: 'pushin',
8+
rootDir: path.resolve('.'),
9+
preset: 'ts-jest',
10+
11+
/**
12+
* A set of global variables that need to be available in all test environments.
13+
*/
14+
globals: {
15+
'ts-jest': {
16+
allowSyntheticDefaultImports: true,
17+
tsconfig: '<rootDir>/tsconfig.spec.json',
18+
},
19+
},
20+
21+
transform: {
22+
'^.+\\.spec.ts$': 'ts-jest',
23+
},
24+
25+
/**
26+
* By default, Jest runs all tests and produces all errors into the console upon completion.
27+
* The bail config option can be used here to have Jest stop running tests after n failures.
28+
* Setting bail to true is the same as setting bail to 1
29+
*/
30+
bail: true,
31+
32+
/**
33+
* Indicates whether the coverage information should be collected while executing the test.
34+
* Because this retrofits all executed files with coverage collection statements,
35+
* it may significantly slow down your tests.
36+
*/
37+
collectCoverage: isCI,
38+
39+
/**
40+
* An array of glob patterns indicating a set of files for which coverage
41+
* information should be collected. If a file matches the specified glob pattern,
42+
* coverage information will be collected for it even if no tests exist for this file and
43+
* it's never required in the test suite.
44+
*/
45+
collectCoverageFrom: ['test/*.spec.ts'],
46+
47+
/**
48+
* A list of reporter names that Jest uses when writing coverage reports.
49+
* Any istanbul reporter can be used.
50+
* https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib
51+
*/
52+
coverageReporters: ['json', 'lcovonly', 'lcov', 'text', 'html'],
53+
54+
/**
55+
* The glob patterns Jest uses to detect test files.
56+
*/
57+
testMatch: ['<rootDir>/test/*.spec.ts'],
58+
59+
/**
60+
* Indicates whether each individual test should be reported during the run.
61+
* All errors will also still be shown on the bottom after execution.
62+
*/
63+
verbose: true,
64+
65+
/**
66+
* The directory where Jest should store its cached dependency information.
67+
*/
68+
cacheDirectory: '<rootDir>/.cache',
69+
70+
/**
71+
* By default, each test file gets its own independent module registry.
72+
* Enabling resetModules goes a step further and resets the module registry before running
73+
* each individual test. This is useful to isolate modules for every test so that local
74+
* module state doesn't conflict between tests. This can be done programmatically
75+
* using jest.resetModules().
76+
*/
77+
resetModules: true,
78+
79+
/**
80+
* Automatically clear mock calls and instances between every test.
81+
* Equivalent to calling jest.clearAllMocks() between each test.
82+
* This does not remove any mock implementation that may have been provided.
83+
*/
84+
clearMocks: true,
85+
86+
testEnvironment: 'node',
87+
};
88+
89+
export default config;

0 commit comments

Comments
 (0)