-
Notifications
You must be signed in to change notification settings - Fork 56
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
Testing implementation of plugin with Jest #82
Comments
First of all thank you for taking the time to implement some real testing. We did not yet get around to it and where simply using manual testing, with the files located in the test folder. With |
Thanks, I've had a bit more luck with getting something working, but there are some limitations. I'll share the code once I've got a bit further in case anyone else is looking for something similar. |
I almost forgot about this :) Updating with what I've managed to put together here |
Thank you very much for sharing the testing setup. I will try to set this up for the repository together with some proper documentation in the upcoming weeks. |
Big thumbs up, this saved my day! |
Thank you for following up on this. I am literally right now working on this for version 2 of the plugin. I just finished setting up the plugin with vue-cli, migrating the complete plugin code over to typescript and implementing the first unit tests with jest. This will really help us to automate the testing and include a lot more test cases. I will try to make the version 2 branch available in a few hours. There will very likely be some breaking changes and new features, but the current version is just a migration to typescript. |
The version branch with a first example of a test is now available |
I'm glad it helped! I have struggled with designing tests to work when the translation string needs parameters passed into it (e.g, "Hello {name}.") but for now have mocked the translation function to return the string as expected. |
I'm trying to test vuex-i18n with jest, so we can test it is configured correctly and the correct strings are being generated and retrieved.
Here is what I've added in the test files:
`const localVue = createLocalVue()
localVue.use(Vuex)
let store = new Vuex.Store()
localVue.use(VuexI18n, store)
localVue.i18n.add('en', en)`
where
en
is an imported translation file. I've also been using vue-test-utils.This is the error I get when trying to run the test:
I've checked and I've used this method to test other plugins so not sure why this way isn't working.
Any ideas?
The text was updated successfully, but these errors were encountered: