Skip to content

Conversation

@vbudhram
Copy link
Contributor

@vbudhram vbudhram commented Feb 5, 2026

Because

  • The existing Mocha-based integration tests cannot be easily parallelized and lack modern test infrastructure (global
    setup/teardown, dynamic port allocation)
  • Migrating to Jest enables better test isolation, describe.each for protocol version matrix testing, and a foundation for migrating remaining integration tests

This pull request

  • Adds Jest integration test infrastructure that spawns the auth server as a child process with dynamic port allocation
  • Adds global setup/teardown for mail_helper lifecycle management
  • Adds jest.integration.config.js with 120s timeout, integration-specific test matchers, and setup files
  • Migrates account_create_tests.js (62 tests) from Mocha to Jest, testing both V1 and V2 protocol versions via describe.each
  • Adds smoke.spec.ts to validate the test infrastructure itself
  • Adds test-integration-jest Nx target and CircleCI job for PR and tag workflows
  • Updates .mocharc.js to ignore *.spec.ts files so Mocha doesn't pick up Jest tests
  • Makes stripeHelper optional in deleteAccountIfUnverified to support running without Stripe credentials in test environments
  • Adds null-safety to log.js error method

Issue

Closes: https://mozilla-hub.atlassian.net/browse/FXA-12609

Checklist

  • My commit is GPG signed
  • Tests pass locally (if applicable)
  • Documentation updated (if applicable)
  • RTL rendering verified (if UI changed)

Other Information

How to test:

cd packages/fxa-auth-server
npx jest --config jest.integration.config.js

Requires local MySQL and infrastructure services running (yarn start infrastructure).

New dependencies: portfinder, esbuild-jest

Architecture decision: The auth server is spawned as a child process rather than imported directly due to ESM module compatibility issues with Jest's transform pipeline.

@vbudhram vbudhram requested a review from a team as a code owner February 5, 2026 18:20
// Generate auth keys (public-key.json, secret-key.json)
console.log('[Jest Global Setup] Checking/generating auth keys...');
try {
execSync(`node -r esbuild-register ${genKeysScript}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium test

This shell command depends on an uncontrolled
absolute path
.
// Generate OAuth keys (key.json, oldKey.json)
console.log('[Jest Global Setup] Checking/generating OAuth keys...');
try {
execSync(`node -r esbuild-register ${oauthGenKeysScript}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium test

This shell command depends on an uncontrolled
absolute path
.
@vbudhram vbudhram force-pushed the fxa-12609-v2 branch 4 times, most recently from a98d302 to 01cf5b9 Compare February 9, 2026 20:01
@vbudhram vbudhram changed the title Fxa 12609 v2 (WIP) feat(auth-server): Add Jest integration test infrastructure and migrate account_create tests Feb 9, 2026
@vbudhram vbudhram requested a review from nshirley February 9, 2026 20:10
@vbudhram vbudhram self-assigned this Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant