[英]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? 在测试实施过程中如何运行Web服务器?
PS My config/test.exs
: PS我的
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
我正在尝试
curl http://localhost:5000
但变得curl: (7) Failed to connect to localhost port 5000: Connection refused
You need to add server: true
to the Endpoint
's config: 您需要将
server: true
添加到Endpoint
的配置中:
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
. phoenix.new
可能已经使用server: false
生成了类似的配置(在v1.2.0中对我有用),因此您可以将false
更改为true
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.