supertest icon indicating copy to clipboard operation
supertest copied to clipboard

Document how to run tests against a remote server.

Open brightbyte opened this issue 6 years ago • 2 comments

I'm evaluating SuperTest for use as an end-to-end testing framework for an API implemented in PHP. So I need to run the tests via actual HTTP against some configurable base URL. After a lot of poking around, I found that I can just pass that base URL to the module's constructor, as in

request( 'http://localhost:8080/dummy/' ).get('api.php')

This is undocumented though, and even violates the documentation in index.js, which requires the parameter to be a Function or a http.Server. Is there a better way to achieve what I want? If not, I'd propose to document the fact that the module can be initialized with a base URL like this.

PS: request( app ).get('http://localhost:8080/dummy/api.php') didn't work for me, it would always return a 404, no matter what URL I fed in. Couldn't figure out why. I'm new to node.js though, maybe I was just confused.

brightbyte avatar Jul 31 '19 13:07 brightbyte

@brightbyte In case of remote servers, what you propose is the only way to do that with supertest.

jonathansamines avatar Aug 08 '19 17:08 jonathansamines

The readme is not clear on whether you can pass a url to request, it should explain that better

marcospgp avatar Mar 24 '20 16:03 marcospgp