Skip to content
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

✨ Add core testing mode to help test SDKs #984

Merged
merged 1 commit into from
Jul 5, 2022
Merged

Conversation

wwilsman
Copy link
Contributor

@wwilsman wwilsman commented Jul 5, 2022

What is this?

Currently, the majority of our SDKs (JavaScript SDKs) have access to sdk-utils' test server that mocks the core API. This is the primary method of testing these SDKs since their implementations use sdk-utils internally anyway. For other SDKs, we implement the required utils on a per-language basis, including how they're tested. Testing typically involves mocking HTTP modules or creating stub APIs to simulate the CLI exec command running.

With minimal changes to our existing core API, we can add a testing mode. This new testing mode accomplishes two main tasks. First is to silence all logs and enable dry-run mode to disable uploads and asset discovery. Second is to enable a few extra API endpoints to allow all SDKs to be more easily tested. New API endpoints include access to raw logs, a simple HTML document to snapshot, and a set of commands to manipulate how the API responds to test various circumstances such as errors, disconnects, or missing/invalid core version information.

For now, this new testing mode will be used with the upcoming .NET SDK. In the future however, we should update all of our other tests across all languages and eventually remove the old test server from sdk-utils.

Other changes made include a small adjustment to client's request util to allow false as a JSON body, and updated percy-css tests which were failing for me locally from accidentally unstashed, unrelated, changes.

@wwilsman wwilsman added the ✨ enhancement New feature or request label Jul 5, 2022
@wwilsman wwilsman requested a review from Robdel12 July 5, 2022 18:11
Currently, the majority of our SDKs (JavaScript SDKs) have access to sdk-utils' test server that
mocks the core API. This is the primary method of testing these SDKs since their implementations use
sdk-utils internally anyway. For other SDKs, we implement the required utils on a per-language
basis, including how they're tested. Testing typically involves mocking HTTP modules or creating
stub APIs to simulate the CLI exec command running.

With minimal changes to our existing core API, we can add a testing mode. This new testing mode
accomplishes two main tasks. First is to silence all logs and enable dry-run mode to disable uploads
and asset discovery. Second is to enable a few extra API endpoints to allow all SDKs to be more
easily tested. New API endpoints include access to raw logs, a simple HTML document to snapshot, and
a set of commands to manipulate how the API responds to test various circumstances such as errors,
disconnects, or missing/invalid core version information.

Other changes made include a small adjustment to client's request util to allow `false` as a JSON
body, and updated percy-css tests which were failing from unrelated, accidentally unstashed, changes.
@wwilsman wwilsman force-pushed the ww/cli-testing-mode branch from 197d792 to 951ce54 Compare July 5, 2022 18:14
Copy link
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

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

🏁 This will make non-js SDKs muchh easier to build too. Great idea 👏🏼

@wwilsman wwilsman merged commit 20ef74a into master Jul 5, 2022
@wwilsman wwilsman deleted the ww/cli-testing-mode branch July 5, 2022 18:28
kodiakhq bot referenced this pull request in carbon-design-system/carbon-for-ibm-dotcom Jul 13, 2022
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@percy/cli](https://github.com/percy/cli) | [`~1.5.0` -> `~1.6.0`](https://renovatebot.com/diffs/npm/@percy%2fcli/1.5.1/1.6.0) | [![age](https://badges.renovateapi.com/packages/npm/@percy%2fcli/1.6.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@percy%2fcli/1.6.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@percy%2fcli/1.6.0/compatibility-slim/1.5.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@percy%2fcli/1.6.0/confidence-slim/1.5.1)](https://docs.renovatebot.com/merge-confidence/) |
| [@percy/dom](https://github.com/percy/cli) | [`~1.5.0` -> `~1.6.0`](https://renovatebot.com/diffs/npm/@percy%2fdom/1.5.1/1.6.0) | [![age](https://badges.renovateapi.com/packages/npm/@percy%2fdom/1.6.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@percy%2fdom/1.6.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@percy%2fdom/1.6.0/compatibility-slim/1.5.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@percy%2fdom/1.6.0/confidence-slim/1.5.1)](https://docs.renovatebot.com/merge-confidence/) |
| [@percy/sdk-utils](https://github.com/percy/cli) | [`~1.5.0` -> `~1.6.0`](https://renovatebot.com/diffs/npm/@percy%2fsdk-utils/1.5.1/1.6.0) | [![age](https://badges.renovateapi.com/packages/npm/@percy%2fsdk-utils/1.6.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@percy%2fsdk-utils/1.6.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@percy%2fsdk-utils/1.6.0/compatibility-slim/1.5.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@percy%2fsdk-utils/1.6.0/confidence-slim/1.5.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>percy/cli</summary>

### [`v1.6.0`](https://github.com/percy/cli/releases/tag/v1.6.0)

[Compare Source](https://github.com/percy/cli/compare/v1.5.1...v1.6.0)

<!-- Release notes generated using configuration in .github/release.yml at master -->

#### What's Changed

##### ✨ Enhancements

-   ✨ Add core testing mode to help test SDKs by [@&#8203;wwilsman](https://github.com/wwilsman) in [https://github.com/percy/cli/pull/984](https://github.com/percy/cli/pull/984)
-   ✨ Allow PascalCase options (and other casing) by [@&#8203;wwilsman](https://github.com/wwilsman) in [https://github.com/percy/cli/pull/985](https://github.com/percy/cli/pull/985)

##### ⬆️⬇️ Dependency Updates

-   ⬆️ Bump [@&#8203;babel/cli](https://github.com/babel/cli) from 7.17.10 to 7.18.6 by [@&#8203;dependabot](https://github.com/dependabot) in [https://github.com/percy/cli/pull/981](https://github.com/percy/cli/pull/981)
-   ⬆️ Bump [@&#8203;babel/register](https://github.com/babel/register) from 7.17.7 to 7.18.6 by [@&#8203;dependabot](https://github.com/dependabot) in [https://github.com/percy/cli/pull/979](https://github.com/percy/cli/pull/979)
-   ⬆️ Bump [@&#8203;babel/core](https://github.com/babel/core) from 7.18.5 to 7.18.6 by [@&#8203;dependabot](https://github.com/dependabot) in [https://github.com/percy/cli/pull/980](https://github.com/percy/cli/pull/980)
-   ⬆️ Bump tsd from 0.21.0 to 0.22.0 by [@&#8203;dependabot](https://github.com/dependabot) in [https://github.com/percy/cli/pull/983](https://github.com/percy/cli/pull/983)
-   ⬆️ Bump [@&#8203;babel/preset-env](https://github.com/babel/preset-env) from 7.18.2 to 7.18.6 by [@&#8203;dependabot](https://github.com/dependabot) in [https://github.com/percy/cli/pull/982](https://github.com/percy/cli/pull/982)

**Full Changelog**: percy/cli@v1.5.1...v1.6.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "every weekend" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/carbon-design-system/carbon-for-ibm-dotcom).
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