Closed Weetbix closed 2 years ago
I've tried to work work out if this is a dual package hazard / alias
issue but I am not having much luck.
For example if I manually change the imports inside the node modules folder to the compat build, I get weird errors about import names and claims the module is CommonJS. I changed the import in my test file and in /node_modules/@vue/test-utils/dist/vue-test-utils.esm-bundler.mjs
to @vue/compat/dist/vue.runtime.esm-bundler.js
and I get:
SyntaxError: Named export 'BaseTransition' not found. The requested module '@vue/compat/dist/vue.runtime.esm-bundler.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@vue/compat/dist/vue.runtime.esm-bundler.js';
const { transformVNodeArgs, Transition, BaseTransition, defineComponent, h, TransitionGroup, Teleport, nextTick, setDevtoolsHook, shallowReactive, reactive, isRef, createApp, computed } = pkg;
Which is weird, because it should be an ES Module and it does export those names..
@Weetbix testing-library should import vue from the same source you import it. Try adding vue test utils to deps.inline
or enable deps.registerNodeLoader
, otherwise test utils will import Vue using Node resolution algorithm without looking at alias
.
Hi @sheremet-va
Indeed it works when inlined! Thank you!
Describe the bug
Reactivity does not seem to work when using the vue compat build.
For example all these tests will work with vue 3, but all will fail with @vue/compat:
Expected behavior All tests should pass when running in compat mode. The templates/output should update to reflect the new values.
Other
I raised this is
@vue/test-utils
here: https://github.com/vuejs/test-utils/issues/1665But these tests can be made to work in jest with the module name mapper: https://github.com/vuejs/test-utils/issues/1665#issuecomment-1211576808
I think this might be related to the dual package hazard issue raised here: https://github.com/vuejs/vue-test-utils/issues/1982#issuecomment-1201131222
Reproduction
Check out this repo on the
jh/vue-utils-version
branch: https://github.com/Weetbix/vue-compat-composition-api-bug-repo/tree/jh/vue-utils-versionRun
yarn test:vue3
to run in vue 3 and notice all tests pass.Run
yarn test:vue-compat
to run with the vue compat alias, notice all tests fail.System Info
Used Package Manager
yarn
Validations