Migrate survey-creator-core unit tests from jest to viTest#7657
Draft
andrewtelnov wants to merge 6 commits intomasterfrom
Draft
Migrate survey-creator-core unit tests from jest to viTest#7657andrewtelnov wants to merge 6 commits intomasterfrom
andrewtelnov wants to merge 6 commits intomasterfrom
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Co-authored-by: Copilot copilot@github.com