feat(ioredis): prototype running tests in ESM mode #1794
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
This is a prototype for running esm tests using our existing tests, based on my comment on #1731.
This PR is not intended for merging, but rather to illustrate how we could run ESM tests if we'd want to have full coverage with our existing tests.
esm.mocharc.json
is used by the esm tests, and specifies both ts-node and otel esm loadersnpm run prepare:test:esm
module
inpackage.json
, I've not found a way around this yet.npm run test:esm:local
lets one run the tests in ESM mode (the instrumentation code is also transpiled to ESM mode, which does not 100% reflect real-life as we don't publish ESM with the npm package)import
in the tests so that they also work with ESM, it transpiles torequire
for cjs, so that should be ok.restore:test:cjs
sets the type back tocommonjs
again and un-patches mocha.This is quite a prototype setup; I think if we'd want to introduce something like this, we'd need adapt some of this to be less fragile.