diff --git a/example/app.json b/example/app.json
index 3813fe43..bab31741 100644
--- a/example/app.json
+++ b/example/app.json
@@ -70,6 +70,7 @@
"van-button": "./dist/button/index",
"van-button-demo": "./dist/button/demo/index",
"van-card": "./dist/card/index",
+ "van-card-demo": "./dist/card/demo/index",
"van-cell": "./dist/cell/index",
"van-cell-group": "./dist/cell-group/index",
"van-checkbox": "./dist/checkbox/index",
diff --git a/example/pages/card/index.js b/example/pages/card/index.js
index bcbac713..cc11dfda 100644
--- a/example/pages/card/index.js
+++ b/example/pages/card/index.js
@@ -1,7 +1,3 @@
import Page from '../../common/page';
-Page({
- data: {
- imageURL: 'https://img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg'
- }
-});
+Page();
diff --git a/example/pages/card/index.wxml b/example/pages/card/index.wxml
index 0bc3b7ec..b3be7bb6 100644
--- a/example/pages/card/index.wxml
+++ b/example/pages/card/index.wxml
@@ -1,32 +1 @@
-
-
-
-
-
-
-
-
- 标签1
- 标签2
-
-
-
-
-
+
diff --git a/packages/card/demo/index.json b/packages/card/demo/index.json
new file mode 100644
index 00000000..d22c0b5c
--- /dev/null
+++ b/packages/card/demo/index.json
@@ -0,0 +1,7 @@
+{
+ "component": true,
+ "usingComponents": {
+ "van-card": "../../card/index",
+ "demo-block": "../../../example/components/demo-block/index"
+ }
+}
diff --git a/example/pages/card/index.wxss b/packages/card/demo/index.less
similarity index 100%
rename from example/pages/card/index.wxss
rename to packages/card/demo/index.less
diff --git a/packages/card/demo/index.ts b/packages/card/demo/index.ts
new file mode 100644
index 00000000..05abaf53
--- /dev/null
+++ b/packages/card/demo/index.ts
@@ -0,0 +1,8 @@
+import { VantComponent } from '../../common/component';
+
+VantComponent({
+ data: {
+ imageURL:
+ 'https://img.yzcdn.cn/upload_files/2017/07/02/af5b9f44deaeb68000d7e4a711160c53.jpg',
+ },
+});
diff --git a/packages/card/demo/index.wxml b/packages/card/demo/index.wxml
new file mode 100644
index 00000000..0bc3b7ec
--- /dev/null
+++ b/packages/card/demo/index.wxml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+ 标签1
+ 标签2
+
+
+
+
+
diff --git a/packages/card/test/__snapshots__/demo.spec.ts.snap b/packages/card/test/__snapshots__/demo.spec.ts.snap
new file mode 100644
index 00000000..7b320cd9
--- /dev/null
+++ b/packages/card/test/__snapshots__/demo.spec.ts.snap
@@ -0,0 +1,217 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render demo and match snapshot 1`] = `
+
+
+
+
+
+ 基础用法
+
+
+
+
+
+
+
+
+
+
+
+
+ 高级用法
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/packages/card/test/demo.spec.ts b/packages/card/test/demo.spec.ts
new file mode 100644
index 00000000..4c3798cb
--- /dev/null
+++ b/packages/card/test/demo.spec.ts
@@ -0,0 +1,11 @@
+import path from 'path';
+import simulate from 'miniprogram-simulate';
+
+test('should render demo and match snapshot', () => {
+ const id = simulate.load(path.resolve(__dirname, '../demo/index'), {
+ rootPath: path.resolve(__dirname, '../../'),
+ });
+ const comp = simulate.render(id);
+ comp.attach(document.createElement('parent-wrapper'));
+ expect(comp.toJSON()).toMatchSnapshot();
+});