testdouble / quibble

Makes it easy to replace require'd dependencies.
93 stars 26 forks source link

allow proxy as default export #93

Closed connorjclark closed 1 year ago

connorjclark commented 1 year ago

Currently, setting a Proxy object as the default export will error within lodash's isPlainObject:

TypeError: Cannot convert a Symbol value to a string
    at Object.get (file:///Users/cjamcl/src/lighthouse/core/test/gather/mock-driver.js:288:74)
    at Proxy.toString (<anonymous>)
    at objectToString (/Users/cjamcl/src/lighthouse/node_modules/lodash/_objectToString.js:19:31)
    at baseGetTag (/Users/cjamcl/src/lighthouse/node_modules/lodash/_baseGetTag.js:25:7)
    at isPlainObject (/Users/cjamcl/src/lighthouse/node_modules/lodash/isPlainObject.js:50:31)
    at Function.quibble.esm (/Users/cjamcl/src/lighthouse/node_modules/quibble/lib/quibble.js:83:36)
    at replaceEsModule (/Users/cjamcl/src/lighthouse/node_modules/testdouble/lib/replace/module/index.js:38:24)
    at Module.replaceEsm (/Users/cjamcl/src/lighthouse/node_modules/testdouble/lib/replace/index.js:24:41)
--------
    at mockDriverSubmodules (file:///Users/cjamcl/src/lighthouse/core/test/gather/mock-driver.js:292:12)
    at file:///Users/cjamcl/src/lighthouse/core/test/gather/gatherers/dobetterweb/response-compression-test.js:9:21

This patch allow a Proxy object to pass this object check.

searls commented 1 year ago

Looks like utils.types.isProxy landed in v10 so this sounds great!

connorjclark commented 1 year ago

Thanks! Would you mind doing a new release to include this?

searls commented 1 year ago

Sure. Landed in v0.6.17