Skip to content

test: Correct source maps for test failure reporting #9109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dlarocque
Copy link
Contributor

@dlarocque dlarocque commented Jun 19, 2025

When running browser tests with Karma, failed assertions would produce stack traces pointing to line numbers within the final webpack bundle (e.g., chat.test.3891121195.js:26044:55), rather than the source. This made it difficult and time-consuming to trace the failure back to the original source TypeScript file.

Cause:

  1. Compilation: .ts compiled to .js, and source maps are generated in .js.map files.
  2. Instrumentation: istanbul-instrument-loader injects code into the .js files to generate code coverage reports. Since lines were added to the .js files, the .js.map files are made inaccurate.

Fix:
The previous devtool: 'source-map' config is what instructs webpack to write source maps to a seperate .js.map file. By changing to devtool: 'inline-source-map', the source maps are embedded directly in the JS bundles we load into karma, so the source maps always reflect the state of the .js bundles.

New output:

FAILED TESTS:
  Chat Session
    Google AI gemini-2.0-flash
      ✖ startChat and sendMessage: text input, text output
        Chrome Headless 137.0.0.0 (Mac OS 10.15.7)
      AssertionError: expected 4 to equal 2

      + expected - actual

      -4
      +2

    at Context.<anonymous> (webpack://firebase/ai/integration/chat.test.ts:87:35 <- chat.test.3891121195.js:26044:55)

Old output:

FAILED TESTS:
  Chat Session
    Google AI gemini-2.0-flash
      ✖ startChat and sendMessage: text input, text output
        Chrome Headless 137.0.0.0 (Mac OS 10.15.7)
      AssertionError: expected 4 to equal 2

      + expected - actual

      -4
      +2

    at Context.<anonymous> (chat.test.3891121195.js:26044:55)

@dlarocque dlarocque requested review from DellaBitta and hsubox76 June 19, 2025 21:15
@dlarocque dlarocque requested a review from a team as a code owner June 19, 2025 21:15
@google-oss-bot
Copy link
Contributor

@google-oss-bot
Copy link
Contributor

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.

3 participants