Alex Antonov
Alex Antonov

Reputation: 15156

How to run real phoenix server during test?

I'm implementing kinda tricky functionality with external libraries I can't mock. They needs to implement real requests to the server. So,

how can I run a web-server during tests implementation?

P.S. My config/test.exs:

config :my_reelty, MyReelty.Endpoint,
  http: [port: {:system, "PORT"}],
  url:  [host: "localhost", port: 5000] # Specific port

I'm trying to curl http://localhost:5000 but getting curl: (7) Failed to connect to localhost port 5000: Connection refused

Upvotes: 2

Views: 1191

Answers (1)

Dogbert
Dogbert

Reputation: 222198

You need to add server: true to the Endpoint's config:

config :my_reelty, MyReelty.Endpoint, server: true

The phoenix.new may have already generated similar config with server: false (it does for me in v1.2.0), so you can just change that false to true.

Upvotes: 3

Related Questions