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

Wrap generating e2e script into async func #3936

Closed
wants to merge 1 commit into from

Conversation

broccolinisoup
Copy link
Member

@broccolinisoup broccolinisoup commented Nov 13, 2023

Changelog

New

Changed

Running the script/generate-e2e-tests.js throws an error due to prettier.format retuning a Promise object, not string. (docs reference)

node:internal/fs/utils:905
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Promise
    at Object.writeFileSync (node:fs:2314:5)
    at Object.<anonymous> (/Users/broccolinisoup/GitHub/DesignSystems/react/script/generate-e2e-tests.js:1605:6)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'ERR_INVALID_ARG_TYPE'
}

I wrapped the code into an async function and awaiting the prettier.format. Let me know if there is a better way to do it!

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan

Testing & Reviewing

Could be test adding a new item to the components array with an id and story name to check if the script generates a test file.

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

Copy link

changeset-bot bot commented Nov 13, 2023

⚠️ No Changeset found

Latest commit: 1c07b9e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

size-limit report 📦

Path Size
dist/browser.esm.js 104.2 KB (0%)
dist/browser.umd.js 104.74 KB (0%)

@joshblack
Copy link
Member

@broccolinisoup just as another option, you can also replace the import to @prettier/sync and the API will be the same. We had to do this for the codemods so the dependency should already be installed too 👍

}

generateE2ETests()
Copy link
Member

Choose a reason for hiding this comment

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

One suggestion, instead of the try-catch block we could instead add .catch() to the promise call and log/exit from there.

Suggested change
generateE2ETests()
generateE2ETests()
.catch((error) => {
// eslint-disable-next-line no-console
console.log(error)
process.exit(1)
});

Copy link
Contributor

Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jan 12, 2024
@github-actions github-actions bot closed this Jan 19, 2024
@github-actions github-actions bot deleted the bs/update-e2e-script branch January 19, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changeset This change does not need a changelog Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants