Skip to content

Add unit tests for uncovered modules#76

Open
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775672983-add-unit-tests
Open

Add unit tests for uncovered modules#76
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1775672983-add-unit-tests

Conversation

@staging-devin-ai-integration
Copy link
Copy Markdown

Summary

Adds comprehensive unit tests for previously uncovered modules, bringing the test count from 6 to 84. New test files cover:

  • runtime.test.ts (30 tests): createRuntimeTw proxy — basic classes, chained classes, underscore-to-hyphen conversion, $ to @// conversion, variant modifiers (hover, md, dark, nested), important(), raw(), variant(), arbitrary values, slash-separated values, typewind_id symbol, Symbol.toPrimitive/toString/valueOf, string property delegation (length, includes, split), getPrototypeOf trap, complex multi-variant combinations.

  • cn.test.ts (10 tests): cn() utility — tailwind-merge conflict resolution, falsy values, empty calls, arrays, conditional classes, object syntax, typewind proxy integration via typewind_id, mixed inputs.

  • evaluate.test.ts (19 tests): createTw with live tailwind context — mirrors runtime tests but exercises the evaluate module's candidateRuleMap/variantMap-based proxy (classes, variants, important, raw, variant helper, arbitrary values, symbol access, complex expressions). Uses jest.isolateModules to avoid cross-test module cache contamination.

  • utils.test.ts (7 tests): loadConfig (default config shape) and createTypewindContext (returns Map-based candidateRuleMap/variantMap with standard Tailwind utilities and variants, throws on missing config).

  • typewindTransforms.test.ts (2 tests): Verifies the typewindTransforms export shape (tsx/ts/jsx/js keys).

  • transform.test.ts (4 new tests added): Edge cases — no-tw passthrough, multiple tw expressions, js/jsx extension handling.

Also updated jest.config.js to use explicit ts-jest configuration with esModuleInterop: true, enabling direct source file imports in tests.

Review & Testing Checklist for Human

  • Run npm test and verify all 84 tests pass
  • Confirm the jest.config.js change (switching from preset: 'ts-jest' to explicit transform config with esModuleInterop) doesn't affect any other tooling in your workflow
  • Spot-check that the new snapshot entries in transform.test.ts.snap look correct for the added edge case tests

Notes

  • The evaluate.test.ts uses jest.isolateModules for each test to avoid the top-level createTypewindContext() call in evaluate.ts from caching a single tailwind config across test runs.
  • All test files use __dirname-based paths instead of process.cwd() to be resilient to cross-file cwd changes from other test suites.
  • The typewindTransforms.test.ts intentionally only tests the export shape (not actual transforms) to avoid caching the dist evaluate module with a config that lacks plugins needed by other fixture tests (e.g., @tailwindcss/container-queries).

Link to Devin session: https://staging.itsdev.in/sessions/f530a193b53f4c1192e5d1eb7bb7f27e
Requested by: @Mokshit06

…ypewindTransforms

- runtime.test.ts: Tests for createRuntimeTw proxy (classes, variants, important, raw, variant helper, arbitrary values, string delegation, Symbol.toPrimitive, complex combinations)
- cn.test.ts: Tests for cn() utility (tailwind merge, falsy values, arrays, object syntax, typewind proxy integration)
- evaluate.test.ts: Tests for createTw with tailwind context (classes, variants, important, raw, arbitrary values, complex expressions)
- utils.test.ts: Tests for loadConfig and createTypewindContext (config shape, candidateRuleMap, variantMap, error on missing config)
- typewindTransforms.test.ts: Tests for typewindTransforms export shape
- transform.test.ts: Added edge case tests (no-tw passthrough, multiple expressions, js/jsx extensions)
- jest.config.js: Updated to use explicit ts-jest config with esModuleInterop for source imports

Co-Authored-By: mokshitjain2006+04081@gmail.com <mokshitjain2006@gmail.com>
@staging-devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
typewind Error Error Apr 8, 2026 6:41pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants