Closed IpelaTech closed 3 years ago
Describe the bug
When I try to test a renderless component, child components of the renderless component are not rendered.
To Reproduce Steps to reproduce the behavior:
Expected behavior
That all components are rendered and can be accessed by the getText, etc. The initial error I got was that getText could not find the text.
Screenshots The error message:
Related information:
@testing-library/vue
Vue
Vuecli
node
npm
Relevant code or config (if any)
//MapboxToken.vue <script> export default { props: { mapbox_token: Object }, data() { return { token: "" }; }, render() { return this.$scopedSlots.default({ token: this.token }); }, created() { console.log(this.mapbox_token); this.token = this.mapbox_token.token; } }; </script> //Create.vue <div> <mapbox-token :mapbox_token="map_token" v-slot="{ token }"> <header> <h4 class="text-white">Schedule Callout</h4> </header> </mapbox-token> </div> //Create.spec.js import { render, fireEvent } from "@testing-library/vue"; import Create from "../../../../../resources/js/Pages/TowRequest/Create.vue"; test("increments value on click", async () => { // The render method returns a collection of utilities to query your component. const { getByText, debug } = render(Create, { props: { map_token: { token: "xstasd" } } }); //debug(); getByText("Schedule Callout"); });
Additional context
Is it possible that I could have missed a step. Or I'm testing the wrong way?
Thanks. Ipeleng
Apologies, I thought the library would load the component and any scoped slots but it works as documented if I send a string or use the create element function.
Describe the bug
When I try to test a renderless component, child components of the renderless component are not rendered.
To Reproduce Steps to reproduce the behavior:
Expected behavior
That all components are rendered and can be accessed by the getText, etc. The initial error I got was that getText could not find the text.
Screenshots The error message:
Related information:
@testing-library/vue
version: 5.6.2Vue
version: 2.6.12Vuecli
version: 4.5.12node
version: 14.16.0npm
version: 6.14.11Relevant code or config (if any)
Additional context
Is it possible that I could have missed a step. Or I'm testing the wrong way?
Thanks. Ipeleng