使用本机节点 mock 模拟进程 argv

Mocking process argv with native node mock

提问人:myol 提问时间:11/15/2023 更新时间:11/15/2023 访问量:9

问:

我正在从本机库迁移到本机库。sinonnode:test

在我嘲笑 argv 之前,我这样;sinon

import { stub } from 'sinon'

stub(process, 'argv').get(() => ['node-path', 'application-entry', 'first-arg']

以下 with 不起作用;node:test

import { mock } from "node:test"

mock.getter(Process, 'argv').mock.mockImplementation(() =>  ['node-path', 'application-entry', 'first-arg'])

我收到以下错误;

TypeError [ERR_INVALID_ARG_VALUE]:参数“methodName”必须是方法。收到 undefined

节点.js 模拟 节点测试运行程序

评论


答: 暂无答案