Comments (14)
Yeah I'll try to get something together next week.
from avoriaz.
Ok I read the other issues and figured it out. I need to register a component stub. No problem. I get it now.
from avoriaz.
I'll write a guide for this at some point
from avoriaz.
I'm currently unable to coax avoriaz to accept my mock router or router-link stubs, and so the tests insist that the router-link element is unknown. I've tried shallow
, stubbing a router-link component manually and stubbing the globals all to no avail. If there's a guide that can walk me through this I'd be happy to give it a read.
from avoriaz.
Are you sure you're not calling Vue.use (VueRouter)
anywhere when you run your tests?
If you're using the vue webpage template, I'm the files are parsed by karma which causes vue router to be installed. This is my edited version of the file https://github.com/eddyerburgh/stub-route-in-vue-unit-tests/blob/master/test/unit/index.js. the comments weren't changed, so they are a bit confusing. In the template they require all src files except main, which includes router files that install vue router and set an immutable $router object. Ive changed the code to require all files in the components dirextory.
Hopefully this solves your issue.
from avoriaz.
Accidentally closed (I'm on mobile)
from avoriaz.
Interestingly enough, I'm actually running it as an isolated unit test. So no Karma, or PhantomJS, just browserEnv()
and tape
. this.$router
is actually undefined in the tests.
from avoriaz.
Would you be able to post a minimal reproduction of the test and component?
from avoriaz.
Sorry I haven't had time to get back into this. I'm definitely having a vue-router related problem. I'm also unable to stub $route
. I don't have this problem with any other global variable name. I can call it route
and it works.
As far as I know, I'm not installing vue-router
as the only files that are compiled are test files. However it's possible that is happening, but the result of wrapper.vm.$route
and wrapper.vm.$router
is that they are undefined.
from avoriaz.
Bah, I just realized I am installing the router at some point in the testing because I have tests that test the router and I'm using tape, so the environment is not entirely reset between tests.
I'll have to play with this a bit more. I wonder if Avoriaz could isolate itself from the global Vue
but I'm guessing that would be hard.
from avoriaz.
Ok I've ensured I don't install Router
now I get errors about router-link
not being registered.
from avoriaz.
@chrisnicola what other issues?
from avoriaz.
@eddyerburgh do you have that guide written o maybe just drop a couple lines in here to help unblock us. THANKS!
from avoriaz.
This is a guide for vue-test-utils but it's the same concepts — https://vue-test-utils.vuejs.org/en/guides/using-with-vue-router.html
from avoriaz.
Related Issues (20)
- External JS files "not defined" HOT 1
- Can't get input value based on v-model HOT 2
- Migrating from Avoriaz to vue-test-utils HOT 1
- Testing props being passed to child components on mount HOT 2
- Test fails when trying to trigger click inside <router-view></router-view> HOT 1
- hasAttribute docs seem to be outdated HOT 1
- Returning undefined on wrapper.html() for a component with jade and vuex
- Tests disregard disabled attribute HOT 3
- How can I use shallow() for a component wrapped in a function within a class HOT 1
- Trigger not working with click
- Make children select work as it should HOT 1
- data() returns empty object HOT 2
- Trigger mouseover/mouseleave etc
- Is this project deprecated in favor of vue-test-utils now? HOT 2
- Scoped slots (slot-scope) issues HOT 3
- Suppress logged warning on calls to propsData() HOT 1
- vue-test-utils 1.0.0-beta.11 setData Error HOT 1
- vue-test-utils 1.0.0-beta.16 setData Error
- Can't find nested component with neither '.find' nor '.first' wrapper methods HOT 3
- How do you ensure a global is being set to child components from mount? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avoriaz.