-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from iambumblehead/update-hooks-usage-to-avoid…
…-recursive-loop add initial support for typescript, resolve load hook recursion error
- Loading branch information
Showing
10 changed files
with
71 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
{ | ||
"name": "esmock", | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"license": "MIT", | ||
"readmeFilename": "README.md", | ||
"description": "provides native ESM import mocking for unit tests", | ||
"author": "chris <[email protected]>", | ||
"main": "src/esmockLoader.mjs", | ||
"module": "src/esmockLoader.mjs", | ||
"type": "module", | ||
"types": "src/esmock.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/iambumblehead/esmock.git" | ||
|
@@ -57,17 +58,21 @@ | |
"uvu": "0.5.3", | ||
"ava": "^4.0.1", | ||
"eslint": "^8.12.0", | ||
"ts-node": "^10.9.1", | ||
"esmock": "file:.", | ||
"form-urlencoded": "4.2.1", | ||
"run-script-os": "^1.1.6", | ||
"sinon": "^12.0.1" | ||
}, | ||
"scripts": { | ||
"test-node-esbuildts": "node --no-warnings --loader=@esbuild-kit/esm-loader --loader=esmock --test ./spec/node-ts/*ts", | ||
"test-node-ts": "node --no-warnings --loader=ts-node/esm --loader=esmock --test ./spec/node-ts/*ts", | ||
"test-node": "node --no-warnings --loader=esmock --test ./spec/node/", | ||
"test-node18": "if (node -v | grep v18); then npm run test-node; fi;", | ||
"test-node18": "npm run test-node && npm run test-node-ts", | ||
"test-nodeis18": "if (node -v | grep v18); then npm run test-node18; fi;", | ||
"test-ava": "npx ava --node-arguments=\"--loader=esmock\" ./spec/ava/*.spec.js", | ||
"test-uvu": "node --loader=esmock ./node_modules/uvu/bin.js ./spec/uvu/", | ||
"test:default": "npm run test-node18 && npm run test-ava && npm run test-uvu", | ||
"test:default": "npm run test-nodeis18 && npm run test-ava && npm run test-uvu", | ||
"test:windows": "npm run test-ava && npm run test-uvu", | ||
"test": "run-script-os", | ||
"test-no-warn": "npx ava --node-arguments=\"--loader=esmock --no-warnings\"", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import path from 'path'; | ||
|
||
export default { | ||
pathbasenamewrap: (n: any) => path.basename(n) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import test from 'node:test'; | ||
import assert from 'assert'; | ||
import esmock from '../../src/esmock.js'; | ||
|
||
test('should mock ts when using node-ts', { only : true }, async () => { | ||
const main = await esmock('../local/main.ts', { | ||
path: { | ||
basename: () => 'hellow' | ||
} | ||
}); | ||
|
||
assert.strictEqual( main.pathbasenamewrap(), 'hellow' ); | ||
assert.ok(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function esmock(path: string, localmock?: any, globalmock?: any): any; | ||
export = esmock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default process.execArgv | ||
.some(args => args.startsWith('--loader=') && args.includes('esmock')) | ||
|| /(?:^|\s)?--(?:experimental-)?loader=(["']*)esmock\1(?:\s|$)/ | ||
.test(process.env.NODE_OPTIONS); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"esm": true, | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": true, | ||
"module": "ESNext", | ||
"moduleResolution": "node" | ||
} | ||
} |