question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing implementation of plugin with Jest

See original GitHub issue

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:

`TypeError: Cannot read property 'add' of undefined`

I’ve checked and I’ve used this method to test other plugins so not sure why this way isn’t working.

Any ideas?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
HumayraHanifcommented, Oct 11, 2018

I almost forgot about this 😃 Updating with what I’ve managed to put together here There were some limitations with what can be tested which I will try to explain either the repo, or in this thread when I get around to it

2reactions
tikiatuacommented, Jul 26, 2018

Hi @HumayraHanif

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 import vuexI18n from "vuex-i18n" you will get an object with the properties store and plugin. Please make sure that you use the vuexi18n.plugin to initialize the plugin, not the complete object imported from vuexi18n – i.e. localVue.use(VuexI18n.plugin, store)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Watch Plugins - Jest
The Jest watch plugin system provides a way to hook into specific parts of Jest and to define watch mode menu prompts that...
Read more >
Testing with Jest - Backstage.io
Jest is a Facebook-built unit testing framework specifically built for React. It follows in the footsteps of other classic Node.js unit testing-related ...
Read more >
How To: Write Jest tests for plugins · Reaction Docs
We use and recommend plugin authors to use Jest for writing tests for their plugins. Consider the following module.js file:
Read more >
Jest testing: Top features and how to use them - LogRocket Blog
Jest is a JavaScript testing framework built by Facebook and primarily designed for React-based applications, but is also used with Babel, ...
Read more >
Easy JavaScript unit tests in WordPress with Jest - StartFunction
So Jest is a great and simple solution to write tests that cover the JavaScript code of our WordPress plugins or themes. But...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found