-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Testing with inject-loader does not work out of the box. #947
Comments
We will suggest a different solution for mocking during tests after more investigation. |
Thanks @yyx990803 - isn't esModules an option in vue-loader that can be set to false (or you can use the babel workaround I mentioned, which seems to be used when Jest is selected.) I'm happy to do a PR to switch this on for mocha/chai so that the inject-loader approach noted on the vue-loader documentation works out of the box: https://vue-loader.vuejs.org/en/workflow/testing-with-mocks.html |
@yyx990803 Is there any replacement for inject-loader? or is there an option to enable using of inject-loader in vue-cli 3? |
@morningdew830 - you can work around it by using e.g. the test command should be: |
I actually made the jump to karma in the end because I needed some of the browser built-ins; but happy to do a PR to fix this with mocha if it's still an issue? It's all about this line:
|
Thanks for quick help! @thomasmichaelwallace This is the old test code that had been working with vue-loader v13.
The project is created by vue-cli 3.0.1. Any good idea? |
Hmm.
Give me a day (it's evening where I am!) I'll see if I can get my old
project with the fix working again with the latest version.
What you've got to do is change that usESModules to false in the resulting
webpack/vue-loader configuration.
…On Mon, 20 Aug 2018, 20:32 morningdew, ***@***.***> wrote:
Thanks for quick help! @thomasmichaelwallace
<https://github.com/thomasmichaelwallace>
Unfortunately, I just tried with the environment but still getting the
same error.
[image: image]
<https://user-images.githubusercontent.com/22661536/44362037-6054a100-a4f2-11e8-84d0-e387fa160b01.png>
This is the old test code that had been working with vue-loader v13.
// eslint-disable-next-line import/no-webpack-loader-syntax
const injector = require('inject-loader!@/store/modules/item')
Any good idea?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#947 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AB3UHTxEU4Es_59jWmKo4e9E50nOkUaIks5uSw6-gaJpZM4SeZhM>
.
|
Thanks again!
|
Interesting.
Do you still need the env flag with that too?
…On Mon, 20 Aug 2018, 20:49 morningdew, ***@***.***> wrote:
Thanks again!
I just updated the presets in the babel configuration so it worked.
--- babel.config.js ---
presets: [
***@***.***/app', {
polyfills: [
'es6.promise',
'es6.symbol'
]
}]
]
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#947 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AB3UHdRkIKSiTb0X_qor6XnAbMy9Xm-Eks5uSxLhgaJpZM4SeZhM>
.
|
no need, that env flag doesn't effect for me but I think it would be better if it works. |
@thomasmichaelwallace @morningdew830 : I had to add
|
Hello. Since |
I completely agree, I've just spent 30 min trying to make it work. All because of the example that you've mentioned |
Version
2.9.3
Steps to reproduce
What is expected?
The module injection function to be returned.
What is actually happening?
Test fails due to invalid configuration.
A workaround for this is to set the VUE_CLI_BABEL_TRANSPILE_MODULES flag while testing.
The text was updated successfully, but these errors were encountered: