Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(#119): allow vue-router creation through routes param from both jest and mocha #127

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

Merged
afontcu merged 2 commits into testing-library:master from agualis:master
Mar 17, 2020

Conversation

@agualis
Copy link
Contributor

@agualis agualis commented Mar 13, 2020

This code fixes issue.


if (routes) {
const VueRouter = require('vue-router')
const VueRouter = require('vue-router')||require('vue-router').default
Copy link
Contributor Author

@agualis agualis Mar 13, 2020
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix-code is ugly cause the problem is that in mocha unit tests we need to bundle the code with webpack (mocha-webpack) and that does not play well with using a require here.

The problem could be also solved with an async import (to follow ES6 notation) but that would probably make the code even uglier cause it would introduce async code.

Another workaround when using mocha, would be passing an already built router through router mounting option (instead of routes) but that cannot work be done with the current implementation.

Enabling this option for mocha users would be highly appreciated. Thanks for your awesome work!

Copy link
Member

afontcu commented Mar 15, 2020

Hi! Thanks for this! 😃

  • Is there a way to add some tests to make sure things are working as expected? I'm not well versed with mocha, but that would be great (right now CI pipeline is failing due to code coverage descending).

  • Should we do the same thing with Vuex?

Copy link

codecov bot commented Mar 17, 2020
edited
Loading

Codecov Report

Merging #127 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@
## master #127 +/- ##
=====================================
 Coverage 100% 100% 
=====================================
 Files 1 1 
 Lines 67 67 
 Branches 13 14 +1 
=====================================
 Hits 67 67
Impacted Files Coverage Δ
src/vue-testing-library.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29e37dd...47168ef. Read the comment docs.

Copy link
Contributor Author

agualis commented Mar 17, 2020
edited
Loading

Is there a way to add some tests to make sure things are working as expected? I'm not well versed with mocha, but that would be great (right now CI pipeline is failing due to code coverage descending).

Some mocha tests could be added but that would not affect the code coverage as mocha does not use jest runner.

However, I just commited a hacky jest test (vue-router-mocha.js) that exercises the added code to keep the same coverage ( not the most expressive test though, I know 😅)

Should we do the same thing with Vuex?

No, we don't need it because vuex is built/exported in a different way than vue-router so that require works out of the box with mocha.

Copy link
Member

afontcu commented Mar 17, 2020

Looks good! I'm willing to merge this 🎉. Yet, do you have an external repository or something where we could see the fix actually fixing the issue? I've never used mocha, so I just want to make sure mocha is 100% usable after this 😄

Copy link
Contributor Author

agualis commented Mar 17, 2020
edited
Loading

Yet, do you have an external repository or something where we could see the fix actually fixing the issue?

(削除) The repository pointing the issue (#119) reproduces the error with this mocha test (削除ここまで)

@afontcu If you replace vue-testing-library with the code in current PR, that test will ✅ 😊

UPDATE: I double checked that repo and It seems that I lied 😅 as the linked repo did not have a correct chai setup. I quickly fixed it in this fork.

Copy link
Contributor Author

agualis commented Mar 17, 2020

BTW, I prefer jest over mocha but it need to use it in a legacy project. I think that I could help to mimic vue-testing-library examples in mocha but I would suggest to do it in the official vue-testing-library repository so it's easier to find/maintain them.

Copy link
Member

@afontcu afontcu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's go with this! Since I won't be using mocha, feel free to keep submitting PRs if you run into similar issues 😄

Thanks for this!

agualis reacted with heart emoji agualis reacted with rocket emoji
@afontcu afontcu merged commit 58a4b5a into testing-library:master Mar 17, 2020
Copy link
Member

afontcu commented Mar 17, 2020

🎉 This PR is included in version 5.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@afontcu afontcu afontcu approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Vue router configuration not working with mocha-chai

2 participants

AltStyle によって変換されたページ (->オリジナル) /