Skip to content

Commit 3bcabcd

Browse files
author
mdatelle
committed
test: add callbackAction tests and cleann up console outout in tests
1 parent be7d798 commit 3bcabcd

File tree

5 files changed

+430
-15
lines changed

5 files changed

+430
-15
lines changed

.cursor/rules/web-testing-rules.mdc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ alwaysApply: false
88
- This is a Nuxt.js app but we are testing with vitest outside of the Nuxt environment
99
- Nuxt is currently set to auto import so some vue files may need compute or ref imported
1010
- Use pnpm when running termical commands and stay within the web directory.
11-
- The directory for tests is located under `web/test`
11+
- The directory for tests is located under `web/test` when running test just run `pnpm test`
1212

1313
### Setup
1414
- Use `mount` from Vue Test Utils for component testing
@@ -125,6 +125,7 @@ describe('Your Store', () => {
125125
- Use `createPinia()` instead of `createTestingPinia()` for most cases
126126
- Only use `createTestingPinia` if you specifically need its testing features
127127
- Let stores initialize with their natural default state instead of forcing initial state
128+
- Do not mock the store we're actually testing in the test file. That's why we're using `createPinia()`
128129

129130
2. **Vue Reactivity**
130131
- Ensure Vue reactivity imports are added to original store files as they may be missing because Nuxt auto import was turned on

web/__test__/store/activationCode.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,24 @@ import { nextTick, ref } from 'vue';
66
import { createPinia, setActivePinia } from 'pinia';
77

88
import { ACTIVATION_CODE_MODAL_HIDDEN_STORAGE_KEY } from '~/consts';
9-
import { beforeEach, describe, expect, it, vi } from 'vitest';
9+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
1010

1111
import { useActivationCodeStore } from '~/store/activationCode';
1212

13+
// Mock console methods to suppress output
14+
const originalConsoleDebug = console.debug;
15+
const originalConsoleError = console.error;
16+
17+
beforeAll(() => {
18+
console.debug = vi.fn();
19+
console.error = vi.fn();
20+
});
21+
22+
afterAll(() => {
23+
console.debug = originalConsoleDebug;
24+
console.error = originalConsoleError;
25+
});
26+
1327
// Mock sessionStorage
1428
const mockStorage = new Map<string, string>();
1529
vi.stubGlobal('sessionStorage', {

0 commit comments

Comments
 (0)