✨ @percy/sdk-utils - #63
Merged
Merged
Conversation
Having no catch argument is valid since Node 10, but some external libraries don't think so when this file is eventually required through test helpers.
This package hosts common utils for Node based SDKs. Test helpers can also be utilized for testing other SDKs if there is a Node process available to hook into.
Robdel12
approved these changes
Oct 19, 2020
Robdel12
left a comment
Contributor
There was a problem hiding this comment.
🏁 Love this, shrinks the JS SDKs to like 40 lines or less.
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 is this?
Node based SDKs have a few common utils that can be abstracted away into their own module. They also perform common setup steps in tests that can also be abstracted away into a common test helper.
These common utils include talking to the local running Percy CLI API. Rather than have dependencies on libraries like fetch, we can use a shared request helper using native Node methods. Also, rather than including all of the
winstondependencies of@percy/logger, there is a smaller, simple log util that accomplishes the goal of communicating SDK information to the user.The consumable utils exported by this package are
log,getInfo,isPercyEnabled,fetchPercyDOM, andpostSnapshot. Their usage docs can be found in the readmeOther changes
I added an argument to the catch clause in the server helper which is eventually required by the new sdk-utils test helper. While testing these utils, I found that some external libraries (like
testcafe) will attempt to compile required files even if they are compatible with the current version of Node. That compilation failed when it encountered a catch without arguments.