-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
developer-experienceIssues affecting ease of use and overall experience of LB usersIssues affecting ease of use and overall experience of LB users
Milestone
Description
This is a follow-up for #1267
When consuming a service using REST connector with template-based configuration: As an app developer, I would definitely want to have few smoke tests to verify that my templates work as intended and match the API provided by the service at the other side. I would like to write an integration test that's using only the service (not the full app!), something along the following lines:
import {GeoService} from '../services/geo.service';
import {expect} from '@loopback/testlab';
describe('GeoService', () => {
let service: GeoService;
beforeEach(() => service = new GeoService());
describe('geocode', () => {
it('returns geo coords for a given address', () => {
const result = await service.geocode('107 S B St', 'San Mateo', '94401');
// { lat: 37.5669986, lng: -122.3237495 }
expect(result.lat).approximately(37.5669986, 0.5);
expect(result.lng).approximately(-122.3237495, 0.5);
});
});
});Acceptance criteria
- Finish Feature: a caching HTTP proxy for integration tests #1364 implementing an aggressive caching HTTP proxy to speed up integration tests.
- Finish Add GeoCoder Service to examples/todo #1347 which is adding Geocoder service to Todo example to demonstrate in practice our advices regarding Service testing. Leverage the caching HTTP proxy to keep
npm testfast enough. The tricky part: how to configure the Service datasource to use our proxy in the test, but not in production? A poor-man's workaround that may work until we implement proper support for per-env config: the tests can useprocess.env.PROXYto instruct the underlyingrequestmodule which is backing our service connectors like loopback-connector-rest. - Update Todo tutorial - describe how to add Geocoder service - see docs: add geo-coding service to Todo tutorial #1441
- http://loopback.io/doc/en/lb4/Testing-your-application.html#unit-test-your-services: we are not going to write any unit tests for services right now, this section should be removed - see docs: describe how to tests services #1445
- http://loopback.io/doc/en/lb4/Testing-your-application.html#test-your-services-against-real-backends: add content explaining users how to write integration tests, see the code example above for inspiration - see docs: describe how to tests services #1445
- http://loopback.io/doc/en/lb4/Calling-other-APIs-and-web-services.html: add a section about testing services, point readers to best-practices section "test-your-services-against-real-backends". We may need to change the prescribed way of defining Services to make testing easier - see docs: describe how to tests services #1445
Metadata
Metadata
Assignees
Labels
developer-experienceIssues affecting ease of use and overall experience of LB usersIssues affecting ease of use and overall experience of LB users