Conversation
nshirley
reviewed
Mar 20, 2026
| expect(db.totpToken.callCount).toBe(1); | ||
|
|
||
| // emits correct metrics | ||
| expect(request.emitMetricsEvent.callCount).toBe(1); |
Contributor
There was a problem hiding this comment.
Obviously nothing to change, just noting that this is the opposite of the kind of tests I highlighted above 😅 . The test just says "should return false for invalid TOTP code" but then it has a bunch of other assertions
nshirley
reviewed
Mar 20, 2026
Contributor
There was a problem hiding this comment.
non-blocking, just curious why you removed this?
nshirley
approved these changes
Mar 20, 2026
Contributor
nshirley
left a comment
There was a problem hiding this comment.
Nothing blocking, just a few observations why checking out the tests!
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.
Because
test/local/, outside the co-located Jest pattern established forlib/**/*.spec.tsThis pull request
.spec.tsfiles:serverJWT.spec.ts— 5 tests,proxyquire→jest.doMock/jest.resetModulesrecovery-codes.spec.ts— 8 tests, merged assert pattern splittotp.spec.ts— 16 tests, TOTP generation viaotplibrecovery-key.spec.ts— 52 tests,proxyquire→jest.mockwith delegating function patternrecovery-phone.spec.ts— 34 tests, largest file (1075 lines), custom Glean mockschai.assert.*→expect().*,assert.isRejected→.rejects.toThrow(),assert.failguards →.rejects.*sinon.assert.*calls alongside Jest (established codebase pattern)Container.reset()inafterAllfor TypeDI cleanupParity Comparison
it()it()assert.isTrue(spy.calledOnceWith)split;try/catch→.rejects.toThrowassert.isDefinedremovedtry/catch→.rejects.toMatchObject;assert.failguards removedassert.failin.then(fail, err)patterns removedassert.isDefinedremoved;assert.isRejected→.rejects.toThrowIssue
Closes: https://mozilla-hub.atlassian.net/browse/FXA-12612
Checklist
Other Information
How to verify:
cd packages/fxa-auth-server NODE_ENV=dev npx jest --no-coverage lib/serverJWT.spec.ts lib/routes/recovery-codes.spec.ts lib/routes/totp.spec.ts lib/routes/recovery-key.spec.ts lib/routes/recovery-phone.spec.ts All 115 tests pass. The -36 assertion delta vs Mocha is entirely from removing redundant assert.isDefined guards before property access and collapsing try/catch + assert.fail into Jest-native .rejects patterns — no behavioral coverage was dropped.