Skip to content

Commit

Permalink
git add tests-jest-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
bumblehead committed Sep 20, 2022
1 parent fddefc7 commit 4241410
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/tests-jest-ts/esmock.node-jest.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import esmock from 'esmock'

test('should mock modules when using jest', async () => {
const main = await esmock('../local/main.js', {
path: {
basename: () => 'hellow'
}
})

expect(main.pathbasenamewrap()).toBe('hellow')
})
27 changes: 27 additions & 0 deletions tests/tests-jest-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "module",
"description": "esmock unit tests, jest with jest-light-runner",
"repository": {
"type": "git",
"url": "https://github.com/iambumblehead/esmock.git"
},
"dependencies": {
"tsm": "^2.2.2",
"jest": "^28.1.3",
"jest-light-runner": "0.2.2",
"run-script-os": "^1.1.6",
"esmock": "file:..",
"sinon": "file:../node_modules/sinon",
"eslint": "file:../node_modules/eslint",
"form-urlencoded": "file:../node_modules/form-urlencoded",
"babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault"
},
"jest": {
"runner": "jest-light-runner"
},
"scripts": {
"test:default": "NODE_OPTIONS=\"--loader=tsm --loader=esmock\" jest esmock.node-jest.test.ts",
"test:win32": "set NODE_OPTIONS=\"--loader=tsm --loader=esmock\" && jest esmock.node-jest.test.ts",
"test": "run-script-os"
}
}

0 comments on commit 4241410

Please sign in to comment.