Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(repo): remove ts-jest #2576

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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