Skip to content

Commit

Permalink
chore(repo): remove ts-jest
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Jan 16, 2024
1 parent 4242cb1 commit d720060
Show file tree
Hide file tree
Showing 4 changed files with 275 additions and 243 deletions.
14 changes: 12 additions & 2 deletions .circleci/config.yml
Expand Up @@ -168,7 +168,12 @@ commands:
- run: yarn pretest
- run:
name: Run node tests
command: yarn test.jest --maxWorkers=<< parameters.max-workers >>
command: yarn test.jest --maxWorkers=<< parameters.max-workers >> --reporters=default --reporters=jest-junit
environment:
JEST_JUNIT_OUTPUT_DIR: ./reports/
JEST_JUNIT_ADD_FILE_ATTRIBUTE: "true"
- store_test_results:
path: ./reports/

test-harness:
parameters:
Expand All @@ -194,7 +199,12 @@ commands:
node-version: << parameters.node-version >>
- run:
name: Run harness tests
command: yarn test.harness --maxWorkers=<< parameters.max-workers >>
command: yarn test.harness --maxWorkers=<< parameters.max-workers >> --reporters=jest-junit
environment:
JEST_JUNIT_OUTPUT_DIR: ./reports/
JEST_JUNIT_ADD_FILE_ATTRIBUTE: "true"
- store_test_results:
path: ./reports/
- save_cache:
name: Retain test-harness artifacts
key: test-harness-{{ checksum "/tmp/current-commit-sha" }}-<< parameters.os >>-<< parameters.node-version >>
Expand Down
19 changes: 11 additions & 8 deletions jest.config.mjs
@@ -1,18 +1,21 @@
/*eslint-env node*/
import { pathsToModuleNameMapper } from 'ts-jest';
import * as path from 'path';
import * as fs from 'fs';
import { fileURLToPath } from 'url';
import escapeRegexp from 'lodash/escapeRegExp.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const { compilerOptions } = JSON.parse(fs.readFileSync('./tsconfig.json', 'utf8'));

const projectDefault = {
moduleNameMapper: {
...Object.fromEntries(
Object.entries(pathsToModuleNameMapper(compilerOptions.paths)).map(([k, v]) => [k, path.join(__dirname, v)]),
),
'^@stoplight/spectral\\-test\\-utils$': '<rootDir>/test-utils/node/index.ts',
...Object.entries(compilerOptions.paths).reduce((paths, [mod, [path]]) => {
if (mod.endsWith('/*')) {
paths[`^${escapeRegexp(mod.slice(0, -1))}(.*)`] = `<rootDir>/${path.replace('*', '$1')}`;
} else {
paths[`^${escapeRegexp(mod)}$`] = `<rootDir>/${path}`;
}

return paths;
}, {}),
'^@stoplight/spectral-test-utils$': '<rootDir>/test-utils/node/index.ts',
},
testEnvironment: 'node',
transform: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -107,6 +107,7 @@
"file-entry-cache": "^6.0.1",
"husky": "^7.0.4",
"jest": "^28.1.3",
"jest-junit": "^16.0.0",
"jest-mock": "^27.5.1",
"karma": "^6.4.0",
"karma-chrome-launcher": "^3.1.1",
Expand All @@ -120,7 +121,6 @@
"patch-package": "^6.4.7",
"prettier": "^2.4.1",
"semantic-release": "^19.0.5",
"ts-jest": "^28.0.5",
"ts-node": "^10.8.2",
"typescript": "^4.4.4"
},
Expand Down

0 comments on commit d720060

Please sign in to comment.