Packages
mneme
0.10.0
0.10.2
0.10.1
0.10.0
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.9.0-alpha.1
0.9.0-alpha.0
0.8.2
0.8.1
0.8.0
0.7.0
0.6.1
0.6.0
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.3.0-rc.1
0.3.0-rc.0
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
Snapshot testing tool using familiar assertions
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/mneme.test.ex
defmodule Mix.Tasks.Mneme.Test do
@shortdoc "Run tests with support for Mneme's options at the command line"
@moduledoc """
#{@shortdoc}
This task is like `mix test`, except that it accepts some command line
options specific to Mneme. See ["Command line options"](#module-command-line-options)
below.
## Setup
To ensure `mix mneme.test` runs in the test environment, add a
`:preferred_cli_env` entry in `mix.exs`:
def project do
[
...
preferred_cli_env: [
"mneme.test": :test,
"mneme.watch": :test
],
...
]
end
## Command line options
In addition to the options supported by `mix test`, which runs under
the hood, the following CLI options are available:
* `--action [prompt,accept,reject]`
* `--default-pattern [infer,first,last]`
* `--diff [text,semantic]`
* `--diff-style [side_by_side,stacked]`
* `--force-update`
* `--target [mneme,ex_unit]`
Option documentation is found here: [Mneme – Options](`Mneme#module-options`)
"""
use Mix.Task
@switches [
action: :string,
default_pattern: :string,
diff: :string,
diff_style: :string,
force_update: :boolean,
target: :string,
dry_run: :boolean
]
# Ensure that these switches are collected instead of all but last
# discarded so that they can be passed to `mix test`.
@mix_test_keep [
include: :keep,
exclude: :keep,
only: :keep,
formatter: :keep
]
@impl Mix.Task
def run(argv) do
{opts, argv} = OptionParser.parse!(argv, switches: @switches ++ @mix_test_keep)
{opts, mix_test_opts} = Keyword.split(opts, Keyword.keys(@switches))
mix_test_argv = OptionParser.to_argv(mix_test_opts) ++ argv
Application.put_env(:mneme, :cli_opts, opts)
Mix.Task.reenable("test")
Mix.Task.run("test", mix_test_argv)
end
end