MCPcopy
hub / github.com/youzan/vant / snapshotDemo

Function snapshotDemo

packages/vant/test/demo.ts:22–57  ·  view source on GitHub ↗
(Demo: any, option: SnapshotDemoOptions = {})

Source from the content-addressed store, hash-verified

20};
21
22export function snapshotDemo(Demo: any, option: SnapshotDemoOptions = {}) {
23 test('should render demo and match snapshot', async () => {
24 if (option.beforeTest) {
25 option.beforeTest();
26 }
27
28 if (Demo.i18n) {
29 Locale.add(Demo.i18n);
30 }
31
32 if (option.ssr) {
33 const app = createSSRApp(Demo);
34 app.component('DemoBlock', EmptyComponent);
35 const html = await renderToString(app);
36
37 expect(html).toMatchSnapshot();
38 } else {
39 const wrapper = mount(Demo, {
40 global: {
41 components: {
42 'demo-block': EmptyComponent,
43 },
44 },
45 attachTo: document.body,
46 });
47
48 await later();
49
50 expect(wrapper.html()).toMatchSnapshot();
51 }
52
53 if (option.afterTest) {
54 option.afterTest();
55 }
56 });
57}

Callers 15

demo-ssr.spec.tsFile · 0.90
demo.spec.tsFile · 0.90
demo-ssr.spec.tsFile · 0.90
demo.spec.tsFile · 0.90
demo-ssr.spec.tsFile · 0.90
demo.spec.tsFile · 0.90
demo-ssr.spec.tsFile · 0.90
demo.spec.tsFile · 0.90
demo-ssr.spec.tsFile · 0.90
demo.spec.tsFile · 0.90
demo-ssr.spec.tsFile · 0.90
demo.spec.tsFile · 0.90

Calls 3

testFunction · 0.85
laterFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…