You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 769ea69
Browse filesBrowse the repository at this point in the historyBrowse files
td.replace(object, property) swapped the property by assignment, both
when replacing and when restoring on reset. Assigning to a getter with
no setter throws in strict mode, so it failed with "Cannot set property
... which has only a getter".
For a getter with no setter, define the fake as a data property
instead:
- An own, configurable getter (as tsc defines re-exports) is redefined,
and reset puts the original descriptor back exactly.
- An inherited getter (a class getter, replaced through an instance) is
shadowed by an own property, which reset deletes.
- An own, non-configurable getter (as SWC defines exports) can't be
redefined, so it gets an error that points to replacing the whole
module with td.replace(path) instead.
Data properties and getters with setters are still replaced by
assignment, as before.
returnlog.error('td.replace',`"${property}" is defined with a getter that cannot be redefined. Compilers like SWC and Babel define ES module exports this way. To replace a module's export, replace the whole module with td.replace('path/to/module') instead.`)
assert._isEqual(e.message,'Error: testdouble.js - td.replace - "beep" is defined with a getter that cannot be redefined. Compilers like SWC and Babel define ES module exports this way. To replace a module\'s export, replace the whole module with td.replace(\'path/to/module\') instead.')
assert._isEqual(e.message,'Error: testdouble.js - td.replace - "beep" is defined with a getter that cannot be redefined. Compilers like SWC and Babel define ES module exports this way. To replace a module\'s export, replace the whole module with td.replace(\'path/to/module\') instead.')
0 commit comments