test(logger): cover logError DEV/PROD/Sentry branches - #201
Open
tanishxdev wants to merge 1 commit into
Open
Conversation
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.
What does this PR do?
Adds
src/lib/logger.test.ts, unit-testinglogErroracross all four DEV/PROD/Sentry code paths.Why?
logErroris the app's single error-logging chokepoint but had zero test coverage, so a regression here could silently swallow errors without anyone noticing.Closes #51
How was this tested?
Added four cases in
src/lib/logger.test.ts, following the style ofsrc/lib/scoring.test.ts:console.errorwith the[context]prefix.window.Sentrypresent: callswindow.Sentry.captureException(err, { tags: { context } }).console.error(catch block), verified call order withtoHaveBeenNthCalledWith.console.error.windowis stubbed per-test withvi.stubGlobal('window', {})since the suite runs underenvironment: 'node'(pervitest.config.ts) with no real DOM global.import.meta.env.DEV/PRODare set directly as booleans (via a typed cast) rather thanvi.stubEnv, since stubbing them as strings didn't coerce to real booleans in this setup and caused false-positive branch execution.Ran locally:
npm run test— 225/225 passing (17 test files, including the new 4 inlogger.test.ts)npm run lint— clean, no errors or warningsnpm run validate— all question banks valid (pre-existing warnings insaa-c03unrelated to this change)Checklist
npm run buildpasses locally — could not fully verify; local build fails at static-path generation withMissing Supabase environment variables, unrelated to this change (no.envcredentials configured locally)npm run lintpasses locallynpm run testpasses locallynpm run validatepasses locally (only if you touchedsrc/data/**/*.json) — N/A, no data files touched (ran anyway, passes)Screenshots (UI changes only)
N/A — test-only change, no UI impact.