Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting ServerParseError on expo and graphql mock #224

Open
Davete0302 opened this issue Dec 20, 2021 · 0 comments
Open

Getting ServerParseError on expo and graphql mock #224

Davete0302 opened this issue Dec 20, 2021 · 0 comments

Comments

@Davete0302
Copy link

Davete0302 commented Dec 20, 2021

I'm using react-native with expo, jest-fetch-mock and graphql. When calling the api Im getting error

× return user feed query (69ms)

● testing api › return user feed query

      at _callee$ (graphql/__tests__/api.test.js:22:41)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:294:22)
  at Generator.next (node_modules/regenerator-runtime/runtime.js:119:21)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
  at invoke (node_modules/regenerator-runtime/runtime.js:155:20)

api.test.js import fetch from 'jest-fetch-mock';

      import fetch from 'jest-fetch-mock';

import { getUserFeed } from '../feed'

describe('testing api', () => {
    beforeEach(() => {
        fetch.resetMocks()
    })

    it('return user feed query', async () => {


        //assert on the response
        await getUserFeed(20).then((response) => response.json())
            .then((responseJson) => {
                console.log('res ' + JSON.stringify(responseJson))
            }).catch((error) => {
                console.log('error' + JSON.stringify(error))
            })

        // .then((res) => {
        //     console.log('res '+JSON.stringify(res))
        // }).catch((error) => {
        //     console.log('error'+JSON.stringify(error))
        //     })

        //assert on the times called and arguments given to fetch
        console.log('watch ' + JSON.stringify(fetch.mock.calls))
        expect(fetch.mock.calls.length).toEqual(20)
    })
})

.catch error from console.log

error{"graphQLErrors":[],"clientErrors":[],"networkError":{"name":"ServerParseError","response":{"size":0,"timeout":0},"statusCode":200,"bodyText":""},"message":"Unexpected end of JSON input"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant