chore: setup test environment#82
Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the 📝 WalkthroughWalkthroughAdds a repository-wide Vitest-based testing workflow: new test scripts, a Turbo "test" task, Husky pre-commit updated to run tests before linting, TypeScript excludes for tests, and a comprehensive generateDeepLink test suite with supporting test types and contributor docs updates. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer (git commit)
participant Husky as Husky pre-commit
participant PNPM as pnpm
participant Turbo as Turbo
participant Vitest as Vitest
participant Lint as lint-staged
rect rgb(230,245,255)
Dev->>Husky: git commit
Husky->>PNPM: run `pnpm test` (pre-commit)
PNPM->>Turbo: `turbo run test`
Turbo->>Vitest: invoke package tests
Vitest-->>Turbo: test result (pass/fail)
Turbo-->>PNPM: exit code
end
alt tests pass
PNPM->>Husky: success
Husky->>PNPM: run `pnpm exec lint-staged`
PNPM->>Lint: lint-staged checks
Lint-->>PNPM: lint result
PNPM-->>Husky: success
Husky-->>Dev: allow commit
else tests fail
PNPM-->>Husky: failure
Husky-->>Dev: block commit (tests failed)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @packages/core/package.json:
- Line 23: Add vitest to this package's devDependencies in
packages/core/package.json so the "test": "vitest run" script has an explicit
local dependency; use the same version range as the root workspace (or a
compatible one), add an entry "vitest": "<version>" under devDependencies, then
run your package manager install (npm/yarn/pnpm) to update node_modules and
lockfile.
🧹 Nitpick comments (3)
turbo.json (1)
16-18: Consider disabling cache for the test task.By default, Turbo will cache test results based on input hashes. This means if source files haven't changed, tests won't re-run. While this improves performance, it might hide test failures caused by external factors (environment, timing, etc.). Consider adding
"cache": falseif tests should always run, or carefully configure cache inputs.⚙️ Proposed configuration to disable caching
"test": { + "cache": false, "outputs": [] }Or, if you want to keep caching but ensure it's based on the right inputs:
"test": { + "dependsOn": ["^build"], "outputs": [] }.husky/pre-commit (1)
1-1: Consider adding tests to the CI pipeline and monitoring performance as test coverage grows.Currently, the project has minimal test coverage (one test file), so pre-commit performance impact is negligible. However, as the project matures, running the full test suite on every commit may slow the workflow. More importantly, tests should run in CI alongside the existing checks in
pr-checks.yml, rather than only at pre-commit. Once tests are integrated into the CI pipeline, you can either:
- Remove tests from pre-commit and rely on CI validation
- Keep pre-commit tests lightweight (e.g., affected tests only)
- Monitor commit times as test coverage grows and adjust as needed
packages/core/src/tests/index.test.ts (1)
202-204: Nice use of dynamic test generation!Using
Object.entries()to iterate over test cases is an elegant approach that automatically generates test suites for all platforms. This makes it easy to add new platforms—just add to thetestCasesobject.Consider adding edge case tests in future iterations, such as:
- Invalid URLs for each platform
- Malformed URLs
- URLs with special characters or encoding
- Missing path segments
This would strengthen the test coverage beyond happy paths.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
.husky/pre-commitpackage.jsonpackages/core/CONTRIBUTING.mdpackages/core/package.jsonpackages/core/src/tests/index.test.tspackages/core/src/tests/types.tspackages/core/tsconfig.jsontsconfig.jsonturbo.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-02T21:27:30.363Z
Learnt from: tanmoyPaul12
Repo: mdsaban/universal-app-opener PR: 0
File: :0-0
Timestamp: 2026-01-02T21:27:30.363Z
Learning: In the mdsaban/universal-app-opener repository, the Platform type in packages/core/src/types.ts already includes 'github' and 'twitch' platforms in the main branch.
Applied to files:
packages/core/src/tests/types.ts
🧬 Code graph analysis (1)
packages/core/src/tests/types.ts (1)
packages/core/src/types.ts (1)
Platform(1-18)
🔇 Additional comments (8)
tsconfig.json (1)
15-15: LGTM!The test file exclusion patterns are appropriate and follow standard practices for separating test files from production compilation.
package.json (2)
11-11: LGTM!The test script correctly delegates to Turbo's task runner, enabling coordinated test execution across the monorepo.
23-23: No action required. Vitest 4.0.16 is a valid release (published December 16, 2025) with no known security vulnerabilities. The critical CVE-2025-24964 affects only vitest ≤3.0.4 and does not impact this version.packages/core/CONTRIBUTING.md (1)
89-107: Excellent addition to the contributor guide!The test documentation is clear and provides a concrete example that matches the actual test structure in
packages/core/src/tests/index.test.ts. This will help contributors understand how to add test coverage for new platform handlers.packages/core/tsconfig.json (1)
12-12: LGTM! Proper test exclusion.Excluding test files from the TypeScript compilation output is the correct approach for production builds.
packages/core/src/tests/types.ts (1)
1-11: Well-designed test types!The type definitions provide strong typing for the test suite:
PlatformLinkcorrectly usesstring | nullfor iOS and Android deep links, accommodating platforms that may not have native app support.SocialLinksasRecord<Platform, PlatformLink[]>ensures compile-time verification that all platforms have test coverage.packages/core/src/tests/index.test.ts (2)
5-18: Clean test helper implementation!The
generateDeepLinkTesthelper function follows the DRY principle and provides good structure for generating platform-specific test suites. The assertions cover all critical fields (platform, webUrl, ios, android).
20-200: Comprehensive platform coverage!The test suite covers all 16 named platforms (discord, facebook, github, instagram, linkedin, pinterest, reddit, snapchat, spotify, substack, telegram, threads, twitch, whatsapp, youtube, zoom) plus the unknown case for a total of 17 platforms. The test data is well-organized and thorough with proper deep link handling across all platforms.
All tested platforms have corresponding handler implementations that are properly exported from
packages/core/src/platforms/index.ts, ensuring complete alignment between test coverage and actual handler implementations.
Title: Add Husky Pre-Commit Hook to Run Vitest Tests
Description:
This PR adds a pre-commit hook to ensure that all tests are run before code is committed, preventing accidental breaking changes. The setup uses Vitest for testing and Husky for Git hooks, with pnpm as the package manager.
Changes Included:
Vitest test script:
"test": "vitest run"topackage.jsonsopnpm testruns all tests.Husky pre-commit hook:
pnpm testbefore every commit.Documentation updates:
CONTRIBUTING.mdon creating tests.Benefits:
Testing:
pnpm testruns all Vitest test cases successfully.Closes #81
Summary by CodeRabbit
New Features
Tests
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.