v4: TypeError: Theme__default.default.setPreset is not a function
when configuring theme configuration using definePreset
in vitest tests
#5689
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
Describe the bug
When configuring the
PrimeVue
Plugin for tests invitest
usingconfig.global.plugins
like this:...it's not possible to set a theme that is created using
definePreset
as it throws the following error when executing the tests:Sidenote:
If you omit the
PrimeVue
configuration object completely in theconfig.global.plugins
(just includePrimeVue
without options there) like this:...you will receive a lot of Vue warnings when executing tests like this:
Reproducer
https://stackblitz.com/edit/primevue-create-vue-typescript-issue-template-2u1dct?file=src%2FApp.vue
PrimeVue version
4.0.0-beta.2
Vue version
3.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
n/a
Steps to reproduce the behavior
npm test
in the terminal to "execute" the testThis shows the error.
definePreset(...)
row and thetheme.preset
propertynpm test
againNow the error does no longer appear and the test executes (actually it fails with a
document is not defined
error but that's probably caused by stackblitz - when executing it in a local project on a real machine, it works).Background info:
When trying to debug into this, I guess this has something to do with the
cjs.js
files being used when executing vitest but I am not sure.It seems that
Theme__default["default"].setPreset(newPreset);
is being called inprimevue/themes/actions/index.cjs.js
l13 andTheme__default["default"]
does not have asetPreset()
defined.Expected behavior
It's possible to use the same
PrimeVue
vue plugin options (= the same theme configuration) for vitest tests as used for the "production" app.The text was updated successfully, but these errors were encountered: