troyanskiy/ngx-resource

Testing services based on ngx-resource

tobias-- opened this issue · 3 comments

Is there any documentation on how to fake/mock services to test components or services that depend on providers that extend ngx-resources' Resource?

@tobias-- i prefer to create a jasmine spy for my own resources. It's the simplest available solution i guess.

const spy = createSpyObj('CustomersResource', ['get']);

// provide it as a dependency for tested service/component
// and in test
spy.get.and.return({ $observable: of({ id: 'foo', name: 'bar' })})

Hello
You can try to test with Http service mocking.
In fact resource === service (provider), so I believe you try this https://kendaleiv.com/angular-2-mockbackend-service-testing-template-using-testbed/

Feel free to reopen the issue if you still have the question open.