-
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 #81 from iambumblehead/add-tsm-demo-and-test
adds tsm unit-test and README example
- Loading branch information
Showing
5 changed files
with
47 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import test from 'node:test'; | ||
import assert from 'assert'; | ||
import esmock from 'esmock'; | ||
|
||
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,19 @@ | ||
{ | ||
"type": "module", | ||
"description": "esmock unit tests, tsm with node native runner", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/iambumblehead/esmock.git" | ||
}, | ||
"dependencies": { | ||
"tsm": "^2.2.2", | ||
"esmock": "file:..", | ||
"sinon": "file:../node_modules/sinon", | ||
"eslint": "file:../node_modules/eslint", | ||
"form-urlencoded": "file:../node_modules/form-urlencoded", | ||
"babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault" | ||
}, | ||
"scripts": { | ||
"test": "node --loader=tsm --loader=esmock --test *test.ts" | ||
} | ||
} |
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" | ||
} | ||
} |