Browse Source

fix: can not genrate snapshot

pull/2682/head
Amour1688 4 years ago
parent
commit
e03d442542
  1. 17
      .babelrc
  2. 1
      .jest.js
  3. 17
      babel.config.js
  4. 4
      package.json
  5. 7
      tests/shared/demoTest.js

17
.babelrc

@ -1,17 +0,0 @@
{
"env": {
"test": {
"presets": [["@babel/preset-env", { "targets": { "node": true } }]],
"plugins": [
["@ant-design-vue/babel-plugin-jsx", { "usePatchFlag": false }],
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-transform-object-assign",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-runtime"
]
}
}
}

1
.jest.js

@ -21,7 +21,6 @@ module.exports = {
'^@/(.*)$': '<rootDir>/$1',
'ant-design-vue$': '<rootDir>/components/index.js',
'ant-design-vue/es': '<rootDir>/components',
// '^vue$': 'vue/dist/vue.global.js',
},
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
collectCoverage: process.env.COVERAGE === 'true',

17
babel.config.js

@ -0,0 +1,17 @@
module.exports = {
env: {
test: {
presets: [['@babel/preset-env', { targets: { node: true } }]],
plugins: [
['@ant-design-vue/babel-plugin-jsx'],
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-transform-object-assign',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-transform-runtime',
],
},
},
};

4
package.json

@ -82,7 +82,7 @@
"@vue/cli-plugin-eslint": "^4.0.0",
"@vue/compiler-sfc": "^3.0.0-rc.5",
"@vue/server-test-utils": "1.0.0-beta.16",
"@vue/test-utils": "^2.0.0-beta.1",
"@vue/test-utils": "^2.0.0-beta.2",
"acorn": "^7.0.0",
"autoprefixer": "^9.6.0",
"axios": "^0.19.0",
@ -168,7 +168,7 @@
"vue-eslint-parser": "^7.0.0",
"vue-i18n": "^9.0.0-alpha.11",
"vue-infinite-scroll": "^2.0.2",
"vue-jest": "^5.0.0-alpha.1",
"vue-jest": "^5.0.0-alpha.3",
"vue-loader": "^16.0.0-beta.4",
"vue-router": "^4.0.0-alpha.12",
"vue-server-renderer": "^2.6.11",

7
tests/shared/demoTest.js

@ -2,7 +2,7 @@ import glob from 'glob';
import { mount } from '@vue/test-utils';
import MockDate from 'mockdate';
import moment from 'moment';
import { createApp, nextTick } from 'vue';
import { nextTick } from 'vue';
import antd from 'ant-design-vue';
export default function demoTest(component, options = {}) {
@ -18,8 +18,7 @@ export default function demoTest(component, options = {}) {
MockDate.set(moment('2016-11-22'));
const demo = require(`../.${file}`).default || require(`../.${file}`);
document.body.innerHTML = '';
const wrapper = mount(demo, { sync: false, attachToDocument: true });
createApp(wrapper).use(antd);
const wrapper = mount(demo, { global: { plugins: [antd] }, attachTo: document.body });
nextTick(() => {
// should get dom from element
// snap files copy from antd does not need to change
@ -27,7 +26,7 @@ export default function demoTest(component, options = {}) {
const dom = options.getDomFromElement ? wrapper.element : wrapper.html();
expect(dom).toMatchSnapshot();
MockDate.reset();
wrapper.unmount();
// wrapper.unmount();
document.body.innerHTML = '';
done();
});

Loading…
Cancel
Save