diff --git a/tests/local/bossch.fnimported.js b/tests/local/bossch.fnimported.js new file mode 100644 index 0000000..e743e84 --- /dev/null +++ b/tests/local/bossch.fnimported.js @@ -0,0 +1 @@ +export const fnimported = () => 'un-mocked' diff --git a/tests/local/bossch.fnimporter.js b/tests/local/bossch.fnimporter.js new file mode 100644 index 0000000..2c6861e --- /dev/null +++ b/tests/local/bossch.fnimporter.js @@ -0,0 +1,5 @@ +import { fnimported } from './bossch.fnimported.js' + +export const fncaller = () => { + return fnimported() +} diff --git a/tests/tests-node/esmock.node.bossch.test.js b/tests/tests-node/esmock.node.bossch.test.js new file mode 100644 index 0000000..6a613d5 --- /dev/null +++ b/tests/tests-node/esmock.node.bossch.test.js @@ -0,0 +1,13 @@ +import test from 'node:test' +import assert from 'assert' +import esmock from 'esmock' + +test('should mock importedfn', async () => { + const { fncaller } = await esmock('../local/bossch.fnimporter.js', { + '../local/bossch.fnimported.js': { + fnimported: () => 'mocky' + } + }) + + assert.equal('mocky', fncaller()) +}) diff --git a/tests/tests-node/package.json b/tests/tests-node/package.json index 5427e7c..01e4da4 100644 --- a/tests/tests-node/package.json +++ b/tests/tests-node/package.json @@ -3,7 +3,7 @@ "description": "esmock unit tests, node native runner", "repository": { "type": "git", - "url": "https://github.com/iambumblehead/esmock.git" + "url": "gi+https://github.com/iambumblehead/esmock.git" }, "dependencies": { "esmock": "file:..",