浏览代码

chore: demo test config

richard1015 3 年之前
父节点
当前提交
4d4dbb2b27
共有 2 个文件被更改,包括 15 次插入0 次删除
  1. 1 0
      jd/generate-nutui.js
  2. 14 0
      src/packages/utils/test/demo.ts

+ 1 - 0
jd/generate-nutui.js

@@ -36,6 +36,7 @@ fs.outputFile(path.resolve(__dirname, '../src/packages/nutui.vue.build.ts'), fil
 let fileStrDev = `${importStr}
 ${installFunction}
 ${importScssStr}
+export const testComponents = { ${packages.join(',')}};
 export { install, ${packages.join(',')}  };
 export default { install, version:'${package.version}'};`;
 fs.outputFile(path.resolve(__dirname, '../src/packages/nutui.vue.ts'), fileStrDev, 'utf8', (error) => {

+ 14 - 0
src/packages/utils/test/demo.ts

@@ -0,0 +1,14 @@
+import { mount } from '@vue/test-utils';
+import { testComponents } from '@/packages/nutui.vue';
+
+export function snapshotDemo(Demo: any, option: any = {}) {
+  test('should render demo and match snapshot', async () => {
+    const wrapper = mount(Demo, {
+      global: {
+        components: testComponents
+      }
+    });
+
+    expect(wrapper.html()).toMatchSnapshot();
+  });
+}