quibble icon indicating copy to clipboard operation
quibble copied to clipboard

fix: correct check for existing replacements

Open JakobJingleheimer opened this issue 1 year ago • 2 comments

quibbleLoaderState.quibbledModules is initialised as a Map in the root of the module, and it is never voided (only replaced with a fresh Map on "reset"), so the empty Map would never fail a falsy test because an empty Map is still truthy (so instead check whether it's emtpy).

To verify, run against https://github.com/JakobJingleheimer/td-global-mock/commit/0008fb5803e23c5acf51c022334282504e1e8dc9 (npm test will error if this fix doesn't work).

This partially fixes https://github.com/testdouble/testdouble.js/issues/528, but it doesn't address all cases.

JakobJingleheimer avatar Mar 21 '24 10:03 JakobJingleheimer

The test-case "support importing esm and returning the path even when bare-specifier quibbled" is failing locally (but apparently not in CI??), but I'm not sure why—I added some logs, and their output is what I expect.

log output

Note that I manually replaced irrelevantly long parts of URLs below with ...s (the actual output does not contain ...s)

[QBL]:
resolved: file:///.../is-promise/index.mjs
size: 0 (there are no replacements registered)

[QBL]:
resolved: file:///.../is-promise/index.mjs?__quibble=1
size: 1

[QBL]:
resolved: file:///.../is-promise/index.mjs?__quibble=1
size: 1

[QBL]:
resolved: file:///.../is-promise/index.mjs?__quibble=1
size: 1

It fails with (I prettied up the output):

AssertionError:
'file:///.../is-promise/index.mjs?__quibble=1'
to deep equal
'file:///.../is-promise/index.mjs'

Based on the description, I think the expected value is wrong—the description seems to say the result should be "quibbled".

JakobJingleheimer avatar Mar 21 '24 16:03 JakobJingleheimer

@giltayar 👀

JakobJingleheimer avatar Jul 25 '24 19:07 JakobJingleheimer