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

chore: Add support for ESM in jest #2606

Merged
merged 1 commit into from
Aug 23, 2024
Merged

chore: Add support for ESM in jest #2606

merged 1 commit into from
Aug 23, 2024

Conversation

gethinwebster
Copy link
Member

@gethinwebster gethinwebster commented Aug 22, 2024

Description

Adjust NodeJS config so that jest tests can cope with ESM (see https://jestjs.io/docs/ecmascript-modules). This is so that we can upgrade webdriverio, which is distributed as ESM in recent versions.

Related links, issue #, if available: AWSUI-51276

How has this been tested?

Tested in local workspace with upgraded version of webdriverio (cloudscape-design/browser-test-tools#86)

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Aug 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.80%. Comparing base (df2a8b4) to head (2c5a0d5).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2606   +/-   ##
=======================================
  Coverage   95.80%   95.80%           
=======================================
  Files         742      743    +1     
  Lines       20320    20335   +15     
  Branches     6859     6923   +64     
=======================================
+ Hits        19467    19482   +15     
  Misses        797      797           
  Partials       56       56           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gethinwebster gethinwebster marked this pull request as ready for review August 22, 2024 10:37
@gethinwebster gethinwebster requested a review from a team as a code owner August 22, 2024 10:37
@gethinwebster gethinwebster requested review from just-boris and removed request for a team August 22, 2024 10:37
package.json Outdated
"test:a11y": "gulp test:a11y",
"test:integ": "gulp test:integ",
"test:motion": "gulp test:motion",
"gulp:integ": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" gulp",
Copy link
Member

@just-boris just-boris Aug 22, 2024

Choose a reason for hiding this comment

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

I already added this flag before:

runJest('build-tools', 'jest.build-tools.config.js', 'build-tools/**/__tests__/*.test.js', {
// stylelint rules require ESM
// https://stylelint.io/migration-guide/to-16#jest-preset-stylelint
NODE_OPTIONS: '--experimental-vm-modules',
}),

How about doing the same way here, so even when running npx gulp ... it still sets the expected options?

Also, I am not sure this line in our contributing docs will remain working:

components/CONTRIBUTING.md

Lines 155 to 156 in a35b753

# Run all input integration tests
npx jest -c jest.integ.config.js src/input

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice approach, thanks. Updated the docs too.

@gethinwebster gethinwebster added this pull request to the merge queue Aug 23, 2024
Merged via the queue into main with commit f30d9c8 Aug 23, 2024
33 checks passed
@gethinwebster gethinwebster deleted the jest-esm branch August 23, 2024 09:42
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