feat: Capture CSP violations - #41
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 45bacd1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
foxable
force-pushed
the
feat/csp-captor
branch
from
September 22, 2026 07:08
025d741 to
8c9d22d
Compare
CspCaptor for capturing CSP violations
PMudra
self-requested a review
September 23, 2026 12:09
PMudra
approved these changes
Sep 23, 2026
foxable
force-pushed
the
feat/csp-captor
branch
from
September 24, 2026 06:30
8c9d22d to
9c0d09d
Compare
foxable
force-pushed
the
feat/csp-captor
branch
from
September 24, 2026 06:32
9c0d09d to
45bacd1
Compare
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.
CSP violations are usually silent: the browser drops the blocked resource, logs a console warning, and the test still passes.
CspCaptorcloses that gap by surfacing every violation as structured data.cspFixturesfixture guards against otherwise undetected CSP violations by failing any test that triggers one, without requiring changes to individual test files.CspCaptorandcaptureCspViolationscan also be used directly, giving tests the ability to trigger and assert on individual CSP directives.Features
CspCaptor: collects a page'ssecuritypolicyviolationevents as structuredCspViolationobjectscaptureCspViolations: factory for creating aCspCaptorcspFixtures: ready-to-merge Playwright fixtures that install an auto-startingcspCaptoron every test and fail it on unexpected violations, configurable per test via theignoreCspViolationsoption fixture