最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

Nock引发'AssertionError [ERR

IT培训 admin 12浏览 0评论

Nock引发'AssertionError [ERR

我正在尝试使用http://102.10.10.337:9391/v2.0/networks和以下代码来模拟URI nock

const allowUnmocked = { allowUnmocked: true };

const networkScope = nock('http://102.10.10.337:9391/v2.0/', allowUnmocked)
.persist();

console.log(networkScope);

let checknock = networkScope.post('/networks')
    .reply(200, (uri, networkPayload) => {
        console.log('dockedd');
        return {
            network: {
                'provider:physical_network': null,           
                mtu: 1450
            }
        };
    });

try {
    checknock.done();
} catch (e) {
    console.log(`boom! -> ${e}`); // pass exception object to error handler
} 

运行时,出现以下错误:

AssertionError [ERR_ASSERTION]: Mocks not yet satisfied

回答如下:

可能与重复使用/有关。

const networkScope = nock('http://102.10.10.337:9391/v2.0', allowUnmocked)
// ...
const checknock = networkScope.post('/networks')

Nock引发'AssertionError [ERR

我正在尝试使用http://102.10.10.337:9391/v2.0/networks和以下代码来模拟URI nock

const allowUnmocked = { allowUnmocked: true };

const networkScope = nock('http://102.10.10.337:9391/v2.0/', allowUnmocked)
.persist();

console.log(networkScope);

let checknock = networkScope.post('/networks')
    .reply(200, (uri, networkPayload) => {
        console.log('dockedd');
        return {
            network: {
                'provider:physical_network': null,           
                mtu: 1450
            }
        };
    });

try {
    checknock.done();
} catch (e) {
    console.log(`boom! -> ${e}`); // pass exception object to error handler
} 

运行时,出现以下错误:

AssertionError [ERR_ASSERTION]: Mocks not yet satisfied

回答如下:

可能与重复使用/有关。

const networkScope = nock('http://102.10.10.337:9391/v2.0', allowUnmocked)
// ...
const checknock = networkScope.post('/networks')

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论