Conversation
## Because - Four fxa-shared DB integration suites flaked on the CI job "Integration Test - Libraries (PR)". - Their `before()` hook calls `testDatabaseSetup`. That drops and recreates the test database and runs about 30 SQL schema files, so it can pass mocha's default 2000 ms timeout. - When the hook timed out, `knex` was never assigned. The `after()` hook then threw "Cannot read properties of undefined (reading 'destroy')", which hid the real failure. ## This pull request - Gives the `before()` hook in each of the four specs a 20 second timeout. The callback is now `function ()` so it can call `this.timeout(20000)`. - Changes `after()` to `await knex?.destroy()` so a failed setup reports only its own error. - Touches `auth/index.spec.ts`, `auth/prune-token.spec.ts`, `auth/sent-emails.spec.ts` and `profile/index.spec.ts` under `packages/fxa-shared/test/db/models/`. ## Issue that this pull request solves Closes: FXA-14596
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused test-only changes correctly address slow setup and prevent teardown from masking setup failures.
Review effort: Balanced
Findings: None
What changed in this PR
Stabilizes four fxa-shared database integration suites and preserves the original setup failure.
Changes:
- Raises database setup hook timeouts to 20 seconds.
- Makes teardown safe when setup fails before assigning
knex.
| File | Description |
|---|---|
auth/index.spec.ts |
Hardens auth integration setup and teardown. |
auth/prune-token.spec.ts |
Hardens token-pruning integration setup and teardown. |
auth/sent-emails.spec.ts |
Hardens sent-email integration setup and teardown. |
profile/index.spec.ts |
Hardens profile integration setup and teardown. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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
before()hook callstestDatabaseSetup. That drops and recreates the test database and runs about 30 SQL schema files, so it can pass mocha's default 2000 ms timeout.knexwas never assigned. Theafter()hook then threw "Cannot read properties of undefined (reading 'destroy')", which hid the real failure.This pull request
before()hook in each of the four specs a 20 second timeout. The callback is nowfunction ()so it can callthis.timeout(20000).after()toawait knex?.destroy()so a failed setup reports only its own error.auth/index.spec.ts,auth/prune-token.spec.ts,auth/sent-emails.spec.tsandprofile/index.spec.tsunderpackages/fxa-shared/test/db/models/.Issue that this pull request solves
Closes: FXA-14596
Checklist
Put an
xin the boxes that applyHow to review (Optional)
before()andafter()hooks in the four spec files.Screenshots (Optional)
Other information (Optional)
npx tsc -p packages/fxa-shared/tsconfig.json --noEmitandnpx nx lint fxa-sharedboth exit 0.