-
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 #305 from galexite/tsx-is-now-compatible
Update test and README about tsx compatibility
- Loading branch information
Showing
7 changed files
with
50 additions
and
42 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
import test from 'node:test' | ||
import assert from 'assert' | ||
import esmock from 'esmock' | ||
|
||
test('should mock js when using tsx', async () => { | ||
const main = await esmock('../local/main.js', { | ||
path: { | ||
basename: () => 'hellow' | ||
} | ||
}) | ||
|
||
assert.strictEqual(main.pathbasenamewrap(), 'hellow') | ||
}) | ||
|
||
test('should mock ts when using tsx', async () => { | ||
const main = await esmock('../local/main-ts.ts', { | ||
path: { | ||
basename: () => 'hellow' | ||
} | ||
}) | ||
|
||
assert.strictEqual(main.pathbasenamewrap(), 'hellow') | ||
}) |
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,21 @@ | ||
{ | ||
"type": "module", | ||
"description": "esmock unit tests, tsx with node", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/iambumblehead/esmock.git" | ||
}, | ||
"dependencies": { | ||
"esmock": "file:..", | ||
"tsx": "^4.15.5" | ||
}, | ||
"scripts": { | ||
"isloaderavailable": "node -e \"(([mj, mn]) => (+mj < 18 || (+mj === 20 && +mn < 6) || (+mj === 18 && +mn < 19)))(process.versions.node.split('.')) || process.exit(1)\"", | ||
"test:loader": "node --loader=tsx/esm --loader=esmock --test esmock.node.tsx.test.ts", | ||
"test:current": "node --import=tsx/esm --test esmock.node.tsx.test.ts", | ||
"test": "npm run isloaderavailable && npm run test:loader || npm run test:current" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.14.2" | ||
} | ||
} |
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