Files
api/web/__test__/setup.ts
Michael Datelle 03be042410 test: create tests for stores (#1338)
This gets the original 3 component tests refactored to better follow the
Vue Testing Library philosophy and test behavior. This also adds a new
test file for the server store. Additional batches of tests will be
added in proceeding PR's.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Chores**  
- Streamlined internal code organization and improved maintenance
through refined import structures and cleanup of redundant files.

- **Tests**  
- Expanded and restructured automated tests across core components,
including new test files for `Auth`, `DownloadApiLogs`, and `KeyActions`
to ensure robust behavior.
- Enhanced test configuration and mock implementations for a more
reliable, consistent testing environment.
- Introduced best practices for testing Vue components and Pinia stores.

These updates optimize performance and stability behind the scenes
without altering the end-user experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mdatelle <mike@datelle.net>
2025-04-09 11:57:11 -04:00

41 lines
807 B
TypeScript

import { config } from '@vue/test-utils';
import { createTestingPinia } from '@pinia/testing';
import { afterAll, beforeAll, vi } from 'vitest';
// Import mocks
import './mocks/shared-callbacks.js';
import './mocks/ui-components.js';
import './mocks/stores/index.js';
import './mocks/services/index.js';
// Configure Vue Test Utils
config.global.plugins = [
createTestingPinia({
createSpy: vi.fn,
}),
// Simple mock for i18n
{
install: vi.fn(),
},
];
// Set a timeout for tests
vi.setConfig({
testTimeout: 10000,
hookTimeout: 10000,
});
// Mock fetch
globalThis.fetch = vi.fn(() =>
Promise.resolve({
ok: true,
json: () => Promise.resolve({}),
text: () => Promise.resolve(''),
} as Response)
);
// Global setup and cleanup
beforeAll(() => {});
afterAll(() => {});