I'm currently working on a Vue.Js project where we have a lot of modal components written like this:
<template>
<div class="root">
<MyModal width="650px" height="300px" :hasShadow="false">
... some logic that needs to be tested.
</MyModal>
</div>
</template>
<script> ... </script>
<style scoped> ... </style>
So essentially, the HTML logic I want to test is one level deep, meaning that I can't use the vue-test-util shallowMount. It would just stub out the MyModal component.
Is there a way in which I can just grab the plain HTML of the vue file itself? I'm thinking of parsing out just the <MyModal>...</MyModal>
section and testing it this way:
let myModalHtmlString = getHtmlString(myComponent);
component = shallowMount(myComponent, {
propsData: myPropsData,
store: myStore,
template: myModalHtmlString
});
Essentially, I'm looking for how getHtmlString()
above would work.