-
Notifications
You must be signed in to change notification settings - Fork 14
Q: How to setup @vue/test-utils? #25
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
Comments
Cutted jest code:
|
Just updated config to see problem directly: |
Maybe: const wrapper = mount(SomeForm, { store: store.original, localVue }); |
This fix is helped, now I got another error (test suite is still failed to run):
Strange, but in VueApp.store.ts (which is seems not used in SomeForm.spec.ts) May be it is because of using standard Vuex getters, not createGetters. Similar issue: championswimmer/vuex-module-decorators#63 |
Also another test suite (SomeForm/store/actions.spec.ts) failed to run:
It seems context parameter in test (or actions) code should be changed but I don't understand how? |
Can't find any example of using direct-vuex actions with tests =( |
About getters same error.
After fix I have another errors, investigating... |
I have located problem with direct-vuex:
If I use classic actions, all is ok: SomeForm.spec.ts suite is runned & actions.spec.ts is runned. @paleo please check this by cloning project & |
When I execute
Is it the error I should see or another? |
Strange, you can remove lint from pretest by renaming in package.json scripts "pretest" to "pre-something-test".
No, you should see
and after commening / commenting out in actions, you should see
|
@paleo, 'getters' problem looks like code trying to get getters from root store instead of module substore. |
I see only one workaround: using mocks with classic Vuex for actions in test suites & direct-vuex actions for browser & type checking. |
Fyi, in this code: export const storeConf = {
namespaced: true as true,
actions: createActions(actions),
// getters: createGetters<IState>()(getters),
getters,
mutations: createMutations<IState>()(mutations),
state: defaultState,
// syntax recommendation https://itnext.io/use-a-vuex-store-with-typing-in-typescript-without-decorators-or-boilerplate-57732d175ff3
// but we declare type with const above
// state: defaultState as IState,
} as const;
export const modSomeForm = createModule(storeConf); … These functions provides autocompletion and typing in the implementation passed as a parameter. But if you declare first a variable then you pass it in these functions, they provide nothing. Additionally, |
I reproduced the error. But your code is complex and I haven't enough time to understand. Maybe the error is an effect of the cyclic dependency because of |
I have some fixes (not committed yet, it will be soon). |
It is ready viT-1/systemjs-ts-es6-vue@7ce884a |
Hi. Maybe |
@paleo Thank you, I'll try that. And If I can test actions without mocking, I'll closing the issue. |
@paleo Yes, it's working. In actions.ts just changed to
instead of
And I can remove standard actions mocking! |
related: #29 (comment) |
With node (jest)
|
Indeed, I forgot to export these new functions as properties of |
v 0.10.4 esm bundle is working, but ie11 (with SystemJS) is not: You can try my project on last commit |
@paleo, |
Just update in |
@paleo Sorry for wasting your time, thank you very much! |
I changed my code to use direct-vuex in actions, browser seems to work without errors, but when I run jest tests, test suite failed to run, cause of typing when I mount component with store
What am I doing wrong?
The text was updated successfully, but these errors were encountered: