Skip to content

Commit

Permalink
chore: about jest
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwong committed Dec 26, 2019
1 parent 0aab814 commit 9bbe5b1
Show file tree
Hide file tree
Showing 6 changed files with 3,121 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Expand Up @@ -3,9 +3,11 @@ const eslintrc = {
extends: [ extends: [
'eslint:recommended', 'eslint:recommended',
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended',
'plugin:jest/recommended',
], ],
plugins: [ plugins: [
'@typescript-eslint', '@typescript-eslint',
'jest',
], ],
env: { env: {
browser: true, browser: true,
Expand Down Expand Up @@ -43,6 +45,8 @@ const eslintrc = {
}], // 成员分隔符 }], // 成员分隔符
'@typescript-eslint/semi': ['error', 'never'], '@typescript-eslint/semi': ['error', 'never'],


'jest/expect-expect': ["off"],

'space-infix-ops': ['error'], 'space-infix-ops': ['error'],
'comma-dangle': ['error', { 'comma-dangle': ['error', {
'arrays': 'always-multiline', 'arrays': 'always-multiline',
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
}
5 changes: 5 additions & 0 deletions package.json
Expand Up @@ -14,20 +14,25 @@
}, },
"homepage": "https://github.com/simonwong/fly-helper#readme", "homepage": "https://github.com/simonwong/fly-helper#readme",
"scripts": { "scripts": {
"test": "jest --coverage --verbose -u",
"lint": "eslint --ext .js,.ts ./src", "lint": "eslint --ext .js,.ts ./src",
"lint:fix": "eslint --fix --ext .js,.ts ./src" "lint:fix": "eslint --fix --ext .js,.ts ./src"
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-env": "^7.7.7", "@babel/preset-env": "^7.7.7",
"@types/jest": "^24.0.24",
"@typescript-eslint/eslint-plugin": "^2.13.0", "@typescript-eslint/eslint-plugin": "^2.13.0",
"@typescript-eslint/parser": "^2.13.0", "@typescript-eslint/parser": "^2.13.0",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-plugin-jest": "^23.1.1",
"jest": "^24.9.0",
"rollup": "^1.27.14", "rollup": "^1.27.14",
"rollup-plugin-babel": "^4.3.3", "rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-eslint": "^7.0.0", "rollup-plugin-eslint": "^7.0.0",
"rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-typescript2": "^0.25.3", "rollup-plugin-typescript2": "^0.25.3",
"ts-jest": "^24.2.0",
"typescript": "^3.7.4" "typescript": "^3.7.4"
}, },
"dependencies": { "dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
@@ -1,3 +1,3 @@
export default function myFirstFunc () { export default function myFirstFunc (str: string) {
return 'hello rollup' return `hello ${str}`
} }
13 changes: 13 additions & 0 deletions test/index.test.ts
@@ -0,0 +1,13 @@
import assert from 'assert'
import myFirstFunc from '../src'

describe('validate:', () => {
/**
* myFirstFunc
*/
describe('myFirstFunc', () => {
test(' return hello rollup ', () => {
assert.strictEqual(myFirstFunc('rollup'), 'hello rollup')
})
})
})

0 comments on commit 9bbe5b1

Please sign in to comment.