Peekaboo/vitest.config.ts
codegen-sh[bot] 271814cc90 Update tests for Linux compatibility and resolve merge conflicts
 **Merge Conflicts Resolved**
- Merged latest changes from main branch
- Resolved conflicts in docs/spec.md by keeping comprehensive specification
- Added PEEKABOO_CLI_TIMEOUT environment variable documentation

🧪 **Test Suite Updates for Linux Compatibility**
- Added platform-specific test skipping for Swift-dependent tests
- Created tests/setup.ts for global test configuration
- Updated vitest.config.ts with platform detection
- Modified integration tests to skip on non-macOS platforms:
  - tests/integration/peekaboo-cli-integration.test.ts
  - tests/integration/image-tool.test.ts
  - tests/integration/analyze-tool.test.ts

📦 **New Test Scripts**
- `npm run test:unit` - Run only unit tests (any platform)
- `npm run test:typescript` - Run TypeScript tests, skip Swift (Linux-friendly)
- `npm run test:typescript:watch` - Watch mode for TypeScript-only tests

🌍 **Platform Support**
- **macOS**: All tests run (unit + integration + Swift)
- **Linux/CI**: Only TypeScript tests run (Swift tests auto-skipped)
- **Environment Variables**:
  - `SKIP_SWIFT_TESTS=true` - Force skip Swift tests
  - `CI=true` - Auto-skip Swift tests in CI

📚 **Documentation Updates**
- Added comprehensive testing section to README.md
- Documented platform-specific test behavior
- Added environment variable documentation for test control

This allows the TypeScript parts of Peekaboo to be tested on Linux while maintaining full test coverage on macOS.
2025-06-08 06:03:49 +00:00

57 lines
1.7 KiB
TypeScript

import { defineConfig } from "vitest/config";
// Helper function to determine if Swift binary is available
const isSwiftBinaryAvailable = () => {
// On macOS, we expect the Swift binary to be available
// On other platforms (like Linux), we skip Swift-dependent tests
return process.platform === "darwin";
};
export default defineConfig({
test: {
globals: true,
environment: "node",
include: [
"**/tests/unit/**/*.test.ts",
// Include all integration tests
"**/tests/integration/**/*.test.ts",
// Only include E2E tests if running on macOS and not in CI
...(process.platform === "darwin" && !process.env.CI
? ["peekaboo-cli/tests/e2e/**/*.test.ts"]
: []
),
],
exclude: [
"**/node_modules/**",
"**/dist/**",
// Exclude E2E tests in CI or non-macOS environments
...(process.platform !== "darwin" || process.env.CI
? ["peekaboo-cli/tests/e2e/**/*.test.ts"]
: []
),
],
// Set reasonable timeouts to prevent hanging
testTimeout: 60000, // 60 seconds for individual tests
hookTimeout: 30000, // 30 seconds for setup/teardown hooks
coverage: {
provider: "v8",
reporter: ["text", "lcov", "html"],
reportsDirectory: "./coverage",
include: ["src/**/*.ts"],
exclude: [
"src/**/*.d.ts",
"src/index.ts", // Assuming this is the main entry point
],
},
// Global setup for platform-specific test skipping
setupFiles: ["./tests/setup.ts"],
// alias: {
// '^(\.{1,2}/.*)\.js$': '$1',
// },
},
// resolve: {
// alias: [
// { find: /^(\..*)\.js$/, replacement: '$1' },
// ],
// },
});