Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lessthanseventy committed Apr 24, 2023
1 parent 9ca3920 commit a2fe91c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
7 changes: 0 additions & 7 deletions lib/mix/tasks/excessibility.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule Mix.Tasks.Excessibility do
@moduledoc "Library to aid in testing your application for WCAG compliance automatically using Pa11y and Wallaby."
@shortdoc "Runs pally against generated snapshots"
@requirements ["app.config"]
@assets_task Application.compile_env(:excessibility, :assets_task, "assets.deploy")
@pally_path Application.compile_env(
:excessibility,
:pa11y_path,
Expand All @@ -20,12 +19,6 @@ defmodule Mix.Tasks.Excessibility do

@impl Mix.Task
def run(_args) do
Mix.Task.run(@assets_task)

File.mkdir_p("#{@ex_assets_path}/css/")
File.mkdir_p("#{@ex_assets_path}/js/")
File.mkdir_p("#{@snapshots_path}/")

File.ls!(@snapshots_path)
|> filter_dirs()
|> run_pa11y()
Expand Down
18 changes: 7 additions & 11 deletions test/excessibility_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,32 @@ defmodule ExcessibilityTest do

import ExUnit.CaptureIO

@output_path "test/excessibility"
@snapshots_path "#{@output_path}/html_snapshots"
@ex_assets_path "#{@output_path}/assets"
@snapshots_path "test/excessibility/html_snapshots"

describe "run/1" do
@describetag :flipper
test "when all pa11y checks pass" do
Mix.Project.in_project(:test_pass, "test_pass/", fn _ ->
assert capture_io(fn ->
refute capture_io(fn ->
Mix.Task.run("excessibility")
end) =~
end)
|> IO.inspect() =~
"Error:"
|> IO.inspect()
end)
end

test "when a pa11y check fails" do
Mix.Project.in_project(:test_fail, "test_fail/", fn _ ->
assert capture_io(fn ->
Mix.Task.run("excessibility")
end) =~
end)
|> IO.inspect() =~
"Error:"
|> IO.inspect()
end)
end

test "creates necessary directories for assets" do
Mix.Project.in_project(:test_pass, "test_pass/", fn _ ->
assert File.exists?("#{@ex_assets_path}/css")
assert File.exists?("#{@ex_assets_path}/js")
assert File.exists?("#{@snapshots_path}")
end)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test_fail/test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ExUnit.start(exclude: [:flipper])
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(TestFail.Repo, :manual)

0 comments on commit a2fe91c

Please sign in to comment.