Skip to content

Commit

Permalink
add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Jul 30, 2023
1 parent b712b10 commit 5241adc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tests/local/usesModuleWithCJSDependency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import meow from 'meow'

const cli = meow('foo', { importMeta: import.meta, description: false })

console.log(cli.help);

Check failure on line 5 in tests/local/usesModuleWithCJSDependency.js

View workflow job for this annotation

GitHub Actions / build

Extra semicolon
9 changes: 5 additions & 4 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
"#sub": "./local/subpath.js"
},
"dependencies": {
"pg": "^8.7.3",
"babelGeneratedDoubleDefault": "file:./local/babelGeneratedDoubleDefault",
"eslint": "^8.12.0",
"sinon": "^12.0.1",
"form-urlencoded": "^6.0.7",
"run-script-os": "^1.1.6",
"meow": "12.0.1",
"npm-run-all": "^4.1.5",
"babelGeneratedDoubleDefault": "file:./local/babelGeneratedDoubleDefault"
"pg": "^8.7.3",
"run-script-os": "^1.1.6",
"sinon": "^12.0.1"
},
"scripts": {
"mini": "cd .. && cd src && npx esbuild esmock.js --minify --bundle --allow-overwrite --platform=node --format=esm --outfile=esmock.js",
Expand Down
12 changes: 12 additions & 0 deletions tests/tests-node/esmock.node.global.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,15 @@ test('should mock files with hashbangs', async () => {

assert.deepEqual(logs, ['foo'])
})

test('should work when modules have CJS imports', async () => {
const logs = []

await esmock('../local/usesModuleWithCJSDependency.js', {}, {
import: {
console: { log: (...args) => logs.push(...args) }
}
})

assert.deepEqual(logs, ['\nfoo\n'])
});

Check failure on line 77 in tests/tests-node/esmock.node.global.test.js

View workflow job for this annotation

GitHub Actions / build

Extra semicolon

0 comments on commit 5241adc

Please sign in to comment.