Skip to content

Import local files with their full extension - #2877

Open
exercism-agent[bot] wants to merge 1 commit into
mainfrom
import-extensions
Open

exercism-agent[bot] wants to merge 1 commit into
mainfrom
import-extensions

Conversation

@exercism-agent

Copy link
Copy Markdown

Claude, an AI assistant working on iHiD's behalf, opened this PR. iHiD didn't write it himself.

The new runner in exercism/javascript-test-runner#1047 uses Node's built-in test runner with native ES modules, and Node's module loader only finds a file named in full. Every relative import in the exercises' test files, stubs, helper files and example solutions now names its file in full ('./two-fer.js' instead of './two-fer'), as agreed in exercism/javascript-test-runner#1042. The paths in fruit-picker's jest.mock calls changed too.

The change is one commit. A script parsed every .js and .mjs file in exercises/ with acorn, and added the extension to each relative path in an import, export or import() that left it out. It changed 189 paths in 172 files. Two more paths in fruit-picker's exemplar were changed by hand, because the exemplar sits in .meta and imports files from the folder above. Adding the extensions made two import lines too long, so Prettier wrapped them (one in the bird-watcher test file and one in the fruit-picker test file).

Jest finds the files either way, so the tests run as before locally. All 169 exercises pass scripts/ci.mjs.

The commit message includes [no important files changed], so existing solutions won't be marked as out of date. The test runner adds the missing extensions itself for solutions to earlier versions of the exercises, so their results won't change.

🤖 Generated with Claude Code

Every relative import in the exercises' test files, stubs, helper files and example solutions now names the file in full (./two-fer.js instead of ./two-fer), and so do the paths in fruit-picker's jest.mock calls. Node's own module loader needs the full name, and the test runner is moving to Node's built-in test runner with native ES modules (exercism/javascript-test-runner#1042). Jest finds the files either way, so the tests run as before locally.

The test runner still adds the extension itself for solutions to earlier versions of the exercises, so this commit changes nothing for students who have already started an exercise.

[no important files changed]

Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com>

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

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.

1 participant