This repository was archived by the owner on Jun 5, 2026. It is now read-only.
feat: Introduce an API for Percy Specific CSS - #346
Merged
Conversation
Ideally the unit tests wouldn't be impacted by a real `.percy.yml` file. But this is easier than refactoring the commands test suite.
Robdel12
commented
Sep 16, 2019
| command: $NYC yarn test-client --singleRun | ||
| - run: | ||
| name: Setup integration test .percy.yml | ||
| command: mv .ci.percy.yml .percy.yml |
Contributor
Author
There was a problem hiding this comment.
I'm not crazy about this, but it's needed because adding a .percy.yml file breaks the unit tests.
This can go away once you can pass a custom file path for the .yml file. Then the unit tests can have their own mocked & static .yml file.
Contributor
|
Haven't reviewed yet, but I just wanted to add that the version: 1
snapshot:
widths: [375, 1280]
percy-css: |
iframe {
display none;
} |
wwilsman
reviewed
Sep 16, 2019
Robdel12
force-pushed
the
rd/percy-css
branch
from
September 16, 2019 22:27
95466d6 to
7a458d2
Compare
wwilsman
approved these changes
Sep 16, 2019
djones
pushed a commit
that referenced
this pull request
Sep 17, 2019
# [0.13.0](v0.12.2...v0.13.0) (2019-09-17) ### Features * Introduce an API for Percy Specific CSS ([#346](#346)) ([6158f57](6158f57))
This was referenced Sep 17, 2019
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 is this?
This PR introduces first class support for providing CSS specific to only Percy's rendering environment though the SDKs. Now users will be able to provide a new option called
percyCSSwith our SDKs. This can be set globally and on a per-snapshot basis.Approach
Initially the implementation of this was going to be fairly easy. We would take a new snapshot option and then serialize that CSS into the DOM when we're serializing inputs and what not. It turns out, CSP can block this injected CSS (thank you SDK test site!).
To work around CSP issues, we instead now take that CSS and create a new resource for this snapshot which contains the CSS. If you have global CSS, we'll concat that with the per-snapshot CSS. This file is named with the current time stamp +
percy-specific.css. It does not use the@percymedia query since this CSS can only ever exist in Percy)This CSS will be applied at the very bottom of their DOM snapshot, before the closing
</body>tag. This hopefully will ensure the cascade will do its job and!importantwon't be needed often.Usage
Now there's a simple API for providing Percy only CSS. For snapshot specific css:
For global CSS in the
.percy.ymlfile:TODOs once this ships
optionscorrectly.