We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
test_with_server
How can we use test context from ExUnit while using test_with_server instead of test from ExUnit?
test context
test
For example, we can use this syntax with ExUnit test macro.
test "uses metadata from setup", context do assert context[:hello] == "world" assert context[:from_named_setup] == true end
but we cannot provide a context for test_with_server as the second parameter is opts.
context
opts
The text was updated successfully, but these errors were encountered:
Posting a workaround for anyone that encounters this problem like we did as well.
Manually start fake server in a setup function and add that to your context.
def start_fake_server(_context) do name = String.to_atom("test_server_#{System.unique_integer([:positive, :monotonic])}") FakeServer.start!(name) on_exit(fn -> FakeServer.stop(name) end) [fake_server: FakeServer.Instance.state(name)] end # ..., usage: setup :start_fake_server setup :something_else test "some test", %{ fake_server: fake_server, something_else: something_else } do FakeServer.put_route!( fake_server.server_name, ClientRequest.api_path() <> "/xxxx", FakeServer.Response.ok!(%{"xxxx" => xxxx}, %{"Content-Type" => "application/json"}) ) ... end
Sorry, something went wrong.
No branches or pull requests
How can we use
test context
from ExUnit while usingtest_with_server
instead oftest
from ExUnit?For example, we can use this syntax with ExUnit
test
macro.but we cannot provide a
context
fortest_with_server
as the second parameter isopts
.The text was updated successfully, but these errors were encountered: