Skip to content

Commit

Permalink
test: change karma to jest
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed May 13, 2018
1 parent d86e333 commit 059b928
Show file tree
Hide file tree
Showing 20 changed files with 677 additions and 440 deletions.
15 changes: 15 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"env": {
"test": {
"presets": [
["env", { "targets": { "node": "current" } }]
],
"plugins": [
"transform-vue-jsx",
"transform-object-assign",
"transform-object-rest-spread",
"transform-class-properties"
]
}
}
}
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"env": {
"browser": true,
"node": true,
"jasmine": true,
"jest": true,
"es6": true
},
"parser": "babel-eslint",
"extends": ["plugin:vue-libs/recommended"],
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ es
site-dist
yarn.lock
package-lock.json
/test/coverage
/coverage

# 备份文件
/components/test/*
48 changes: 48 additions & 0 deletions .jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const libDir = process.env.LIB_DIR;

const transformIgnorePatterns = [
'/dist/',
'node_modules\/[^/]+?\/(?!(es|node_modules)\/)', // Ignore modules without es dir
];

module.exports = {
setupFiles: [
'./tests/setup.js',
],
moduleFileExtensions: [
"js",
"jsx",
"json",
"vue",
"md"
],
modulePathIgnorePatterns: [
'/_site/',
],
testPathIgnorePatterns: [
'/node_modules/',
'node',
],
transform: {
".*\\.(vue|md)$": "<rootDir>/node_modules/vue-jest",
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest"
},
testRegex: libDir === 'dist' ? 'demo\\.test\\.js$' : '.*\\.test\\.js$',
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/$1",
"vue-antd-ui": "<rootDir>/components/index.js",
},
snapshotSerializers: [
"<rootDir>/node_modules/jest-serializer-vue"
],
collectCoverage: process.env.COVERAGE === 'true',
collectCoverageFrom: [
"components/**/*.{js,jsx,vue}",
'!components/*/style/index.{js,jsx}',
'!components/style/index.{js,jsx}',
'!components/*/locale/index.{js,jsx}',
'!components/*/__tests__/**/type.{js,jsx}',
"!**/node_modules/**"
],
transformIgnorePatterns,
};
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_js:
before_script:
- npm install vue vue-template-compiler
script:
- npm test
- COVERAGE=true npm run test
- npm run codecov
- bash ./scripts/deploy-to-gh-pages.sh
env:
Expand Down
3 changes: 2 additions & 1 deletion antd-tools/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function dist (done) {
}

function babelify (js, modules) {
const babelConfig = getBabelCommonConfig(modules)
const babelConfig = { ...getBabelCommonConfig(modules), babelrc: false }
delete babelConfig.cacheDirectory
if (modules === false) {
babelConfig.plugins.push(replaceLib)
Expand Down Expand Up @@ -123,6 +123,7 @@ function compile (modules) {
const source = [
'components/**/*.js',
'components/**/*.jsx',
'!components/*/__tests__/*',
]
const jsFilesStream = babelify(gulp.src(source), modules)
return merge2([less, jsFilesStream, assets])
Expand Down
28 changes: 0 additions & 28 deletions components/button/__test__/__snapshots__/index.test.md

This file was deleted.

140 changes: 0 additions & 140 deletions components/button/__test__/index.spec.js

This file was deleted.

Loading

0 comments on commit 059b928

Please sign in to comment.