Skip to content

Example project with stubs not working in Cypress 12.3, Vue 2.7 in script setup mode.

Notifications You must be signed in to change notification settings

mverdaguer/cypress-vue-2.7-stubs-not-working

Repository files navigation

cypress-vue-2.7-stubs-not-working

Example project with stubs not working in Cypress 12.3.0, Vue 2.7.14 in script setup mode.

Install

yarn

Run tests

yarn test:ct

Example 1: Working case (not using script setup)

Component: HelloWorld

<script lang="ts">
import { defineComponent } from "vue";
import ChildComponent from "./ChildComponent.vue"

export default defineComponent({
  components: {
    ChildComponent,
  },
});

<template>
  <div class="hello-world">
    <ChildComponent />
    <ChildComponent />
    <ChildComponent />
  </div>
</template>
</script>
import HelloWorld from "../HelloWorld.vue";

describe("HelloWorld", () => {
  it("renders properly", () => {
    cy.mount(HelloWorld, { stubs: { ChildComponent: true } })
      .get("childcomponent-stub")
      .should("have.length", "3");
  });
});

Example 2: Failing case (using script setup)

<script setup lang="ts">
import ChildComponent from './ChildComponent.vue'
</script>

<template>
  <div class="hello-world">
    <ChildComponent />
    <ChildComponent />
    <ChildComponent />
  </div>
</template>
import HelloWorldScriptSetup from "../HelloWorldScriptSetup.vue";

describe("HelloWorldScriptSetup", () => {
  it("renders properly", () => {
    cy.mount(HelloWorldScriptSetup, { stubs: { ChildComponent: true } })
      .get("childcomponent-stub")
      .should("have.length", "3");
  });
});

About

Example project with stubs not working in Cypress 12.3, Vue 2.7 in script setup mode.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published