Skip to content

Add regression tests for mocking by package.json imports specifiers - #127

Merged
rosston merged 1 commit into
mainfrom
add-import-alias-test
Oct 10, 2026
Merged

rosston merged 1 commit into
mainfrom
add-import-alias-test

Conversation

@rosston

@rosston rosston commented Oct 10, 2026

Copy link
Copy Markdown
Member

To prevent a regression of #69.

quibble.esm('#src/...') used to fail with ERR_PACKAGE_IMPORT_NOT_DEFINED because the dummy import() that finds a specifier's URL ran from quibble's own file, so Node resolved the specifier against quibble's package.json. Resolving non-relative specifiers from the caller (#123, 0.12.0) fixed this too, since # specifiers count as bare, but nothing tested it.

The fixture is its own package with an imports field, and the calls to quibble come from a file inside it. The tests and quibble's lib directory share quibble's root package.json, so mapping the alias there would let 0.11.0 resolve it too and the tests would never fail. They do fail against 0.11.0's lib.

To prevent a regression of #69.

quibble.esm('#src/...') used to fail with ERR_PACKAGE_IMPORT_NOT_DEFINED
because the dummy import() that finds a specifier's URL ran from quibble's
own file, so Node resolved the specifier against quibble's package.json.
Resolving non-relative specifiers from the caller (#123, 0.12.0) fixed this
too, since `#` specifiers count as bare, but nothing tested it.

The fixture is its own package with an `imports` field, and the calls to
quibble come from a file inside it. The tests and quibble's lib directory
share quibble's root package.json, so mapping the alias there would let
0.11.0 resolve it too and the tests would never fail. They do fail against
0.11.0's lib.
@rosston rosston self-assigned this Oct 10, 2026
@rosston
rosston marked this pull request as ready for review October 10, 2026 00:50
@rosston
rosston merged commit 0cc08f6 into main Oct 10, 2026
18 checks passed
@rosston
rosston deleted the add-import-alias-test branch October 10, 2026 00:53
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