我正在尝试使用 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/