FaktoryWorker.Testing.assert_enqueued

You're seeing just the function assert_enqueued, go back to FaktoryWorker.Testing module for more information.
Link to this function

assert_enqueued(worker_mod, filters \\ [])

View Source

Specs

assert_enqueued(module(), args: list(), opts: Keyword.t()) :: true

Assert that a job was enqueued for the given job module, optionally matching a set of argument/option filters. By default, this assertion will fail if more than one matching job is found. If you want to assert that multiple matching jobs are enqueued, you can use the :count option. If you want the assertion to pass if at least one matching job is enqueued, pass count: :any (this should generally be discouraged in favor of a specific count, to help catch accidental duplicate enqueues).

Examples

defmodule MyApp.Test do
  use ExUnit.Case

  import FaktoryWorker.Testing

  setup :reset_queues

  test "enqueues" do
    MyApp.Job.perform_async("argument")

    # assert that _any_ job was enqueued for this module
    assert_enqueued MyApp.Job

    # assert that a specific job was enqueued
    assert_enqueued MyApp.Job, args: ["argument"]

    # assert on multiple arguments (order matters)
    assert_enqueued MyApp.Job, args: ["foo", "bar"]

    # assert that two matching jobs were enqueued
    assert_enqueued MyApp.Job, args: ["foo", "bar"], count: 2

    # assert on serializable arguments
    assert_enqueued MyApp.Job, args: [%MyApp.User{...}]

    # assert on options (only those explicitly passed to `perform_async`)
    assert_enqueued MyApp.Job, opts: [reserve_for: 1_500]

    # assert on multiple filters
    assert_enqueued MyApp.Job, args: ["foo", "bar"], opts: [custom: %{}]
  end
end