Skip to content

Releases: iambumblehead/esmock

detect null and undefined loader-returned sources

07 Sep 19:29
2fc016c
Compare
Choose a tag to compare

Detects null AND undefined loader-returned source definitions

diff --git a/src/esmockLoader.js b/src/esmockLoader.js
index 69dedd4..e835ec3 100644
--- a/src/esmockLoader.js
+++ b/src/esmockLoader.js
@@ -145,7 +145,8 @@ const load = async (url, context, nextLoad) => {
       if (!/^(commonjs|module)$/.test(nextLoadRes.format))
         return nextLoad(url, context)
 
-      const source = nextLoadRes.source === null
+      // nextLoadRes.source sometimes 'undefined' and other times 'null' :(
+      const source = nextLoadRes.source === null || nextLoadRes.source === undefined
         ? String(await fs.readFile(new URL(url)))
         : String(nextLoadRes.source)
       const hbang = (source.match(hashbangRe) || [])[0] || ''

node v20.6 solutions

07 Sep 17:07
221b37e
Compare
Choose a tag to compare

node v20.6 caused some issues. The primary issue was that the newest import.meta.resolve defined by node has significantly and suddenly changed. The newer import.meta.resolve is less useful and no longer supports the parent param as in the call import.meta.resolve(moduleId, parent),

simplify loader detection

15 Aug 23:32
9df7b5b
Compare
Choose a tag to compare

clerical changes to simplify loader detection,

clerical changes fewer loc

15 Aug 03:12
e8f2c27
Compare
Choose a tag to compare

Clerical changes to reduce lines of code and update some test files,

resolve global mock using mixed esm cjs import trees

07 Aug 22:21
fd4b0e3
Compare
Choose a tag to compare

resolve error global-mocking commonjs

30 Jul 21:38
35ada4d
Compare
Choose a tag to compare

support hashbang #!/usr/bin/env node

28 Jul 17:26
b712b10
Compare
Choose a tag to compare

this no-risk release adds support for files that use hashbang, eg #!/usr/bin/env node

restore ava to node20 test pipeline

22 Jul 18:27
81c3d33
Compare
Choose a tag to compare

This no-risk update restores ava to esmock's unit test pipeline and removes an ava warning from the README,

improve README examples and descriptions

01 Jun 21:00
a7615f7
Compare
Choose a tag to compare

improve README examples and descriptions,

  • improve README example for mocking global values
  • use the word 'global' in the global values mocking example only, to improve clarity (hopefully)

feat: mock global vars

31 May 07:04
3fab421
Compare
Choose a tag to compare

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 and Date scenarious at unit-tests
  • remove node 19 test job, update remaining jobs to use node 20