Skip to content

Commit b6612f7

Browse files
committed
refactor(tests): e2e
1 parent c9dc12e commit b6612f7

3 files changed

Lines changed: 2005 additions & 13641 deletions

File tree

jest.config.js

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,51 @@
1+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
12
const FULL_TEST = Boolean(process.env.FULL_TEST);
2-
const TEST_STANDALONE = Boolean(process.env.TEST_STANDALONE);
3+
// jest.config.js
4+
const {defaults} = require('jest-config');
35

6+
const CONSOLE_FAIL_TYPES = ['error', 'warn']
7+
8+
// Throw errors when a `console.error` or `console.warn` happens
9+
// by overriding the functions
10+
CONSOLE_FAIL_TYPES.forEach((type) => {
11+
console[type] = (message) => {
12+
throw new VError.errorFromList(
13+
`Failing due to console.${type} while running test!\n\n${message}`,
14+
)
15+
}
16+
})
417
module.exports = {
518
collectCoverage: FULL_TEST,
619
collectCoverageFrom: [
7-
'scripts/**/*.js',
20+
"__tests__/**/*.js",
21+
'!scripts/**/*.js',
822
'!scripts/generateIndexes.js',
923
'src/**/*.js',
1024
'!<rootDir>/node_modules/',
11-
'!src/prettier-comments/**/*.js',
25+
'!src/prettier-comments/**/*.js'
1226
],
27+
"coverageReporters": ["clover", "json", "lcov"],
1328
coverageDirectory: './coverage/',
1429
coveragePathIgnorePatterns: ['/node_modules/', '/scripts/'],
1530
coverageThreshold: {
1631
global: {
1732
branches: 100,
1833
functions: 100,
1934
lines: 100,
20-
statements: 100,
21-
},
22-
},
23-
moduleNameMapper: {
24-
'^prettier$': TEST_STANDALONE
25-
? '<rootDir>/node_modules/prettier/standalone'
26-
: '<rootDir>/node_modules/prettier',
35+
statements: 100
36+
}
2737
},
2838
setupFiles: ['<rootDir>/tests/config/setup.js'],
29-
snapshotSerializers: ['jest-snapshot-serializer-raw', 'jest-snapshot-serializer-ansi'],
39+
snapshotSerializers: [
40+
'jest-snapshot-serializer-raw',
41+
'jest-snapshot-serializer-ansi'
42+
],
43+
testTimeout: 12500,
3044
testEnvironment: 'node',
3145
testRegex: 'jsfmt\\.spec\\.js$|tests/unit/.*\\.js$',
3246
transform: {},
33-
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
47+
watchPlugins: [
48+
'jest-watch-typeahead/filename',
49+
'jest-watch-typeahead/testname'
50+
]
3451
};

0 commit comments

Comments
 (0)