diff --git a/src/web/components/form/__tests__/multiselect.jsx b/src/web/components/form/__tests__/multiselect.jsx index 6349051ce2..59df248e71 100644 --- a/src/web/components/form/__tests__/multiselect.jsx +++ b/src/web/components/form/__tests__/multiselect.jsx @@ -18,10 +18,11 @@ import {describe, test, expect, testing} from '@gsa/testing'; -import {render, screen, userEvent} from 'web/utils/testing'; +import {render, screen} from 'web/utils/testing'; import { changeSelectInput, + clickElement, getMultiSelectElement, getSelectElement, getSelectItemElements, @@ -118,7 +119,7 @@ describe('MultiSelect tests', () => { const domItems = getSelectItemElements(); expect(domItems.length).toEqual(2); - await userEvent.click(domItems[1]); + await clickElement(domItems[1]); expect(onChange).toHaveBeenCalledWith(['foo'], undefined); }); @@ -144,7 +145,7 @@ describe('MultiSelect tests', () => { const domItems = getSelectItemElements(); expect(domItems.length).toEqual(2); - await userEvent.click(domItems[0]); + await clickElement(domItems[0]); expect(onChange).toHaveBeenCalledWith(['bar'], 'abc'); }); @@ -235,7 +236,7 @@ describe('MultiSelect tests', () => { expect(selectedItems.length).toEqual(2); const deleteIcon = selectedItems[0].querySelector('button'); - await userEvent.click(deleteIcon); + await clickElement(deleteIcon); expect(onChange).toHaveBeenCalledWith(['foo'], undefined); }); diff --git a/vite.config.ts b/vite.config.ts index 0907b326fa..f1d6c9ce84 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,7 +10,12 @@ const projectRootDir = path.resolve(__dirname); // https://vitejs.dev/config/ export default defineConfig({ - define: {global: 'window'}, + define: { + global: 'window', + // avoid "You are loading @emotion/react when it is already loaded" warnings during tests + // https://github.com/emotion-js/emotion/discussions/2795#discussioncomment-7885638 + vi: {}, + }, plugins: [ react({include: /\.(mdx|js|jsx|ts|tsx)$/}), legacy(),