lundi 8 janvier 2018

"fetch is not found globally and no fetcher passed" when using spacejam in meteor

I'm writing unit tests to check my api. Before I merged my git test branch with my dev branch everything was fine, but then I started to get this error:

App running at: http://localhost:4096/
spacejam: meteor is ready
spacejam: spawning phantomjs
phantomjs: Running tests at http://localhost:4096/local using test-in-console
phantomjs: Error: fetch is not found globally and no fetcher passed, to fix pass a fetch for
  your environment like http://ift.tt/2nshLbi.

  For example:
    import fetch from 'unfetch';
    import { createHttpLink } from 'apollo-link-http';

    const link = createHttpLink({ uri: '/graphql', fetch: fetch });

Here's a part of my api.test.js file:

describe('GraphQL API for users', () => {
    before(() => {
      StubCollections.add([Meteor.users]);
      StubCollections.stub();
    });

    after(() => {
      StubCollections.restore();
    });

    it('should do the work', () => {
      const x = 'hello';
      expect(x).to.be.a('string');
    });
  });

The funniest thing is that I don't even have graphql in my tests (although, I use it in my meteor package) Unfortunately, I didn't to find enough information (apart from apollo-link-http docs that has examples, but still puzzles me). I did try to use that example, but it didn't help and I still get the same error

Aucun commentaire:

Enregistrer un commentaire