gpt4 book ai didi

node.js - 引用错误: describe is not defined

转载 作者:太空宇宙 更新时间:2023-11-04 00:17:27 27 4
gpt4 key购买 nike

我正在尝试使用 gest 运行 graphql 端点测试。下面是我的代码

const Gest = require('graphicli')
const schema = require('./path/schema.js')

const gest = Gest(schema, {
baseURL: 'http://localhost:7770/graphql',
headers: {
Accept: 'application/json'
}
})

describe('GraphQL', () => {
test('{getAllNominator{firstName}}', () => {
return gest('{getAllNominator{firstName}}').then(({ data, errors }) => {
expect(errors).toBeUndefined()
expect(data).toEqual('Adam')
})
})
})

但是我收到以下错误

ReferenceError: describe is not defined

根据Solution Link给出的解决方案我使用mocha运行该文件。但它给出了另一个错误

ReferenceError: test is not defined

我被困在这里了。我该如何解决这个问题。还有一个问题。 gest Mocha 有关系吗?请有人帮我解决这个问题

最佳答案

describe 函数由 mocha 设置。

如果您已在本地安装了 mocha,请使用

运行测试
./node_modules/.bin/mocha path/to/test.js

或者

mocha path/to/test.js

此外,您可能希望将 test(...) 调用替换为 it(...)

关于node.js - 引用错误: describe is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46193653/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com