Coder Social home page Coder Social logo

Comments (14)

chrisnicola avatar chrisnicola commented on May 28, 2024 1

Yeah I'll try to get something together next week.

from avoriaz.

chrisnicola avatar chrisnicola commented on May 28, 2024 1

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.

eddyerburgh avatar eddyerburgh commented on May 28, 2024 1

I'll write a guide for this at some point

from avoriaz.

LoneRifle avatar LoneRifle commented on May 28, 2024 1

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.

eddyerburgh avatar eddyerburgh commented on May 28, 2024

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.

eddyerburgh avatar eddyerburgh commented on May 28, 2024

Accidentally closed (I'm on mobile) 🙃

from avoriaz.

chrisnicola avatar chrisnicola commented on May 28, 2024

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.

eddyerburgh avatar eddyerburgh commented on May 28, 2024

Would you be able to post a minimal reproduction of the test and component?

from avoriaz.

chrisnicola avatar chrisnicola commented on May 28, 2024

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.

chrisnicola avatar chrisnicola commented on May 28, 2024

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.

chrisnicola avatar chrisnicola commented on May 28, 2024

Ok I've ensured I don't install Router now I get errors about router-link not being registered.

from avoriaz.

signal-intrusion avatar signal-intrusion commented on May 28, 2024

@chrisnicola what other issues?

from avoriaz.

signal-intrusion avatar signal-intrusion commented on May 28, 2024

@eddyerburgh do you have that guide written o maybe just drop a couple lines in here to help unblock us. THANKS! 😄

from avoriaz.

eddyerburgh avatar eddyerburgh commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.