devonestes / assertions

Helpful assertions for ExUnit
MIT License
142 stars 29 forks source link

Can't seem to properly import Absinthe assertions #22

Open tadiou opened 3 years ago

tadiou commented 3 years ago

Hey, love the work thank you.

But I'm struggling here with consistently getting the assertions methods to properly compile here.

I have a really (really) small phoenix app i whipped up, where I try to add the Assertions.AbsintheCase to the DataCase, and

I try to write a really simple case here

defmodule AssertionsTestWeb.Schema.Queries.UserTest do
  use AssertionsTest.DataCase

  test "resolves correctly" do
    """
    query {
      user {
        #{document_for(:user)}
      }
    }
    """
    |> assert_response_matches do
      %{
        "user" => %{
          "id" => _id
        }
      }
    end
  end
end

and the DataCase.ex looks like

defmodule AssertionsTest.DataCase do
  use ExUnit.CaseTemplate
  using do
    quote do
      alias AssertionsTest.Repo

      import Ecto
      import Ecto.Changeset
      import Ecto.Query
      import AssertionsTest.DataCase

      use Assertions.AbsintheCase, async: true, schema: AssertionsTestWeb.Schema
    end
  end
  # [....]
end

And it can't find assert_response_matches/4.

== Compilation error in file test/assertions_test_web/gql/queries/user_test.exs ==
** (CompileError) test/assertions_test_web/gql/queries/user_test.exs:2: undefined function assert_response_equals/4
    (elixir 1.11.3) src/elixir_locals.erl:114: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
    (stdlib 3.14) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.11.3) lib/kernel/parallel_compiler.ex:416: Kernel.ParallelCompiler.require_file/2
    (elixir 1.11.3) lib/kernel/parallel_compiler.ex:316: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7
mackshkatz commented 3 years ago

I am seeing this same issue. The strange thing is that it works fine for one of my teammates and myself, but not for our other teammate. Also, the compilation fails on our CI build (in Circle). All 3 of us and our CI instance are running elixir 1.12.1

@devonestes Any thoughts?

jimshepherd commented 3 years ago

timgremore's pull request, #24, solved the issue for me. Thanks @timgremore!

mackshkatz commented 3 years ago

@jimshepherd I should have posted a follow up, but we used PR #24 as well and it fixed the issue for us as well, thanks!

shaunr0b commented 2 years ago

Ran into this issue

this command fixed it:

MIX_ENV=test mix deps.compile --force assertions

rizasal commented 2 years ago

This issue still exists and is causing builds to fail. Any update here? @devonestes