-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: add support for named exports #28
base: master
Are you sure you want to change the base?
feat: add support for named exports #28
Conversation
@@ -4,7 +4,9 @@ | |||
"description": "Safe(r) monkeypatching for JavaScript.", | |||
"main": "index.js", | |||
"scripts": { | |||
"test": "standard && tap test/*.tap.js --coverage" | |||
"test": "npm run test:cjs && npm run test:mjs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see this being condensed into a single line for testing instead of separating out the esm named export test, open to suggestion.
@@ -23,6 +25,6 @@ | |||
"devDependencies": { | |||
"sinon": "^7.2.2", | |||
"standard": "^12.0.1", | |||
"tap": "^12.1.1" | |||
"tap": "15.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enumerable: false | ||
}) | ||
|
||
test('should wrap safely with named export in esm', function (t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is lifted from the wrap.tap.js
test, with the main difference being the use of the named import. I wasn't sure whether to add tests for each method or if this is sufficient.
'wrapped unenumerable property is still unenumerable') | ||
}) | ||
|
||
test('should properly import each named export', function (t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This second test just confirms the named imports successfully imported. It may not be necessary, open to feedback.
Since this is a larger change because of the test updates, I'm more than happy to reduce this to only add the named exports and not make adjustments to tests and updating the tap package. |
Which problem is this PR solving?
karma
with wpt runner in user-interaction open-telemetry/opentelemetry-js-contrib#2005Short description of the changes
There is some explanation here of the problems we were running into while trying to update our tests to use a new test runner. It seems that this will be resolved by providing named exports, which may help other folks using ESM as well.
@std/esm
that didn't work as expected in tests. The latest version has some other changes so I opted for 15.2 to minimize overall changes while still allowing this test to work.