Repository navigation
Teach testing with a stricter CI - #42
Merged
Merged
Conversation
CI's typecheck runs plain tsc against a root tsconfig with no files, so it checks nothing. CI never builds, and no job has a time limit. The e2e covers what the fake IntersectionObserver can't: real scrolling.
Lesson 09 said form.reset() only re-rendered the OnPush contact form because a signal write sat next to it. It renders on its own: controls keep touched and status in signals, and NgControlStatus reads them in its host bindings. The new spec resets the form with no other change and no detectChanges(), and the errors clear.
The root tsconfig has no files, so plain tsc --noEmit checked nothing. Typecheck the app and spec configs, run the production build (the only step that prerenders and enforces budgets), and give each job a time limit so a hung builder can't hold a runner for six hours.
The demo runs the real notBlank validator's cases in the page, with a switch that swaps in the whitespace bug lesson 08 fixed so exactly one test goes red.
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.
Eleventh lesson in my Angular guide: testing. The feature slice is a CI workflow that checks what actually ships.
What shipped
CI's typecheck checks real files. It ran
npx tsc --noEmitagainst a roottsconfig.jsonwith"files": []and only project references.tscdoesn't follow references, so it listed 0 source files and passed. With-p tsconfig.app.json, it lists 72.tsconfig.app.jsonandtsconfig.spec.json.CI runs the production build. It's the only step that prerenders every route and enforces the bundle budget.
Every job has
timeout-minutes. While working on change detection, I hit anng build/ng testthat finished its work and never exited. Without a limit, that holds a runner for GitHub's six-hour default.qualitygets 15 minutes ande2e-accessibilitygets 20.ci-workflow.spec.tspins all three. It's a fitness test over.github/workflows/ci.yml.e2e/lesson-nav.spec.ts. It covers the lesson nav from #41 in a real browser: jumping focuses the heading, and the highlight follows real scrolling. The unit specs can only drive a fakeIntersectionObserver.A correction to #40. That PR's comment on the contact form said
form.reset()only re-rendered the OnPush view because a signal write sat next to it. A test I wrote here to pin that claim passed without the signal write.NgControlStatusreads them in its host bindings (forms.mjs,AbstractControlStatus.isTouched).contact-app.spec.tsresets the form with no other change and nodetectChanges(), and the errors clear.Lesson 11: testing (
/thoughts/angular-11-testing).HttpTestingControllerwith fake timersRouterTestingHarnessandsetInputnotBlankvalidator's test cases in the page. A switch swaps in lesson 08's whitespace bug, and exactly one test goes red.Version and changelog. 1.4.10, with a matching changelog entry.
Commits
Verification
-ptypecheck, no build, no timeout onquality.on:block instead of the jobs. I saw that in the RED output and fixed it before committing.ng test: 66 files, 462 tests, exit 0.tsc --noEmitconfigs are clean. The e2e file typechecks withtsc --strict.testingwas already a tag). Initial bundle 394.92 kB.develop, so on this stacked branch that happens once the stack reaches develop.TO-DOs for this PR
npx playwright test e2e/lesson-nav.spec.tslocally before merging, and tune the 30% trigger band inscroll-spy.tsif the highlight lags.