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.

Allow for separate config file

See original GitHub issue

What problem does this feature solve?

I work in a non English speaking country, so we are using vue-i18n to create a bilingual app. It adds a global $t function. I have to do:

mocks: {
  $t: jest.fn()
}

in every test, or the test fails with $t is undefined, since almost all components have some form of text.

Other users have a similar use case to mock regularly occurring global objects. More comments in this thread: https://github.com/vuejs/vue-test-utils/issues/325

What does the proposed API look like?

I still think a config file would be good. I’m thinking something along the lines of a test-utils.config.js that could be something like this:

export default {
  mocks: {
    // mocks to use in all tests
    // they should be merged with any mocks passed in `shallow` or `mount`
    // the ones from `shallow`, `mount` should take priority and override the ones in this config file
  },
  stubs: {
    /* I often find myself wanting to stub certain components a lot as well */
  }
}

You should be able to provide defaults for anything you can pass in the options object to shallow and mount.

vue-test-utils shouls look for a default config file in the root directory (for example test-utils.config.js).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
38elementscommented, Apr 15, 2018

Thank you for replying.

IMHO, Since it is not necessary to use multiple test runners for same test, I think that not depending test runner does not become benefit. Adding a function is adding maintenance cost and complex. I think if the function provided by a test runner resolve it, it is not necessary to adding this function.

Supporting all options in the config object is other issue.

0reactions
eddyerburghcommented, May 16, 2018

I agree with @38elements, adding an extra config file adds a lot of work on our end. Since we already have a config object, all the setup can be done in there.

I’m closing this as something we aren’t going to implement.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Separate Config Files for Separate Users - Stack Overflow
1 Answer 1 · In order to add a settings file to you project right click the project and then select Add ->...
Read more >
Core Features - Spring
This section dives into the details of Spring Boot. Here you can learn about the key features that you may want to use...
Read more >
Managing Multiple Configuration File Environments with Pre ...
Just create one config file, and use specific tags for items you wish to vary. Then let your build server change these, depending...
Read more >
Multiple configuration files
This method of operation means that you cannot preserve different startupconfig files across a reboot without using remote storage. The switch allows up...
Read more >
Configuration Handling — Flask Documentation (2.2.x)
Do not enable debug mode when deploying in production. ... Configuration becomes more useful if you can store it in a separate file,...
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