(Demo: any, option: SnapshotDemoOptions = {})
| 20 | }; |
| 21 | |
| 22 | export 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 | } |
no test coverage detected
searching dependent graphs…