Модульное тестирование apollo-angular graphql

Кому-нибудь удалось протестировать сервер apollo с apollo-angular?. Вот моя маленькая установка:

import { ApolloModule } from 'apollo-angular';
import { ApolloTestingModule } from 'apollo-angular/testing';
import { ApolloClient, ApolloClientOptions } from 'apollo-client';
import { AppComponent } from './app.component';

// Copy a GQL response (that includes __typename etc)
const gqlResponse = `
  {
    "data": {
      "comments": []
    }
  }`;

function provideClient(): any {
  return new ApolloClient({
    networkInterface: {
      query: function () {
        return new Promise(resolve => resolve(gqlResponse));
      }
    }
  });
}

describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [AppComponent],
      imports: [
        ApolloTestingModule,
        MatListModule,
        MatSidenavModule,
        RouterTestingModule,
        BrowserAnimationsModule,
        ApolloModule.withClient(provideClient)
        // Failed: apollo_angular_1.ApolloModule.withClient is not a function
      ]
    }).compileComponents();
  }));

  it('should make a srv req', async(() => {


  }));

Здесь происходит сбой: ApolloModule.withClient(provideClient) // Ошибка: apollo_angular_1.ApolloModule.withClient не является функцией

0 ответов

Другие вопросы по тегам