Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests rely on a third-party service to work #64

Open
zhevron opened this issue Nov 17, 2017 · 1 comment
Open

Unit tests rely on a third-party service to work #64

zhevron opened this issue Nov 17, 2017 · 1 comment

Comments

@zhevron
Copy link
Contributor

zhevron commented Nov 17, 2017

Currently, the unit tests rely on the "Trippin" example service. Which means that the unit tests actually rely on this API to work. I've seen multiple examples where the library produces the correct request, but the API fails with HTTP status code 500, causing the tests to fail anyway.

IMO, it would be better to simply test the request object before it goes out to any server. Since the project currently uses Jasmine for testing, one possibility is to use jasmine-ajax to intercept the requests and run tests on them.

This way, the URL, method, data, etc can be tested without actually relying on a real API to respond. This also allows tests to be run in a offline-only scenario when developing.

Thoughts? As long as the tests enforce the OData protocol spec, it should be a better approach and allow for corner case testing without the Trippin service implementing that endpoint.

@janhommes
Copy link
Owner

I like the idea. But it is not an easy task. The test-mocks must follow the specs and therefore somebody has to invest time to set-up the mocks correctly.

Jasmin-Ajax looks like a good library to do that and this will allow us to test all internal functions until the initialized request. Another idea is to fake any request which is going to base.get(), base.post() (etc.), but this will only allow us to test the public available functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants