Skip to content

Commit 33993bd

Browse files
authored
test: add jest and create tests for charts (#170)
* test: add jest and create tests for charts * test: move babel-jest config to jest config file
1 parent 76bbe31 commit 33993bd

17 files changed

+2413
-58
lines changed

.babelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
{
2+
"presets": [
3+
[
4+
"@vue/cli-plugin-babel/preset",
5+
{
6+
"modules": false,
7+
"targets": {
8+
"browsers": [
9+
"last 2 versions"
10+
]
11+
}
12+
}
13+
]
14+
],
215
"plugins": [
316
[
417
"module:@import-meta-env/babel",

jest.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
testEnvironment: 'jsdom',
3+
testMatch: ['<rootDir>/test/(*.)spec.(js|ts)'],
4+
moduleFileExtensions: ['js', 'ts', 'vue'],
5+
transform: {
6+
'^.+\\.vue$': '@vue/vue2-jest',
7+
// TODO: replace with @swc/jest after code migration to typescript
8+
'\\.js$': [
9+
'babel-jest',
10+
{
11+
presets: ['@vue/cli-plugin-babel/preset'],
12+
plugins: ['babel-plugin-transform-import-meta'],
13+
},
14+
],
15+
},
16+
collectCoverage: true,
17+
collectCoverageFrom: ['<rootDir>/src/*'],
18+
coverageReporters: ['lcovonly', 'text'],
19+
};

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"postpublish": "del ./package",
2727
"build": "rollup -c",
2828
"lint": "eslint --ext .js,.vue src",
29-
"test": "pnpm lint",
29+
"unit": "jest -c jest.config.js",
30+
"test": "pnpm lint && pnpm unit",
3031
"format": "prettier --write src rollup.config.js",
3132
"test:size": "size-limit",
3233
"commit": "cz",
@@ -64,8 +65,13 @@
6465
"@storybook/vue": "^6.4.20",
6566
"@swc/core": "^1.2.124",
6667
"@swc/helpers": "^0.3.2",
68+
"@vue/cli-plugin-babel": "^5.0.4",
6769
"@vue/compiler-sfc": "^3.2.26",
70+
"@vue/test-utils": "1",
71+
"@vue/vue2-jest": "^27.0.0-alpha.4",
72+
"babel-jest": "^27.5.1",
6873
"babel-loader": "^8.2.4",
74+
"babel-plugin-transform-import-meta": "^2.1.1",
6975
"browserslist": "^4.19.1",
7076
"clean-publish": "^3.4.5",
7177
"commitizen": "^4.2.4",
@@ -74,6 +80,7 @@
7480
"eslint": "^8.5.0",
7581
"eslint-config-prettier": "^8.3.0",
7682
"eslint-plugin-vue": "^8.2.0",
83+
"jest": "^27.5.1",
7784
"nano-staged": "^0.5.0",
7885
"prettier": "^2.5.1",
7986
"rollup": "^2.62.0",
@@ -83,9 +90,9 @@
8390
"simple-github-release": "^1.0.0",
8491
"size-limit": "^7.0.8",
8592
"standard-version": "^9.3.2",
86-
"vue": "^2.6.8",
93+
"vue": "^2.6.14",
8794
"vue-loader": "15.9.8",
88-
"vue-template-compiler": "^2.1.6"
95+
"vue-template-compiler": "^2.6.14"
8996
},
9097
"pnpm": {
9198
"overrides": {

0 commit comments

Comments
 (0)