diff --git a/package.json b/package.json
index 4863580f..71d04d74 100644
--- a/package.json
+++ b/package.json
@@ -18,9 +18,8 @@
"build": "npm run types && vite build && node scripts/replace-version.mjs",
"build:dist": "npm run build && node scripts/create-dist-file.mjs",
"test": "vitest run --run",
- "test:coverage": "npm run test -- --coverage",
- "test:ci": "npm run test:coverage -- --coverageReporters=clover --ci",
- "test:pretty": "npm run test:coverage -- --coverageReporters=html",
+ "test:watch": "vitest run --watch",
+ "test:ci": "npm run test -- --coverage",
"test:verbose": "npm run test -- --verbose"
},
"dependencies": {
diff --git a/test/__helpers__/setUpTest.ts b/test/__helpers__/setUpTest.ts
index ffaf7376..5d125c73 100644
--- a/test/__helpers__/setUpTest.ts
+++ b/test/__helpers__/setUpTest.ts
@@ -5,7 +5,11 @@ import type { ReactElement } from 'react';
export const setUpCanvas = (element: ReactElement) => {
const result = render(element);
const { container } = result;
- const getEvents = () => container.querySelector('canvas')?.getContext('2d')?.__getEvents(); // eslint-disable-line no-underscore-dangle
+ const getEvents = () => {
+ const context = container.querySelector('canvas')?.getContext('2d');
+ // @ts-expect-error __getEvents is set by vitest-canvas-mock
+ return context?.__getEvents(); // eslint-disable-line no-underscore-dangle
+ };
return { ...result, events: getEvents(), getEvents };
};
diff --git a/test/common/services/ImageDownloader.test.ts b/test/common/services/ImageDownloader.test.ts
index 304a54e9..b393ec98 100644
--- a/test/common/services/ImageDownloader.test.ts
+++ b/test/common/services/ImageDownloader.test.ts
@@ -9,7 +9,6 @@ describe('ImageDownloader', () => {
let imageDownloader: ImageDownloader;
beforeEach(() => {
- vi.clearAllMocks();
(global as any).URL = { createObjectURL: () => '' };
imageDownloader = new ImageDownloader(httpClient, windowMock);
diff --git a/test/tags/TagsTable.test.tsx b/test/tags/TagsTable.test.tsx
index d804e264..ee146aeb 100644
--- a/test/tags/TagsTable.test.tsx
+++ b/test/tags/TagsTable.test.tsx
@@ -26,10 +26,6 @@ describe('', () => {
);
};
- afterEach(() => {
- vi.clearAllMocks();
- });
-
it('renders empty result if there are no tags', () => {
setUp();
diff --git a/test/utils/services/ColorGenerator.test.ts b/test/utils/services/ColorGenerator.test.ts
index 6b2dcd4c..dc0d8a44 100644
--- a/test/utils/services/ColorGenerator.test.ts
+++ b/test/utils/services/ColorGenerator.test.ts
@@ -7,11 +7,10 @@ describe('ColorGenerator', () => {
let colorGenerator: ColorGenerator;
const storageMock = fromPartial({
set: vi.fn(),
- get: vi.fn(),
+ get: vi.fn().mockImplementation(() => undefined),
});
beforeEach(() => {
- vi.clearAllMocks();
colorGenerator = new ColorGenerator(storageMock);
});
diff --git a/test/utils/services/LocalStorage.test.ts b/test/utils/services/LocalStorage.test.ts
index c8b94b6a..c3e44066 100644
--- a/test/utils/services/LocalStorage.test.ts
+++ b/test/utils/services/LocalStorage.test.ts
@@ -8,7 +8,6 @@ describe('LocalStorage', () => {
let storage: LocalStorage;
beforeEach(() => {
- vi.clearAllMocks();
storage = new LocalStorage(localStorageMock);
});