cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.04k stars 1.09k forks source link

Issue 2105 more detailed error #2264

Closed michael-lloyd-morris closed 1 year ago

michael-lloyd-morris commented 1 year ago

🤔 What's changed?

The error message viewed when importing a CommonJS module or requiring an ES module is now customized.

⚡️ What's your motivation?

Making life easier when simple mistakes are made. The error message Node gives when you try to import steps using CommonJS format or require an ES module are a bit cryptic. The new error message tells the user they are using the wrong directive and to either change the file's format or use the other directive to include the file.

🏷️ What kind of change is this?

📋 Checklist:

coveralls commented 1 year ago

Coverage Status

Coverage: 98.489% (-0.04%) from 98.525% when pulling c0fa54d3f4f848d0df0a2ed5dc549f90b93cec2a on michael-lloyd-morris:issue-2105-more-detailed-error into aae711c7ee374a1081867e0adcbb1ee77ae4ef2a on cucumber:main.

michael-lloyd-morris commented 1 year ago

I did not know that it's valid to import a common JS module. That does explain why the error messages are so different. Of the two native nodejs errors that one is the more easy to understand, so I'll remove the catch on the importer for now to satisfy this requirement along with the scenario testing for that code change. Shall I keep the remaining feature alone in it's own file or move it into the esm.feature file? (on second thought, just going ahead and doing that as it makes the most sense, but I can undo it).

michael-lloyd-morris commented 1 year ago

Requested Changes applied.

michael-lloyd-morris commented 1 year ago

Is there something else I need to do or where the changes I did insufficient?

davidjgoss commented 1 year ago

Just a couple of things to address but this is looking like a good change. Also see a conflict on the changelog file.

michael-lloyd-morris commented 1 year ago

I'll get to these items in the morning and will try to be done by end of day, though I've got to take a chunk of the day to take my Dad to the hospital.

(Until I have a job, volunteer work here is my job - if only to keep my skills sharp and my sanity intact - so I'm treating it as such).

michael-lloyd-morris commented 1 year ago

Ok, all requested changes applied, though see the note about Typescript and using the cause option on Error throws.