Skip to content

Commit

Permalink
chore(tests): add Jest and initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nelson6e65 committed May 7, 2022
1 parent 8c267ca commit 4417833
Show file tree
Hide file tree
Showing 7 changed files with 2,020 additions and 78 deletions.
40 changes: 28 additions & 12 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig.json"]
},
"plugins": ["@typescript-eslint", "import"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier"
"overrides": [
{
"files": ["*.js"],
"env": {
"node": true
},
"extends": ["eslint:recommended", "plugin:import/recommended", "prettier"]
},
{
"files": ["*.ts"],
"env": {
"browser": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig.json", "./tsconfig.spec.json"]
},
"plugins": ["@typescript-eslint", "import"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier"
]
}
]
}
17 changes: 17 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */

const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig.json');

module.exports = {
preset: 'ts-jest/presets/default-esm',
extensionsToTreatAsEsm: ['.ts'],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.spec.json',
useESM: true,
},
},
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths /*, { prefix: '<rootDir>/' } */),
testEnvironment: 'node',
};
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
"build": "tsc",
"commit": "git-cz",
"preinstall": "npx -y only-allow pnpm",
"lint": "tsc --noEmit -p . && eslint . && prettier --check .",
"lint": "tsc --noEmit -p . && tsc --noEmit -p tsconfig.spec.json && eslint . && prettier --check .",
"prepare": "husky install",
"semantic-release": "semantic-release"
"semantic-release": "semantic-release",
"test": "jest"
},
"config": {
"commitizen": {
Expand All @@ -34,6 +35,8 @@
"@commitlint/config-conventional": "^16.2.4",
"@commitlint/cz-commitlint": "^16.2.4",
"@prettier/plugin-xml": "^2.1.0",
"@types/jest": "^27.5.0",
"@types/node": "16",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"commitizen": "^4.2.4",
Expand All @@ -43,11 +46,14 @@
"eslint-plugin-import": "^2.26.0",
"husky": "^7.0.0",
"inquirer": "^8.2.4",
"jest": "^28.1.0",
"lint-staged": "^12.4.1",
"prettier": "^2.6.2",
"prettier-plugin-packagejson": "^2.2.17",
"pretty-quick": "^3.1.3",
"semantic-release": "^19.0.2",
"ts-jest": "^28.0.1",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
},
"engines": {
Expand Down
Loading

0 comments on commit 4417833

Please sign in to comment.