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

test: Convert tests to ESM and upgrade Chai #297

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented Jan 11, 2024

Convert all the tests to ESM (.mjs) in preparation for Chai 5, which drops support for CommonJS.

  • replace require with import throughout.
  • create a global chai object to replace the old chai = require('chai').
  • rename tests from .js to .mjs.
  • remove chai-http and chai-as-promised, which aren't being used by any tests.
  • upgrade outdated dependencies (New Relic, Mocha, Express, and Sentry.)
  • install chai v5.1.0.

@eatyourgreens
Copy link
Contributor Author

eatyourgreens commented Jan 11, 2024

NB. the tests here will run, and pass, with Chai 5, but you have to npm install --force chai@latest, because of incompatible plugins.

Fixed by removing chai-as-promised, which hasn't been updated in ~6 years.

test/index.mjs Outdated
Comment on lines 27 to 31
global.chai = {
...baseChai,
...baseChai.use(chaiAsPromised),
...baseChai.use(chaiHttp),
...baseChai.use(chaiSpies),
...baseChai.use(chaiChanges)
};
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 is a workaround for chaijs/chai#1569, because imports are immutable.

@eatyourgreens eatyourgreens force-pushed the esm-tests branch 3 times, most recently from f31ae89 to e147b77 Compare January 12, 2024 10:08
@eatyourgreens eatyourgreens changed the title Convert tests to ESM tests: Convert tests to ESM Feb 17, 2024
@eatyourgreens eatyourgreens changed the title tests: Convert tests to ESM test: Convert tests to ESM Feb 17, 2024
Convert all the tests to ESM (`.mjs`) in preparation for Chai 5, which drops support for CommonJS.
- replace `require` with `import` throughout.
- create a global `chai` object to replace the old `chai = require('chai')`.
- rename tests from '.js' to '.mjs'.
@eatyourgreens eatyourgreens changed the title test: Convert tests to ESM test: Convert tests to ESM and upgrade Chai Apr 14, 2024
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.

None yet

1 participant