Skip to content

Commit 872b197

Browse files
committed
add typescript support for jest
1 parent abaa5a9 commit 872b197

File tree

6 files changed

+255
-31
lines changed

6 files changed

+255
-31
lines changed

__tests__/tsconfig.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
"allowJs": true,
44
"allowSyntheticDefaultImports": true,
55
"checkJs": false,
6-
// "declaration": true,
76
"esModuleInterop": true,
8-
"lib": ["ES6"],
9-
"module": "ES6",
7+
"moduleResolution": "node",
8+
"noEmit": true,
109
"noEmitOnError": true,
11-
"outDir": "dist/",
12-
"strict": true
10+
"strict": true,
11+
"target": "ESNext"
1312
},
14-
"exclude": ["node_modules", "dist", "src", "**/*.json"],
13+
"exclude": [
14+
"node_modules",
15+
"examples",
16+
"dist",
17+
"**/*.json",
18+
"**/*.config.js"
19+
],
1520
"include": ["./"]
1621
}

jest.config.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"bail": true,
3+
"collectCoverage": false,
4+
"collectCoverageFrom": ["src/**/*"],
5+
"coverageDirectory": "__coverage__",
6+
"globalSetup": "",
7+
"globals": {},
8+
"preset": "ts-jest",
9+
"setupFiles": [],
10+
"testEnvironment": "node",
11+
"testPathIgnorePatterns": [
12+
"__tests__/istanbul-linker-util.js",
13+
"__tests__/test-utils.js",
14+
"__tests__/.eslintrc.js"
15+
],
16+
"verbose": false
17+
}

jsconfig.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

package-lock.json

Lines changed: 215 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@types/core-js": "^2.5.3",
2424
"@types/eslint": "^6.8.1",
2525
"@types/eslint-plugin-prettier": "^3.1.0",
26+
"@types/jest": "^25.2.2",
2627
"@types/prettier": "^2.0.0",
2728
"@types/rollup-plugin-node-builtins": "^2.1.1",
2829
"@types/rollup-plugin-node-globals": "^1.4.0",
@@ -53,6 +54,7 @@
5354
"rollup-plugin-node-builtins": "^2.1.2",
5455
"rollup-plugin-node-globals": "^1.4.0",
5556
"rollup-plugin-terser": "^5.3.0",
57+
"ts-jest": "^25.5.1",
5658
"typescript": "^3.9.2"
5759
},
5860
"engines": {
@@ -68,24 +70,6 @@
6870
"pre-commit": "npm run lint"
6971
}
7072
},
71-
"jest": {
72-
"bail": true,
73-
"collectCoverage": false,
74-
"collectCoverageFrom": [
75-
"src/**/*.js"
76-
],
77-
"coverageDirectory": "__coverage__",
78-
"globalSetup": "",
79-
"globals": {},
80-
"setupFiles": [],
81-
"testEnvironment": "node",
82-
"testPathIgnorePatterns": [
83-
"__tests__/istanbul-linker-util.js",
84-
"__tests__/test-utils.js",
85-
"__tests__/.eslintrc.js"
86-
],
87-
"verbose": false
88-
},
8973
"keywords": [
9074
"ai",
9175
"artificial-intelligence",
@@ -122,16 +106,16 @@
122106
"build": "run-s build:**",
123107
"build:browser": "rollup -c rollup.config.browser.js",
124108
"build:node": "rollup -c rollup.config.js",
125-
"coverage": "jest --env=node --coverage --coverage-provider v8 && codecov",
109+
"coverage": "jest --coverage --coverage-provider v8 && codecov",
126110
"dist": "npm run build",
127111
"lint": "run-s lint:typecheck lint:eslint",
128112
"lint:eslint": "eslint --fix --ext .js,.ts __tests__ src",
129113
"lint:typecheck": "tsc --noEmit",
130-
"test": "jest --env=node",
114+
"test": "jest",
131115
"watch": "run-p watch:**",
132116
"watch:browser": "rollup -c rollup.config.browser.js -w",
133117
"watch:node": "rollup -c rollup.config.js -w",
134-
"watch:test": "jest --watch --env=node"
118+
"watch:test": "jest --watch"
135119
},
136120
"typings": "./src/index.d.ts",
137121
"version": "2.0.0-alpha.12"

tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
"strict": true,
1111
"target": "ESNext"
1212
},
13-
"exclude": ["node_modules", "dist", "**/*.json", "**/*.config.js"],
13+
"exclude": [
14+
"node_modules",
15+
"examples",
16+
"dist",
17+
"**/*.json",
18+
"**/*.config.js"
19+
],
1420
"include": ["src", "__tests__"]
1521
}

0 commit comments

Comments
 (0)