-
Notifications
You must be signed in to change notification settings - Fork 668
@vue/test-utils 1.0.0-beta.18 broke unit tests #699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The issue is the store is not added to a class component. I'll look into this soon, but if anyone else would like to investigate, here is a failing test: import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
//
it.only('handles store correctly', () => {
const localVue = createLocalVue()
localVue.use(Vuex)
const store = new Vuex.Store()
const wrapper = mount(ComponentAsAClass, {
store,
localVue
})
console.log(wrapper.vm.$store.getters)
}) |
Just for the reference, here the source code that adds describe('unit tests for ActionBar component', () => {
let actions
let store
beforeEach(() => {
actions = {
fetchComments: jest.fn() // mocking Vuex action call
}
store = new Vuex.Store({ actions })
})
test('should call fetchComments action', () => {
const wrapper = mount(ActionBar, { store, localVue })
const input = wrapper.find('button')
input.trigger('click')
expect(actions.fetchComments).toHaveBeenCalled()
})
}) |
I have a similar problem with vee validate https://www.npmjs.com/package/vee-validate.
This is not working with 1.0.0-beta.17 and 1.0.0-beta.18. |
Hi I have the same problem using mocks options (i am using electron framework) import App from '@/App'; describe.('App.vue', () => { it('should open an external link', (done) => {
......... I have an error : It is working in 1.0.0-beta16, not in beta17 and beta 18 |
same issue with: mount(App, {
i18n,
store,
stubs: ['router-link', 'router-view'],
mocks: {
$router: { replace: jest.fn() },
$route: { name: 'something ' }
}
}); Both mocks throw: TypeError: Cannot read property 'name' of undefined Thrown with class-based components (Typescript) |
Version
1.0.0-beta.18
Reproduction link
wemake-services/wemake-vue-template#597
Tests source: https://github.com/wemake-services/wemake-vue-template/blob/master/template/tests/unit/components/comment.spec.js
Steps to reproduce
@vue/test-utils
to1.0.0-beta.18
yarn test:unit
What is expected?
I expect my unit tests to pass like it was with
1.0.0-beta.16
.Here's an example of a successful build: https://travis-ci.org/wemake-services/wemake-vue-template/builds/389942022
Nothing was changed except the
@vue/test-utils
version.What is actually happening?
Almost all tests fail with:
Related: wemake-services/wemake-vue-template#598
The text was updated successfully, but these errors were encountered: