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

Use jsdom polyfill and update jest #2386

Merged
merged 53 commits into from
Nov 7, 2022
Merged

Use jsdom polyfill and update jest #2386

merged 53 commits into from
Nov 7, 2022

Conversation

NSeydoux
Copy link
Contributor

@NSeydoux NSeydoux commented Oct 17, 2022

Initially, the intent of this PR was just to use jsdom polyfills we provide to simplify the environment setup. However, it showed that we are currently not running our unit test using the browser jose bundle in the browser package, because we are using an older version of jest. So this PR also looks at updating jest to the latest version.

EDIT: a bunch of upgrades tacked on this PR:

  • Update to the latest linting rules (because of the polyfill update coming from the same repo)
  • Migrated jest configs to TS to reuse explicit typing provided by ts-jest
  • A bunch of tests required some changes because of the jest major update
  • The polyfill still don't entirely cut it, so for now the custom environment is still used. Changes will be pushed to the polyfills, and when upgrading the custom environment will be removed.

@NSeydoux NSeydoux requested a review from a team as a code owner October 17, 2022 09:52
@NSeydoux NSeydoux marked this pull request as draft October 17, 2022 09:52
@NSeydoux NSeydoux force-pushed the chore/jsdom-polyfill branch from 4a227c5 to 6c4e9dd Compare October 17, 2022 09:53
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 17, 2022 09:53 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 17, 2022 09:53 Inactive
@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 17, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ecbf668:

Sandbox Source
solid-client-auth-browser-demo Configuration

@vercel vercel bot temporarily deployed to Preview October 17, 2022 09:57 Inactive
Copy link
Contributor

@ThisIsMissEm ThisIsMissEm left a comment

Choose a reason for hiding this comment

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

Looks good overall, a few minor comments

jest.config.js Outdated Show resolved Hide resolved
jest.setup.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
packages/browser/jest.config.js Outdated Show resolved Hide resolved
packages/oidc/jest.config.js Outdated Show resolved Hide resolved
packages/oidc/package.json Outdated Show resolved Hide resolved
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 12:22 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 12:22 Inactive
@vercel vercel bot temporarily deployed to Preview October 19, 2022 12:26 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 14:20 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 14:20 Inactive
@vercel vercel bot temporarily deployed to Preview October 19, 2022 14:24 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 14:25 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 14:25 Inactive
@vercel vercel bot temporarily deployed to Preview October 19, 2022 14:29 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 14:31 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 14:31 Inactive
@vercel vercel bot temporarily deployed to Preview October 19, 2022 14:34 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 14:38 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 19, 2022 14:38 Inactive
@NSeydoux NSeydoux marked this pull request as ready for review October 19, 2022 14:40
@vercel vercel bot temporarily deployed to Preview October 19, 2022 14:41 Inactive
Copy link
Contributor

@ThisIsMissEm ThisIsMissEm left a comment

Choose a reason for hiding this comment

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

Let's get the changes needed into jest-jsdom-polyfills instead of using a custom environment here.

jest.setup.ts Outdated
@@ -0,0 +1 @@
import "@inrupt/jest-jsdom-polyfills";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import "@inrupt/jest-jsdom-polyfills";
import "@inrupt/jest-jsdom-polyfills";

missing trailing new line, and eslint may complain about license header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We currently don't run eslint on config files (none of them include the license header). Should we?

Copy link
Contributor

Choose a reason for hiding this comment

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

Debatable? It does run in some repos, needs to be standardised as included or ignored in style configs

jest.config.ts Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
(this.global.crypto.subtle as any) = (new Crypto()).subtle;
this.global.CryptoKey = CryptoKey;
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's fix this in jest-jsdom-polyfills instead of using custom environments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This works in the polyfill (I have tested it locally, I was planning on merging this and revisiting after releasing the updated polyfills), but I couldn't get the Uint8Array thing to work in there, so for now I'm afraid the custom environment has to stay. We can revisit why, but I'd like to move on because this has been a time sink :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, okay; I suspect this is due to there being that JSDom UInt8Array issue

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should've been released now, so this shouldn't be necessary anymore.

tsconfig.build.json Show resolved Hide resolved
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 20, 2022 08:49 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 20, 2022 08:49 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 20, 2022 08:51 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 20, 2022 08:51 Inactive
@vercel vercel bot temporarily deployed to Preview October 20, 2022 08:57 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 28, 2022 21:44 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 28, 2022 21:44 Inactive
@vercel vercel bot temporarily deployed to Preview October 28, 2022 21:47 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 28, 2022 21:49 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 28, 2022 21:49 Inactive
@vercel vercel bot temporarily deployed to Preview October 28, 2022 21:52 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 28, 2022 21:54 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next October 31, 2022 13:37 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 2, 2022 09:20 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 2, 2022 12:54 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 2, 2022 12:54 Inactive
@vercel vercel bot temporarily deployed to Preview November 2, 2022 12:57 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 2, 2022 13:19 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 2, 2022 13:20 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 2, 2022 13:20 Inactive
@vercel vercel bot temporarily deployed to Preview November 2, 2022 13:23 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 3, 2022 11:15 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 3, 2022 11:15 Inactive
@vercel vercel bot temporarily deployed to Preview November 3, 2022 11:18 Inactive
Instead of relying on Lerna to run tests across the repos, just use Jest picking a specific project or running them all.
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 3, 2022 22:04 Inactive
@NSeydoux NSeydoux temporarily deployed to ESS Dev-Next November 3, 2022 22:04 Inactive
@vercel vercel bot temporarily deployed to Preview November 3, 2022 22:06 Inactive
@NSeydoux NSeydoux merged commit 7b21bee into main Nov 7, 2022
@NSeydoux NSeydoux deleted the chore/jsdom-polyfill branch November 7, 2022 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants