chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Global setup utilities that run once before all tests.
|
||||
*
|
||||
* Use this for expensive setup that should only happen once.
|
||||
*/
|
||||
|
||||
import { vi } from 'vitest'
|
||||
|
||||
/**
|
||||
* Suppresses specific console warnings/errors during tests.
|
||||
*/
|
||||
export function suppressConsoleWarnings(patterns: RegExp[]): void {
|
||||
const originalWarn = console.warn
|
||||
const originalError = console.error
|
||||
|
||||
console.warn = (...args: any[]) => {
|
||||
const message = args.join(' ')
|
||||
if (patterns.some((pattern) => pattern.test(message))) {
|
||||
return
|
||||
}
|
||||
originalWarn.apply(console, args)
|
||||
}
|
||||
|
||||
console.error = (...args: any[]) => {
|
||||
const message = args.join(' ')
|
||||
if (patterns.some((pattern) => pattern.test(message))) {
|
||||
return
|
||||
}
|
||||
originalError.apply(console, args)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Common patterns to suppress in tests.
|
||||
*/
|
||||
export const COMMON_SUPPRESS_PATTERNS = [
|
||||
/Zustand.*persist middleware/i,
|
||||
/React does not recognize the.*prop/,
|
||||
/Warning: Invalid DOM property/,
|
||||
/act\(\) warning/,
|
||||
]
|
||||
|
||||
/**
|
||||
* Sets up global mocks for Node.js environment.
|
||||
*/
|
||||
export function setupNodeEnvironment(): void {
|
||||
// Mock window if not present
|
||||
if (typeof window === 'undefined') {
|
||||
vi.stubGlobal('window', {
|
||||
location: { href: 'http://localhost:3000' },
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
})
|
||||
}
|
||||
|
||||
// Mock document if not present
|
||||
if (typeof document === 'undefined') {
|
||||
vi.stubGlobal('document', {
|
||||
createElement: vi.fn(() => ({
|
||||
style: {},
|
||||
setAttribute: vi.fn(),
|
||||
appendChild: vi.fn(),
|
||||
})),
|
||||
body: { appendChild: vi.fn() },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up global mocks after tests.
|
||||
*/
|
||||
export function cleanupGlobalMocks(): void {
|
||||
vi.unstubAllGlobals()
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Shared Vitest setup file for the testing package.
|
||||
*
|
||||
* Import this in your vitest.config.ts to get common mocks and setup.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // vitest.config.ts
|
||||
* export default defineConfig({
|
||||
* test: {
|
||||
* setupFiles: ['@sim/testing/setup'],
|
||||
* },
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
|
||||
import { afterEach, beforeEach, vi } from 'vitest'
|
||||
import { setupGlobalFetchMock } from '../mocks/fetch.mock'
|
||||
import { createMockLogger } from '../mocks/logger.mock'
|
||||
import { clearStorageMocks, setupGlobalStorageMocks } from '../mocks/storage.mock'
|
||||
|
||||
// Setup global storage mocks
|
||||
setupGlobalStorageMocks()
|
||||
|
||||
// Setup global fetch mock with empty JSON response by default
|
||||
setupGlobalFetchMock({ json: {} })
|
||||
|
||||
// Clear mocks between tests
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
clearStorageMocks()
|
||||
})
|
||||
|
||||
// Export utilities for use in tests
|
||||
export { createMockLogger }
|
||||
export { setupGlobalStorageMocks, clearStorageMocks }
|
||||
export { mockFetchError, mockNextFetchResponse, setupGlobalFetchMock } from '../mocks/fetch.mock'
|
||||
Reference in New Issue
Block a user