Skip to content

Commit

Permalink
feat: 新增jest测试
Browse files Browse the repository at this point in the history
  • Loading branch information
vfiee committed Apr 11, 2022
1 parent 856b0f1 commit 7672710
Show file tree
Hide file tree
Showing 8 changed files with 3,016 additions and 131 deletions.
8 changes: 6 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/* eslint-disable no-undef */
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['error']
'@typescript-eslint/no-unused-vars': ['error'],
'no-restricted-globals': ['error']
},
globals: {
__dirname: true,
module: true
}
}
47 changes: 9 additions & 38 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,15 @@
## 1.1.4 (2022-02-27)
## 0.0.1 (2022-04-10)


### Features

## 1.1.3 (2022-02-27)



## 1.1.2 (2022-02-27)



## 0.0.1-alpha.3 (2022-02-27)



## 0.0.1-alpha.2 (2022-02-27)



## 0.0.1-alpha.1 (2022-02-27)



## 0.0.1-alpha.8 (2022-02-27)



## 0.0.1-alpha.7 (2022-02-27)



## 0.0.1-alpha.6 (2022-02-27)



## 0.0.1-alpha.4 (2022-02-27)



## 0.0.1 (2022-02-27)
* 新增v-utils 包 ([38990c1](https://github.com/VFiee/v-utils/commit/38990c14c35fe9307359192a8e480320b1e832e6))
* **array:** 初始化数组包 ([c094e1f](https://github.com/VFiee/v-utils/commit/c094e1ff03ce3a7d93ef0d093c5a3205a3e826b4))
* **array:** 新增chunk,compact,head,first,last,flattenDepth,flattenDeep,flatten ([198abc1](https://github.com/VFiee/v-utils/commit/198abc121efd50a0b68e2a6328b35fcf11469872))
* **type:** 新增类型函数 ([944da83](https://github.com/VFiee/v-utils/commit/944da8341139d5c59d7b750a94a566e3e2e07450))
* **type:** 新增isFalsy, isTruthy ([d97d81c](https://github.com/VFiee/v-utils/commit/d97d81cff04cc66bc1c0ed7cd33a1f4e3fdf7841))


### Performance Improvements

* **type:** 优化 isNull,isUndefined,isNil ([a58d3db](https://github.com/VFiee/v-utils/commit/a58d3db582189a20665c960086eed0e47cffa9be))
23 changes: 23 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
testEnvironment: 'jsdom',
preset: 'ts-jest',
globals: {
'ts-jest': {
target: 'esnext',
sourceMap: true
}
},
// collectCoverage: true,
coverageProvider: 'v8',
coverageDirectory: 'coverage',
coverageReporters: ['json', 'text', 'html'],
collectCoverageFrom: ['packages/**/**/*.ts', '!packages/v-utils/**'],
moduleFileExtensions: ['js', 'ts'],
moduleNameMapper: {
'@v-utils/type': '<rootDir>/packages/type/src',
'@v-utils/array': '<rootDir>/packages/array/src'
},
rootDir: __dirname,
testMatch: ['<rootDir>/packages/**/__tests__/**/*spec.ts'],
testPathIgnorePatterns: ['/node_modules/']
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"release": "node scripts/release.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"preinstall": "npx only-allow pnpm",
"test": "node scripts/test.js",
"test": "jest --",
"lint": "eslint --ext .ts packages/*/src/**.ts",
"format": "prettier --write --parser typescript \"packages/**/*.ts?(x)\""
},
Expand Down Expand Up @@ -54,6 +54,7 @@
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
"@microsoft/api-extractor": "^7.20.0",
"@types/bluebird": "^3.5.36",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.23",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.17.0",
Expand All @@ -65,6 +66,7 @@
"esbuild": "^0.14.23",
"eslint": "^8.12.0",
"execa": "5.1.1",
"jest": "^27.5.1",
"lint-staged": "^12.3.7",
"lodash.get": "^4.4.2",
"lodash.set": "^4.3.2",
Expand All @@ -76,6 +78,7 @@
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"semver": "^7.3.5",
"ts-jest": "^27.1.4",
"ts-toolbelt": "^9.6.0",
"typescript": "^4.6.3",
"yorkie": "^2.0.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/array/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { head } from '@v-utils/array'

describe('array', () => {
test('head', () => {
const arr = [1, 2, 3]
expect(head(arr)).toBe(1)
})
})
10 changes: 10 additions & 0 deletions packages/type/__tests__/type.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { isString } from '@v-utils/type'

describe('type', () => {
test('isString', () => {
const str = 'string'
const str2 = new String('string')
expect(isString(str)).toBe(true)
expect(isString(str2)).toBe(false)
})
})
Loading

0 comments on commit 7672710

Please sign in to comment.