Packages
mob
0.6.13
0.7.20
0.7.19
0.7.18
0.7.17
0.7.16
0.7.15
0.7.14
0.7.13
0.7.12
0.7.11
0.7.10
0.7.9
0.7.8
0.7.7
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.26
0.6.25
0.6.24
0.6.23
0.6.22
0.6.21
0.6.20
0.6.19
0.6.18
0.6.17
0.6.16
0.6.15
0.6.14
0.6.13
0.6.12
0.6.11
0.6.10
0.6.9
0.6.8
0.6.7
0.6.6
0.6.5
0.6.2
0.6.1
0.6.0
0.5.18
0.5.17
0.5.16
0.5.15
0.5.14
0.5.11
0.5.10
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.0
0.3.10
0.3.9
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.0
0.1.0
BEAM-on-device mobile framework for Elixir
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/mob.onboarding_test.ex
defmodule Mix.Tasks.Mob.OnboardingTest do
@shortdoc "Run the Mob onboarding integration test suite"
@moduledoc """
Runs the Mob onboarding integration tests, which verify that a new user can
go from zero to a running app without hitting any friction that should have
been caught automatically.
## Usage
mix mob.onboarding_test # pre-device tests only (fast)
mix mob.onboarding_test --all # all tests including post-device
mix mob.onboarding_test --only generator
mix mob.onboarding_test --only failure_modes
mix mob.onboarding_test --only pre_device
mix mob.onboarding_test --only post_device
## Options
--all Run all onboarding tests, including those that need a
booted iOS simulator or Android emulator
--only TAG Run only tests with this tag
--env ENV Toolchain environment to report in output (mise|asdf|nix|brew)
--seed N ExUnit seed (passed through to mix test)
--no-color Disable ANSI colors in output
## What this runs
Tests live in `test/onboarding/` and are tagged `:onboarding`. They are
excluded from the normal `mix test` run to avoid slowing down the development
loop.
Sub-tags:
- `:generator` — Stage 1–4: archive install, project gen, install, doctor
- `:failure_modes` — All failure injection tests
- `:pre_device` — Failure tests that require no simulator/emulator
- `:post_device` — Failure tests that require a running simulator/emulator
## Workspace isolation
Each test creates a fresh temp directory under `/tmp/mob_onboarding_<id>/`
with its own MIX_HOME, HEX_HOME, and MOB_CACHE_DIR. On success the workspace
is deleted. On failure it is preserved and its path is printed so you can
inspect logs and the generated project.
"""
use Mix.Task
@switches [
all: :boolean,
only: :string,
env: :string,
seed: :integer,
no_color: :boolean
]
@impl Mix.Task
def run(argv) do
{opts, _rest, _invalid} = OptionParser.parse(argv, strict: @switches)
include_tags = build_include_tags(opts)
test_args = build_test_args(opts, include_tags)
banner(opts)
System.put_env("MIX_ENV", "test")
exit_code =
Mix.shell().cmd("mix test test/onboarding/ #{Enum.join(test_args, " ")}")
if exit_code != 0, do: Mix.raise("Onboarding tests failed (exit #{exit_code})")
end
# ── Private ───────────────────────────────────────────────────────────────────
defp build_include_tags(opts) do
# Tags use simple atoms (:generator, :pre_device, etc.) combined with the
# module-level :onboarding tag. --only overrides the global exclusion of
# :onboarding so all onboarding subtests get included.
cond do
opts[:all] -> ["onboarding"]
opts[:only] -> [opts[:only]]
true -> ["generator", "pre_device"]
end
end
defp build_test_args(opts, include_tags) do
args = Enum.flat_map(include_tags, fn tag -> ["--only", tag] end)
args = if seed = opts[:seed], do: args ++ ["--seed", "#{seed}"], else: args
args = if opts[:no_color], do: args ++ ["--no-color"], else: args
args
end
defp banner(opts) do
env_label = opts[:env] || "default"
scope = if opts[:all], do: "all tests", else: opts[:only] || "generator + pre-device"
Mix.shell().info("""
╔══════════════════════════════════════════════════════╗
║ Mob Onboarding Integration Tests ║
║ Scope: #{String.pad_trailing(scope, 44)}║
║ Env: #{String.pad_trailing(env_label, 44)}║
╚══════════════════════════════════════════════════════╝
""")
end
end