1

I am trying to run test for graphql endpoint using gest. Below is my code

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')
    })
  })
})

But I am getting the following error

ReferenceError: describe is not defined

As per the solution give in Solution Link I ran the file using mocha. But it the gives another error

ReferenceError: test is not defined

I am stuck here. How can I solve this issue. And also one more question. Is gest and mocha related? Please some one help me out of this

greybeard
  • 2,249
  • 8
  • 30
  • 66
Seena V P
  • 934
  • 3
  • 9
  • 26

2 Answers2

2

describe function is setup by mocha.

If you have installed mocha locally, run test with

./node_modules/.bin/mocha path/to/test.js

Or

mocha path/to/test.js

Also, you might want to replace test(...) call with it(...)

explorer
  • 944
  • 8
  • 18
0

Discussion for this is happening here. Basically you need to run the posted example in an environment that has describe as a global, like [Mocha][3] and Jest.

Mike Fix
  • 1
  • 1