Releases: iambumblehead/esmock
feat: mock global vars
This release adds a new feature: support for mocking global values like fetch
, Date
, setTimeout
and others. The wiki will be updated with more details in the next day or so,
- add initial support for the solution to "globalThis" mocks,
- support injecting definitions into the mock import tree,
- demonstrate mock
setTimeout
,fetch
andDate
scenarious at unit-tests - remove node 19 test job, update remaining jobs to use node 20
add node v21 nightly to test ci pipeline
- add node v21 nightly to test ci pipeline
- send wide uri definitions to loader using loader worker
- encountered upstream error when attempting to add node v20 tests
detect async variant import.meta.resolve
- detect async import.meta.resolve and handle in a separate way
- remove un-necessary usage of await keyword in README example
- require node version less than 20.x
use Object.defineProperty to define mock properties
use Object.defineProperty to write mock definitions protected on inherited prototype chain, re #196
throw error when esmock.stricted is called with empty mock
- throw error when esmock.strictest is called with empty mock definition, @koshic @Swivelgames
- update jest and jest-light-runner packages at unit-tests, @koshic
usability, restore previous mock-defining behaviour
This release adds node v19 to the ci-test pipeline and restores the previous mock defining-behaviour where properties can be seen easily with something like console.log(mockimported)
. This "un-does" a previous MR from 3 days ago that left part of the definition in the prototype chain, where properties were less discoverable.
@mshima windows drive letter patch
added CONTRIBUTING.md
Adds a CONTRIBUTING.md and use the live module's default export in prototype of returned mock definition, to resolve class-instance mock related issue
support yarn PnP
This release makes esmock compatible with yarn PnP. To do this, esmock is published with no dependencies and is instead bundled with resolvewithplus. Changes for this release,
- Changes the package-exported file to
esmock.js
fromesmockLoader.js
, a clerical change to make the "main" esmock file more obvious, - Embeds the resolvewithplus package inside esmock, so the published package will have no dependencies and will support yarn PnP, thanks @koshic
- Detects and uses import.meta.resolve, rather than resolvewithlus, when it is provided by the host environment. See flag
--experimental-import-meta-resolve
- Detects the presence of esmock's loader by using the loader directly. Previously, esmock tested process args with a regexp like this
/--(experimental-)?loader[=\s,"']*esmock/.test(process.argv)
. Directly using the loader is more precise and allows other scripts to wrap and use esmock in un-anticipated ways, credit @koshic
show full path at error message
show full path at error message, making it easier to identify an invalid path. Related #174