Skip to content

Migrate survey-creator-core unit tests from jest to viTest#7657

Draft
andrewtelnov wants to merge 6 commits intomasterfrom
tests/vi-test-migration
Draft

Migrate survey-creator-core unit tests from jest to viTest#7657
andrewtelnov wants to merge 6 commits intomasterfrom
tests/vi-test-migration

Conversation

@andrewtelnov
Copy link
Copy Markdown
Member

Co-authored-by: Copilot copilot@github.com

andrewtelnov and others added 6 commits April 28, 2026 14:17
…omts

Co-authored-by: Copilot <copilot@github.com>
…tupDefaults

Phase 4 triage — make tests:vitest exit 0.

Three Vitest-only failures resolved:

1. presets-editable-properties.ts setupDefaults crashed with 'c.properties is
   not iterable' under Vitest. Root cause: ts-jest's es5 target compiled
   '[].push(...c.properties)' to '.apply(arr, c.properties)' which silently
   tolerates an undefined argument. Vitest/esbuild keeps the native spread,
   which throws on undefined. Hardened the loop to skip categories with no
   'properties' field. Verified Jest still passes.

2. tests/question-adorner.tests.ts 'expand/collapse animation options'
   expected '0px', received 'NaNpx'. Root cause: jsdom 29 returns
   boxSizing='content-box' and borderTopWidth='medium' for detached divs;
   survey-core's getVerticalDimensions does parseFloat on those keywords
   (NaN). Older jsdom under Jest returned empty strings, so the else
   branch produced '0px'. Added a getComputedStyle wrapper in
   tests/vitest.setup.ts that coerces empty/keyword padding/margin/border
   widths to '0px'.

Run summary after fix: 76 files passed, 1941 tests passed, 4 skipped.
Exit code 0. The 7 'Errors' shown are pre-existing stray-timer rejections
from src/ that 'dangerouslyIgnoreUnhandledErrors: true' (already configured)
intentionally ignores per Vitest docs.
- npm scripts: 'test', 'test:cov', 'test:watch' now invoke Vitest. Remove
  redundant 'test:vitest*' scripts. Add 'test:core' / 'test:presets' (and
  watch/cov variants) backed by Vitest project filters.
- Remove jest, ts-jest, @types/jest, jest-environment-jsdom, jest-junit from
  devDependencies. jest-canvas-mock and jsdom remain (used by Vitest setup).
- Delete jest.config.js, jest.ui-preset-editor.config.js, tests/jest.setup.js,
  tests/empty-module.js (Vitest config + setup replace these).

Final smoke: npm test (Vitest) -> 76 files, 1941 tests pass, exit 0.
CI/Azure DevOps .yml updates are out of scope (handled separately by team).
Vitest 4 declares peer @types/node >=20, but the package pins
@types/node@7.0.4 (also required transitively by ts-node@3.3.0). Local
installs already passed --legacy-peer-deps; the Azure pipeline's npm
install does not, causing ERESOLVE failures.

Adding legacy-peer-deps=true at the package level matches the local
workflow and unblocks CI without bumping @types/node (which would touch
unrelated transitive constraints).
@andrewtelnov andrewtelnov marked this pull request as draft April 30, 2026 06:33
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.

1 participant