vuejs / vue-test-utils

Component Test Utils for Vue 2
https://vue-test-utils.vuejs.org
MIT License
3.57k stars 668 forks source link

test breaks when switching import #779

Closed theNewFlesh closed 6 years ago

theNewFlesh commented 6 years ago

When I switch the import from "vue-test-utils" to "@vue/test-utils" one of my tests breaks.

wrapper.emitted() resolves to undefined in the latter case, and I get an "TypeError: undefined is not an object" error

Given that:

`

here is the test: `import Vue from "vue"; import Timeline from "../src/components/Timeline.vue";

import as vtu from "@vue/test-utils"; import as utils from "../../tools/utils"; // -----------------------------------------------------------------------------

/ convenience function for getting a good timeline instance @return a wrapped Timeline mounted with easily testable prop data / function getWrapper1(): any { return vtu.mount(Timeline, { propsData: { inPoint: 2, outPoint: 6, step: 2, displayMarkers: true } } ); }

/ like getWrapper1, but with props that make testing tick and tickStep easy @return a wrapped Timeline mounted with easily testable prop data / function getWrapper2(): any { return vtu.mount(Timeline, { propsData: { inPoint: 0, outPoint: 100, step: 1, displayMarkers: true } } ); } // -----------------------------------------------------------------------------

describe('Timeline', () => { describe("events", () => { const wrapper = getWrapper1();

    it("onMarkerUpdate emits correct events and values", () => {
        wrapper.vm.onMarkerUpdate(["1", "2", "3"]);
        const emitted = wrapper.emitted();
        expect(emitted.inPointChanged[0][0]).toBe(1);
        expect(emitted.playheadChanged[0][0]).toBe(2);
        expect(emitted.outPointChanged[0][0]).toBe(3);
    });
});

}); `

vue-bot commented 6 years ago

Hello, your issue has been closed because it does not conform to our issue requirements. In order to ensure every issue provides the necessary information for us to investigate, we require the use of the Issue Helper when creating new issues. Thank you!