-
Notifications
You must be signed in to change notification settings - Fork 48
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
✨ Browserify @percy/sdk-utils #265
Merged
Merged
Conversation
This file contains 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
wwilsman
force-pushed
the
ww/browserify-sdk-utils
branch
from
March 25, 2021 19:40
3b35954
to
471948c
Compare
Robdel12
approved these changes
Mar 25, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏁
|
||
let script = await fetchPercyDOM(); | ||
let script = await fetchPercyDOM() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this stance you're taking here. NO SEMI'S?!
samarsault
pushed a commit
that referenced
this pull request
Mar 3, 2023
Bumps [@percy/agent](https://github.com/percy/percy-agent) from 0.28.2 to 0.28.4. - [Release notes](https://github.com/percy/percy-agent/releases) - [Changelog](https://github.com/percy/percy-agent/blob/master/CHANGELOG.md) - [Commits](percy/percy-agent@v0.28.2...v0.28.4) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
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 is this?
This refactors and bundles
@percy/sdk-utils
to be able to work in browser environments!Thanks to all the build/test script updates, bundling for the browser was as easy as adding a
browser
field to the package.json file, and adjusting the rollup config for package specific settings via the customrollup
field.A
karma
property was also added to support hooks specific for browser tests (more on this later). Rather than usingexec
, the hook command is called viaspawn
so stdio can be properly inherited without pipes.Now that the package needs to be built (where it previously did not), we can take advantage of es features and refactor the utils. They are also now broken apart into their own modules.
The
getInfo()
util was replaced with an exportedpercy
object which gets updated with all of the cached information from the various other utils. This also enables us to test the utils without re-requiring the package to reset private caches since we can now reset these caches via manipulating thepercy
object. Thepercy.version
property was also updated to be a small version object that contains major/minor/patch/prerelease/build information based on the version string.The internal
request()
util used by other utils is now also exported. This util could potentially be used to interact with other core server API endpoints such as/percy/idle
or/percy/stop
. Implementation specific fetching can be configured via therequest.fetch
property. By default, it useswindow.fetch
in browsers andhttp.request
in node, but can be overridden with framework specific methods. For example, the Cypress SDK can use thecy.backend('http:request')
method to avoid CORS/CSP issues.The
isPercyEnabled()
util will now also set up a remote logging connection upon a successful health check response. Failed connections are ignored (such as from CSP) as it will only affect how logs are consumed and not any other functionality. Browser WebSockets are handled internally by the browser, so while thrown errors are ignored, logged errors might still exist in the local browser console and might not be easily avoidable. If this rogue log becomes more of an issue than we expect, we might potentially be able to check for certain other conditions before attempting the connection.Test helpers were drastically changed and warrant their own set of bullet points.
The helpers revolve around starting mock API and site servers. These servers are then used for SDK functions to communicate with or take snapshots of. Since you cannot start servers from within a browser, these helpers have to exist in node while providing some way for browser tests to interact with them.
The core helper functionality and it's methods were moved to
test/server.js
as acontext()
helper. The context returned by the helper has acall
method which forwards nested accessors or callees to the proper place. Thetest/helpers.js
file now contains a simplified set of methods that themselves use thecall
method to interact with the test helper context.In node environments, the test helper context is attached to the test helper object. In browser environments, the
call
method is replaced with a WebSocket based solution that connects to and forwards calls to a local test helper server.The
test/server.js
file also exports newstart
,stop
, andexec
functions. These functions can be used directly, or via invoking the file as a script (node test/server <start|stop|exec> [...args]
).The
start()
function will start a WebSocket server and create a new test helper context so remote sockets can interact with test helpers (used by ourkarma.run_start
hook for our own tests).The
stop()
function will create a new WebSocket, attempt to connect to a runningtest/server
, and send aCLOSE
message which triggers the server to stop (used by ourkarma.run_complete
hook for our own tests).The
exec()
function will start and stop the server around a supplied command (for usage similar topercy exec
—test/server exec -- run-tests
).