test(element): migrate element-ng to vitest part 4#1709
test(element): migrate element-ng to vitest part 4#1709
Conversation
There was a problem hiding this comment.
Code Review
This pull request continues the migration of tests from Karma/Jasmine to Vitest. The changes primarily involve updating test files to use Vitest's mocking and timer APIs, and refactoring several test suites to align with modern Angular testing practices using signals and standalone component features. The configuration files are also updated to reflect the migration progress. The changes are generally good, but I have a couple of suggestions to improve code consistency and remove redundancy in the test setup, particularly regarding redundant change detection calls in async tests.
projects/element-ng/landing-page/login-basic/si-login-basic.component.spec.ts
Outdated
Show resolved
Hide resolved
| @@ -87,62 +115,61 @@ describe('SiLoginBasicComponent', () => { | |||
| passwordInput.dispatchEvent(new Event('input')); | |||
| fixture.detectChanges(); | |||
There was a problem hiding this comment.
In Angular async tests, avoid redundant fixture.detectChanges() calls after setting inputs when await fixture.whenStable() is already present, as whenStable() also triggers change detection. It's better to use await fixture.whenStable() here to trigger change detection and wait for async operations to complete, instead of fixture.detectChanges().
| fixture.detectChanges(); | |
| await fixture.whenStable(); |
References
- In Angular async tests, avoid redundant
fixture.detectChanges()calls after setting inputs whenawait fixture.whenStable()is already present, aswhenStable()also triggers change detection.
6a40609 to
cca0a6f
Compare
Documentation.
Examples.
Dashboards Demo.
Playwright report.
Coverage Reports: