question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: Create set of mock functions for ng test

See original GitHub issue

As of now when using Apollo in app, the spec fails, complaining for something along the lines of: Error: Client has not been defined yet. I think it would be useful to have an internal mock available simply by importing it as a module in test e.g.:

imports: [
  ApolloMockModule
]

Any suggestions as to how this feature might be implemented are more than welcome as well. Thank you.

Note: I’ve noticed in the Apollo.spec.ts file, there is an apolloMock function: https://github.com/apollographql/apollo-angular/blob/master/packages/apollo-angular/tests/Apollo.spec.ts

Perhaps making this function available as an export, in the mocks folder(https://github.com/apollographql/apollo-angular/tree/master/packages/apollo-angular/tests/mocks) with the appropriate documentation, would solve this feature request.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kamilkisielacommented, May 13, 2018

v1.1.0 is going to have apollo-angular/testing, same experience as in @angular/common/http/testing

0reactions
fetiscommented, Apr 6, 2018

I expected to have something like ApolloTestingModule similar as we have HttpClientTestingModule by the Angular team, but unfortunately, I didn’t find anything. So, yeah this common testing module is highly needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature: Create set of mock functions for ng test · Issue #502
As of now when using Apollo in app, the spec fails, complaining for something along the lines of: Error: Client has not been...
Read more >
All You Need to Know About Mocking in Angular Tests (2020)
The createMagicalMock method will substitute every method to a spy, making it possible to set a return value and assert that calls have...
Read more >
How to mock service function in Angular component for unit test
I believe I have mocked the service function in my test, so I expect it must have reached else part where variable is...
Read more >
ng-mocks: Mock components, services and more out of ...
ng -mocks is a testing library which helps with mocking services, components, directives, pipes and modules in tests for Angular applications.
Read more >
Testing with Mocks & Spies using createSpyObj in Angular
There is a simpler way to mock services by creating a Spy Object. A Spy is a feature of Jasmine that allows you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found