Closed jrwpatterson closed 5 years ago
@jrwpatterson Actually it doesn't support remote schemas, but there's a workaround that can be useful using the Apollo tools described here
it'll be something like this:
'use strict'
const { introspectSchema } = require('graphql-tools')
const { HttpLink } = require('apollo-link-http')
const fetch = require('node-fetch')
const { expect } = require('chai')
const EasyGraphQLTester = require('easygraphql-tester')
const link = new HttpLink({ uri: '<YOUR_URL>', fetch });
describe('test', () => {
let tester
before(async () => {
const schema = await introspectSchema(link)
tester = new EasyGraphQLTester(schema)
})
it('should mock the id', () => {
const query = `
{
me {
id
name
}
}
`
const { data } = tester.mock({
query,
fixture: {
data: {
me: {
id: 'abc-123'
}
}
}
})
expect(data.me.id).to.be.a('string')
expect(data.me.name).to.be.a('string')
expect(data.me.id).to.be.eq('abc-123')
})
})
@jrwpatterson does it works for you?
Can we close this issue?
sure I'll give it a go
I'm going to close this issue, if it's needed we can open again!
I'm wondering if its possible to run tests on a remote schema so that we can test clients against deployed servers?