Skip to content

test: migrate from Web Test Runner to Vitest#21

Merged
cristinecula merged 6 commits intomainfrom
feature/neo-927-migrate-cosmoz-queue-tests-from-wtr-to-vitest
Feb 7, 2026
Merged

test: migrate from Web Test Runner to Vitest#21
cristinecula merged 6 commits intomainfrom
feature/neo-927-migrate-cosmoz-queue-tests-from-wtr-to-vitest

Conversation

@cristinecula
Copy link
Contributor

Summary

  • Replace WTR with Vitest for test infrastructure
  • Add dual project setup: unit tests (jsdom) and storybook tests (browser)
  • Migrate unit tests (fetch, path) to Vitest syntax with vi.* mocks
  • Convert UI tests (render, item-click, use-pref) to Storybook interaction tests
  • Add @storybook/addon-vitest integration for browser-based testing

Changes

Infrastructure

  • Created vitest.config.ts with two projects:
    • unit: jsdom environment for pure logic tests
    • storybook: browser mode with Playwright for UI tests
  • Updated .storybook/main.js to include @storybook/addon-vitest
  • Added .storybook/vitest.setup.ts for Storybook project annotations
  • Updated package.json scripts: test, test:unit, test:storybook, test:watch

Dependencies

  • Added: vitest, jsdom, @vitest/browser, @vitest/browser-playwright, @storybook/addon-vitest, playwright
  • Removed: sinon, @open-wc/testing, @open-wc/testing-helpers, @web/test-runner-playwright, @types/mocha, @neovici/testing, shadow-dom-testing-library

Tests

  • Unit tests: Converted fetch.test.ts and path.test.ts from Mocha/Chai/sinon to Vitest
  • Storybook tests: Migrated render, item-click, and use-pref tests to Storybook interaction tests

Test Results

All 41 tests pass:

  • Unit: 30 tests (path: 23, fetch: 7)
  • Storybook: 11 tests (component: 2, render: 4, item-click: 3, use-pref: 2)

NEO-927

- Replace WTR with Vitest for test infrastructure
- Add dual project setup: unit tests (jsdom) and storybook tests (browser)
- Migrate unit tests (fetch, path) to Vitest syntax with vi.* mocks
- Convert UI tests (render, item-click, use-pref) to Storybook interaction tests
- Add @storybook/addon-vitest integration for browser-based testing
- Update package.json scripts: test, test:unit, test:storybook, test:watch

NEO-927
@cristinecula cristinecula force-pushed the feature/neo-927-migrate-cosmoz-queue-tests-from-wtr-to-vitest branch from a0c3b6b to 1ddedec Compare February 6, 2026 11:28
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-02-07 17:15 UTC

- Add @types/react for Storybook type definitions
- Add skipLibCheck to tsconfig.json for Storybook type compatibility
- Fix unused 'within' import in render.stories.ts
- Fix window type casts in use-pref.stories.ts
- Create stories/helpers/render-hook.ts utility for testing Pion hooks
- Use Storybook args pattern in render.stories.ts instead of window globals
- Simplify use-pref.stories.ts using renderHook utility
- Remove all window global usage from story tests
@cristinecula cristinecula self-assigned this Feb 6, 2026
@cristinecula cristinecula marked this pull request as ready for review February 6, 2026 13:37
Replace local stories/helpers/render-hook.ts with @Neovici/testing@2.2.0
which now provides the same renderHook functionality for Pion hooks.
@cristinecula
Copy link
Contributor Author

@megheaiulian I removed the custom renderHook

@cristinecula cristinecula added the enhancement New feature or request label Feb 6, 2026
- Add HTML snapshots to RenderNavTest, RenderNavWithCallbacks, and RenderPaginationTest
- Use vitest expect for snapshot assertions (storybook/test uses Chai which lacks snapshot support)
- Snapshots capture DOM structure before user interactions
@cristinecula cristinecula force-pushed the feature/neo-927-migrate-cosmoz-queue-tests-from-wtr-to-vitest branch from 114fc09 to 5ef94aa Compare February 6, 2026 23:30
Move snapshot assertions out of story play functions to avoid
vitest expect being bundled into the deployed Storybook UI,
which caused 'Cannot read properties of undefined' errors.

The interaction tests remain and provide sufficient coverage.
@cristinecula cristinecula merged commit e450b24 into main Feb 7, 2026
3 checks passed
@megheaiulian megheaiulian deleted the feature/neo-927-migrate-cosmoz-queue-tests-from-wtr-to-vitest branch February 9, 2026 07:18
@github-actions
Copy link

🎉 This PR is included in version 1.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants