Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/local/importsChangelogParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import parseChangelog from 'changelog-parser'

export default parseChangelog
17 changes: 17 additions & 0 deletions tests/tests-node/esmock.node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ import esmock from 'esmock'
import sinon from 'sinon'
import esmockCache from '../../src/esmockCache.js'

// https://github.com/iambumblehead/esmock/issues/312
test('should mock changelog-parser', {
only: true,
skip: true
}, async () => {
const parseChangelog = await esmock(
'../local/importsChangelogParser.js', {}, {
'node:fs': {
open: test.mock.fn(),
close: test.mock.fn(),
read: test.mock.fn(() => 'content')
}
})

assert.strictEqual(await parseChangelog({ filePath: 'fake' }), 'content')
})

test('should mock node:process', async () => {
// has direct and in-direct calls to `process.cwd()`
const thingBeingTested = await esmock('../local/usesNodeProcess.js', {}, {
Expand Down
1 change: 1 addition & 0 deletions tests/tests-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"sinon": "file:../node_modules/sinon",
"eslint": "file:../node_modules/eslint",
"form-urlencoded": "file:../node_modules/form-urlencoded",
"changelog-parser": "file:../node_modules/changelog-parser",
"babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault"
},
"scripts": {
Expand Down
Loading