Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gen1321/anise
Set of helpers/asserts for Absinthe
https://github.com/gen1321/anise
absinthe absinthe-graphql elixir exunit graphql
Last synced: 16 days ago
JSON representation
Set of helpers/asserts for Absinthe
- Host: GitHub
- URL: https://github.com/gen1321/anise
- Owner: gen1321
- License: mit
- Created: 2018-10-14T14:53:21.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-26T23:13:28.000Z (almost 6 years ago)
- Last Synced: 2024-10-12T13:35:43.020Z (about 1 month ago)
- Topics: absinthe, absinthe-graphql, elixir, exunit, graphql
- Language: Elixir
- Homepage:
- Size: 31.3 KB
- Stars: 21
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Anise
Anise is a set of helpers/assertions for Absinthe
## Installation
```elixir
def deps do
[
{:anise, "~> 0.1.1"}
]
end
```## Usage
### Without subscriptions
Add `use Anise` on top of your tests.Than you can do that.
```elixir
graphql(conn, "/api", @mutation, %{email: "[email protected]", name: "Boris"})
```
same for queries.### With subscriptions
Create `subscription_case.ex` in `test/support`.```elixir
defmodule MyAppWeb.SubscriptionCase do
use ExUnit.CaseTemplateusing do
quote do
@endpoint MyAppWeb.Endpoint
use Aniseuse Anise.SubscriptionCase,
schema: MyAppWeb.Schema,
socket: MyAppWeb.UserSocket
end
endsetup do
:ok
end
end```
Then in your subscription tests add `use MyAppWeb.Subscription`Now you can test your subscriptions.
```elixir
describe "User add" do
test "valid data", %{socket: socket, conn: conn} do
assert %{
payload: %{subscriptionId: sub_id},
status: :ok
} = subscribe(socket, @subscription)graphql(conn, "/api", @mutation, %{email: "[email protected]", name: "Boris"})
expected = %{result: %{data: %{"userAdded" => %{"name" => "Boris"}}}}
assert_subscription_fulfilment fufilment
assert fufilment = expected
end
end
```