Skip to content

Commit

Permalink
Refactor test for Marp CLI interface
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Sep 29, 2024
1 parent a55bceb commit 60a0ce7
Show file tree
Hide file tree
Showing 4 changed files with 338 additions and 630 deletions.
4 changes: 2 additions & 2 deletions test/__mocks__/cosmiconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {

// Because of v8's bug, Jest fails with SIGSEGV if used dynamic import.
// When using ESM in tests, you have to set up Jest to transpile config files into CommonJS with Babel.
cosmiconfig.cosmiconfig = jest.fn((moduleName, options) => {
cosmiconfig.cosmiconfig = (moduleName, options) => {
return originalCosmiconfig(moduleName, {
loaders: {
// cosmiconfig sync loader is using `require()` to load JS
Expand All @@ -21,6 +21,6 @@ cosmiconfig.cosmiconfig = jest.fn((moduleName, options) => {
},
...(options ?? {}),
})
})
}

module.exports = cosmiconfig
4 changes: 2 additions & 2 deletions test/__mocks__/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EventEmitter } from 'node:events'
const express = jest.requireActual('express')

express.__errorOnListening = undefined
express.application.listen = jest.fn(() => {
express.application.listen = () => {
const serverMock = Object.assign(new EventEmitter(), {
close: (callback) => callback(),
})
Expand All @@ -17,6 +17,6 @@ express.application.listen = jest.fn(() => {
}, 0)

return serverMock
})
}

module.exports = express
Loading

0 comments on commit 60a0ce7

Please sign in to comment.