Skip to content

Commit 5cb192d

Browse files
committed
test(auth): Mock oauth/token module in token exchange unit test
Because: * token.verify() was not mocked in two token exchange tests * Each jest.resetModules() creates a fresh OauthDB singleton that opens real MySQL/Redis connections; the second instantiation hangs past 10s in CI, causing an intermittent timeout * Example failure: https://app.circleci.com/pipelines/github/mozilla/fxa/68720/workflow s/fd17ddcd-5541-49fe-90c2-28cb3bdd86c7/jobs/661401 This commit: * Adds jest.doMock('../../oauth/token', ...) to both token exchange tests so token.verify() never hits real infrastructure in unit tests
1 parent 62e0d5b commit 5cb192d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/fxa-auth-server/lib/routes/oauth/token.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ describe('/oauth/token POST', () => {
745745
jest.doMock('../utils/oauth', () => ({
746746
newTokenNotification: newTokenNotificationStub,
747747
}));
748+
jest.doMock('../../oauth/token', () => ({
749+
verify: sinon.stub().resolves({ user: UID }),
750+
}));
748751
const routes = require('./token')({
749752
...tokenRoutesArgMocks,
750753
db: {
@@ -828,6 +831,9 @@ describe('/oauth/token POST', () => {
828831
jest.doMock('../utils/oauth', () => ({
829832
newTokenNotification: newTokenNotificationStub,
830833
}));
834+
jest.doMock('../../oauth/token', () => ({
835+
verify: sinon.stub().resolves({ user: UID }),
836+
}));
831837
const routes = require('./token')({
832838
...tokenRoutesArgMocks,
833839
db: {

0 commit comments

Comments
 (0)