Browse Source

test: vue component

fix-react18
王福朋 4 years ago
parent
commit
13df95c7a1
  1. 3
      .babelrc
  2. 11
      jest.config.js
  3. 15
      package.json
  4. 5
      packages/editor-for-vue/__tests__/basic.test.js
  5. 15
      packages/editor-for-vue/__tests__/basic.test.ts
  6. 5
      packages/list-module/__tests__/basic.test.js
  7. 5
      packages/table-module/__tests__/basic.test.js
  8. 4
      shims-vue.d.ts
  9. 8
      tests/setup/index.ts
  10. 2
      tsconfig.json
  11. 2160
      yarn.lock

3
babel.config.json → .babelrc

@ -10,7 +10,8 @@
}
],
"@babel/preset-react",
"@babel/preset-typescript"
"@babel/preset-typescript",
"@vue/cli-plugin-babel/preset"
],
"plugins": [
[

11
jest.config.js

@ -1,20 +1,21 @@
module.exports = {
roots: ['<rootDir>/packages'],
testEnvironment: 'jsdom',
testMatch: ['**/(*.)+(spec|test).+(ts|js)'],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.js$': 'ts-jest',
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest',
},
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.json',
tsconfig: '<rootDir>/tsconfig.json',
},
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleFileExtensions: ['js', 'ts', 'tsx', 'json', 'vue'],
moduleNameMapper: {
'^.+\\.(css|less)$': '<rootDir>/tests/utils/stylesMock.js',
},
transformIgnorePatterns: ['node_modules/(?!(lodash-es)/)'],
transformIgnorePatterns: ['/node_modules/'],
setupFilesAfterEnv: ['<rootDir>/tests/setup/index.ts'],
}

15
package.json

@ -14,15 +14,15 @@
"release:publish": "lerna publish from-git --yes",
"prerelease": "yarn build",
"format": "yarn prettier --write",
"lint": "eslint \"packages/**/*.+(ts|tsx)\"",
"prettier": "prettier --ignore-path .gitignore \"packages/**/*.+(ts|tsx)\""
"lint": "eslint \"packages/*/src/**/*.+(ts|tsx)\"",
"prettier": "prettier --ignore-path .gitignore \"packages/*/src/**/*.+(ts|tsx)\""
},
"workspaces": [
"packages/*"
],
"lint-staged": {
"packages/**/*.{ts,tsx}": [
"eslint --ext .ts,tsx",
"packages/**/*.{ts,tsx,vue}": [
"yarn lint",
"yarn format",
"yarn test",
"git add ."
@ -57,8 +57,11 @@
"@types/jest": "^25.2.1",
"@typescript-eslint/eslint-plugin": "^2.31.0",
"@typescript-eslint/parser": "^4.4.1",
"@vue/cli-plugin-babel": "^4.5.13",
"@vue/compiler-sfc": "^3.1.4",
"@vue/test-utils": "^1.2.2",
"autoprefixer": "^10.2.5",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^27.0.6",
"babel-plugin-istanbul": "^6.0.0",
"commitlint": "^11.0.0",
@ -97,7 +100,9 @@
"rollup-plugin-vue": "^6.0.0",
"ts-jest": "^27.0.4",
"tslib": "^2.3.0",
"typescript": "4.3.2"
"typescript": "4.3.2",
"vue-jest": "^3.0.7",
"vue-template-compiler": "^2.6.14"
},
"dependencies": {
"@babel/runtime": "^7.14.6"

5
packages/editor-for-vue/__tests__/basic.test.js

@ -1,5 +0,0 @@
describe('editor for vue3', () => {
it('needs tests', () => {
expect(1 + 1).toBe(2)
})
})

15
packages/editor-for-vue/__tests__/basic.test.ts

@ -0,0 +1,15 @@
import { mount } from '@vue/test-utils'
import BasicEditor from '../example/pages/Basic.vue'
import SimpleEditor from '../example/pages/Simple.vue'
describe('Vue editor component', () => {
it('basic editor is a Vue instance', () => {
const editor = mount(BasicEditor)
expect(editor.vm).toBeTruthy()
})
it('simple editor is a Vue instance', () => {
const editor = mount(SimpleEditor)
expect(editor.vm).toBeTruthy()
})
})

5
packages/list-module/__tests__/basic.test.js

@ -1,5 +0,0 @@
describe('list', () => {
it('needs tests', () => {
expect(1 + 1).toBe(2)
})
})

5
packages/table-module/__tests__/basic.test.js

@ -1,5 +0,0 @@
describe('table', () => {
it('needs tests', () => {
expect(1 + 1).toBe(2)
})
})

4
shims-vue.d.ts

@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}

8
tests/setup/index.ts

@ -1 +1,9 @@
import '@testing-library/jest-dom'
import nodeCrypto from 'crypto'
// @ts-ignore
global.crypto = {
getRandomValues: function (buffer: any) {
return nodeCrypto.randomFillSync(buffer)
},
}

2
tsconfig.json

@ -25,5 +25,5 @@
"build",
"__tests__"
],
"include": ["./tests/setup/index.ts"]
"include": ["./tests/setup/index.ts", "./shims-vue.d.ts"]
}

2160
yarn.lock
File diff suppressed because it is too large
View File

Loading…
Cancel
Save