Skip to content

✨ @percy/sdk-utils - #63

Merged
wwilsman merged 4 commits into
masterfrom
ww/sdk-utils
Oct 19, 2020
Merged

✨ @percy/sdk-utils#63
wwilsman merged 4 commits into
masterfrom
ww/sdk-utils

Conversation

@wwilsman

Copy link
Copy Markdown
Contributor

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 winston dependencies 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, and postSnapshot. Their usage docs can be found in the readme

Other 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.

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.
@wwilsman wwilsman added the ✨ enhancement New feature or request label Oct 19, 2020
@wwilsman wwilsman assigned Robdel12 and unassigned Robdel12 Oct 19, 2020
@wwilsman
wwilsman requested a review from Robdel12 October 19, 2020 21:18

@Robdel12 Robdel12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏁 Love this, shrinks the JS SDKs to like 40 lines or less.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants