Skip to content

build: fail frontend-base package tests on unexpected console output - #2219

Merged
brian-smith-tcril merged 2 commits into
frontend-basefrom
bsmith/test-console-noise
Nov 10, 2026
Merged

brian-smith-tcril merged 2 commits into
frontend-basefrom
bsmith/test-console-noise

Conversation

@brian-smith-tcril

@brian-smith-tcril brian-smith-tcril commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The frontend-base package's test suite now fails any test that prints an unexpected console.warn or console.error, so every later port lands with a silent suite and the noise master's suite has accumulated (2,101 console blocks in one run) does not move across with the tests. The two react-router 6 future flag warnings, which belong to the shell's router (openedx/frontend-base#325), are silenced by name. No user-facing change; test tooling only.

Part of #1905. Resolves #2218. Stacked above #2217.

What changed

  • frontend-base/package.json, lockfile: jest-fail-on-console as a dev dependency.
  • frontend-base/src/setupTest.js: failOnConsole with a silenceMessage list, one regex per silenced message grouped under the URL of the issue that owns it; its only group is the two react-router flags.
  • A throwaway test warned once in the branch's first CI run so the test job showed the failure; it is squashed out of the branch. The PR lands as a rebase merge, two commits (decision 6).
  • .github/workflows/validate.yml: frontend-base joins master in the push branches, the bottom commit, added 2026-11-10 (decision 5).

Testing

In frontend-base/: npm test with the throwaway fails that one test with "Expected test not to call console.warn()" and passes the other two, the two router warnings no longer printing; without it, 2 tests pass at 100% lines with no console block; lint and build green. CI: run 1 red on the throwaway, run 2 green, recorded below.

Decisions

What was decided while building this layer; the mechanism and the inventory of master's noise are in #2218.

Full decision log

