vue-test-utils

Vue test-utils how to test a router.push()

断了今生、忘了曾经 提交于 2019-12-05 12:05:12
In my component , I have a method which will execute a router.push() import router from "@/router"; // ... export default { // ... methods: { closeAlert: function() { if (this.msgTypeContactForm == "success") { router.push("/home"); } else { return; } }, // .... } } I want to test it... I wrote the following specs.. it("should ... go to home page", async () => { // given const $route = { name: "home" }, options = { ... mocks: { $route } }; wrapper = mount(ContactForm, options); const closeBtn = wrapper.find(".v-alert__dismissible"); closeBtn.trigger("click"); await wrapper.vm.$nextTick();

VueJS - Unit testing with vue-test-utils gives error - TypeError: _vm.$t is not a function

你离开我真会死。 提交于 2019-12-04 07:46:55
Relatively new to Vuejs and testing its components. Using vue-test-utils and jest for testing. Getting following error test log The .vue file consists of template, component and styling. Below is the part of the SignupLayout.vue that gets error - <style lang="sass"> @import '../stylesheets/colors' html[path="/signup"], html[path="/login"] height: 100% background-image: url("../assets/background.jpg") background-size: cover background-position: center background-repeat: no-repeat overflow: hidden #signup-layout #change-language-button .lang-menu color: $alto </style> Test File - import Vue from