Files
pnpm/__utils__/jest-config/globalSetup.js

30 lines
779 B
JavaScript

const { start, prepare } = require('@pnpm/registry-mock')
const { promisify } = require('util')
const kill = promisify(require('tree-kill'))
module.exports = () => {
if (process.env.PNPM_REGISTRY_MOCK_PORT == null) return
prepare()
const server = start({
// Verdaccio stopped working properly on Node.js 22.
// You can test the issue by running:
// pnpm --filter=core run test test/install/auth.ts
useNodeVersion: '20.16.0',
stdio: 'inherit',
})
let killed = false
server.on('error', (err) => {
console.log(err)
})
server.on('close', () => {
if (!killed) {
console.log('Error: The registry server was killed!')
process.exit(1)
}
})
global.killServer = () => {
killed = true
return kill(server.pid)
}
}