I am currently utilizing Bootstrap-Vue ^2.23.1
along with Vuejs and vue/compat ^3.2.45
, and my testing library is jest ^29.3.1
.
However, when I include the BootstrapVue plugin in my tests, it triggers the following error:
TypeError: Cannot read properties of undefined (reading '$bvConfig')
I have attempted using @vue/test-utils
and @testing-library/vue
without success. It seems likely that the issue is related to BV lacking proper support for Vue 3. Is there a workaround to resolve this error?
@vue/test-utils
:
test("component is visible: ", () => {
const wrapper = mount(
AccountingTable,
{
global: { plugins: [pinia, i18n, BootstrapVue] },
},
);
expect(wrapper.isVisible()).toBeTruthy();
});
@testing-library/vue
:
test("component is visible: ", () => {
const wrapper = render(
AccountingTable,
{
global: { plugins: [pinia, i18n, BootstrapVue] },
},
);
expect(wrapper.isVisible()).toBeTruthy();
});
Here is my jest configuration:
/** @type {import('jest).Config} */
module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom",
testEnvironmentOptions: {
customExportConditions: ["node", "node-addons"],
},
testMatch: ["**/**/*.test.ts"],
verbose: true,
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/mocks/file.mock.js',
},
transform: {
"^.+\\.vue$": "@vue/vue3-jest",
},
};