Decisions — fail frontend-base package tests on unexpected console output (#2218)

Decisions made while implementing. The mechanism, the inventory of
master's noise and the commit shape are in #2218's plan and are not
repeated.

  1. Silence, not allow. jest-fail-on-console offers allowMessage
    (the test passes, the message still prints) and silenceMessage (the
    test passes, nothing prints). The two react-router messages go through
    silenceMessage: the point of the layer is a silent suite, and a
    message that prints on every run is noise whether or not it fails.

  2. The silenced list names the two flags, not the warning family. A
    first cut matched the ⚠️ React Router Future Flag Warning prefix,
    which would also have swallowed a warning for any of the other six v7
    flags react-router 6.30 knows, none of which
    React Router v6 deprecation/future flag warnings frontend-base#325 covers. Each entry
    is one regex anchored on the prefix and the flag name in backticks, so
    a warning for another flag fails the test that triggers it.

  3. Shape of the list: inline under silenceMessage, grouped by issue
    URL, no prose comment.
    Written for the day it holds ten entries from
    several issues: a URL line above the patterns it owns, patterns as
    plain regex literals, the matcher a one-line some. Inline rather than
    a file-level constant because nothing else reads the list and the
    failOnConsole call is then the one block a reader opens for console
    handling; the per-call allocation of the array is not measurable.
    Code comments cite the issue by full URL, since GitHub's owner/repo#N
    shorthand only renders in GitHub markdown. A sentence explaining the
    list was dropped: the option name and the shape already say it.

  4. No muting convention in the setup file. The issue's draft had the
    "mock the console method in the test" rule written as a comment beside
    the hook; it restates what the library's failure message tells the
    developer at the moment it matters, so the rule lives in Fail frontend-base package tests on unexpected console output #2218 and the
    acceptance box for it was dropped. The jest config does not restore
    mocks automatically, so a test that mocks a console method restores it
    at its end.

Manual testing

Manual testing — fail frontend-base package tests on unexpected console output (#2218)

Test tooling only; nothing renders differently. The evidence is two CI
runs on #2219, in the fail-then-pass shape.

  1. The validate workflow runs on pushes to frontend-base. Added
    2026-11-10 as the bottom commit of this PR, Brian's call, after feat: scaffold the frontend-base package #2217
    merged and this PR's codecov/project status went red: "96.16%
    (-3.84%) compared to 2764e40". validate.yml ran on pushes to
    master and on every pull request; frontend-base.yml runs on pushes
    to frontend-base that touch frontend-base/. So the merge commit's
    Codecov report held one upload, the frontend-base flag (6 files, 9
    lines, 100%), while this PR's head held that plus the unflagged root
    suite (374 files, 6028 lines, 96.16%), and the project status
    (target: auto, threshold: 0% in codecov.yml) read a whole-repo
    number against a package-only one. feat: add the frontend-base route tree with stub pages, roles and provides #2221 and refactor: port the dates tab to frontend-base #2234 compare against
    the PR below each and pass; every PR into frontend-base would show
    this once the PR below it merged. With the branch in the push list,
    every merge into it uploads the root suite. GitHub reads the workflow
    file from the pushed commit, so the merge of this PR is the first such
    push and master's file is untouched; the list rides into master
    at the swap. Considered and not taken: a project status scoped with
    flags: [frontend-base] (Codecov docs, "Commit status", heading
    "flags": "the combined coverage from those flags will be reported"),
    which adds a passing package-only status but leaves the whole-repo
    one red, or with default: false drops it for master PRs too; no
    status key selects a PR's target branch.

  2. Two commits, landed by rebase merge. Decided 2026-11-10 with
    entry 5, Brian's call. The validate trigger and the console hook are
    separate facts for frontend-base's history, so the PR lands as a
    rebase merge rather than the squash a layer usually gets. The
    throwaway test and its removal, the branch's first two commits, are
    squashed into the hook commit beforehand, so neither the failing test
    nor its removal lands; the PR's first CI run, red on the throwaway,
    stays the evidence that the hook fails a test. The hook commit's
    package tree is unchanged by the squash.

Verify

  • Run 1, red — head 09afe9ba, commit 1 with the throwaway test.
    The frontend-base workflow's test job fails:
    FAIL src/console-noise.test.ts with "Expected test not to call
    console.warn()" and the printed unexpected; src/app.test.ts and
    src/Main.test.tsx pass; the job log contains no React Router
    future flag warning, so the two silenced messages are gone from the
    output as well as from the failures. codecov/project is red on
    this run, "96.15% (-0.01%) compared to f8a64c1": the test step
    failed before the coverage step, so the commit has only the legacy
    upload and the combined number lost the package's lines; the legacy
    tests job, commitlint, version-check and the CLA are green.
  • Run 2, green — head 8d56fdc5, commit 2 removes the throwaway:
    src/app.test.ts and src/Main.test.tsx pass, 2 of 2; zero console
    blocks in the test step's log; all eight checks green, with
    codecov/project back at "96.16% (+0.00%) compared to f8a64c1".
    The only extra output in the job is a Browserslist notice that the
    package's caniuse-lite data is six months old (twice in the Test
    step, once in Build (CI)); that is the package lockfile's pin, not
    a console call, and not something the hook sees. After the
    caniuse-lite bump in feat: scaffold the frontend-base package #2217's first commit, the rerun on 7c35d8c2
    is green with no Browserslist notice in the job (feat: scaffold the frontend-base package #2217's rerun on
    f5b78764 likewise).

Left to the automated suite

  • The hook itself is exercised on every run from now on: any new
    console.warn or console.error in a test fails that test.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.16%. Comparing base (2764e40) to head (dc05229).

Additional details and impacted files
@@                Coverage Diff                @@
##           frontend-base    #2219      +/-   ##
=================================================
- Coverage         100.00%   96.16%   -3.84%     
=================================================
  Files                  6      374     +368     
  Lines                  9     6028    +6019     
  Branches               0     1486    +1486     
=================================================
+ Hits                   9     5797    +5788     
- Misses                 0      222     +222     
- Partials               0        9       +9     
Flag Coverage Δ
frontend-base 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brian-smith-tcril
brian-smith-tcril force-pushed the bsmith/test-console-noise branch from 8d56fdc to 7c35d8c Compare October 22, 2026 08:26
@brian-smith-tcril brian-smith-tcril changed the title build: fail the frontend-base package's tests on unexpected console output build: fail frontend-base package tests on unexpected console output Oct 22, 2026
brian-smith-tcril added a commit to brian-smith-tcril/bairf that referenced this pull request Oct 22, 2026
… scaffold-frontend-base)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@brian-smith-tcril brian-smith-tcril linked an issue Oct 22, 2026 that may be closed by this pull request
3 tasks
@brian-smith-tcril
brian-smith-tcril marked this pull request as ready for review October 22, 2026 09:34
@brian-smith-tcril
brian-smith-tcril force-pushed the bsmith/test-console-noise branch from 7c35d8c to e4c0999 Compare October 29, 2026 16:59

@arbrandes arbrandes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. 👍🏼

Base automatically changed from bsmith/scaffold-frontend-base to frontend-base November 10, 2026 16:18
@brian-smith-tcril
brian-smith-tcril force-pushed the bsmith/test-console-noise branch 2 times, most recently from aa3d4dd to 8db7a03 Compare November 10, 2026 17:22
brian-smith-tcril and others added 2 commits November 10, 2026 12:25
The validate workflow runs on pushes to master and on every pull request,
so a commit landing on frontend-base gets only the package workflow's
coverage upload. Codecov's project status compares a PR head's total
coverage with its base commit's report: once #2217 merged, this PR's base
was the merge commit, whose report held the package's nine lines at 100%,
and the head's whole-repo 96.16% read as a 3.84 point drop. Pushes to
frontend-base now run validate too, so each merge into the branch uploads
the root suite and the comparison is whole repo against whole repo. The
push that carries this change is the first.

Part of #2218.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…utput

jest-fail-on-console in the setup file: a test that prints to console.error
or console.warn fails with the printed message. react-router 6's two future
flag warnings are silenced, since the runtime router is the shell's and
opting in is frontend-base's call (openedx/frontend-base#325).

Part of #2218.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@brian-smith-tcril
brian-smith-tcril force-pushed the bsmith/test-console-noise branch from 8db7a03 to dc05229 Compare November 10, 2026 17:39
@brian-smith-tcril
brian-smith-tcril merged commit 66fd76a into frontend-base Nov 10, 2026
7 of 8 checks passed
@brian-smith-tcril
brian-smith-tcril deleted the bsmith/test-console-noise branch November 10, 2026 17:51
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.

Fail frontend-base package tests on unexpected console output

2 participants