Testem has a config option serve_files
that serves the client side code for me. But i need to run my server because It has a REST API
, and client side uses it.
How do i configure testem to run my server before running the tests? Or is this against the testem rules?
Because testem runs on another port and my rest api references to rest api won't work.
So i need to tell testem to bypass serve_files
and launch my actual server and test the files from there.
PS: Or another alternative would be to stub the api with sinonjs or something, would that be a proper approach? Then i wouldn't really be testing my API with the ember generated templates using the API.
You can use the API Proxy setting:
The proxy option allows you to transparently forward http requests to an external endpoint.
Simply add a proxies section to the testem.json configuration file.
{ "proxies": { "/api": { "port": 4200, "host": "localhost" }, "/xmlapi": { "port": 8000, "host": "localhost" } } }
This functionality is implemented as a transparent proxy hence a request to
http://localhost:7357/api/posts.json
will be proxied tohttp://localhost:4200/api/posts.json
without removing the /api prefix.