- Notifications
You must be signed in to change notification settings - Fork2
Elixir library to help selecting the right elements in your tests.
License
NotificationsYou must be signed in to change notification settings
DefactoSoftware/test_selector
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A set of Elixir helpers to set/get test selectors to/from elements in a Phoenix app (whenMix.env == :test
). These selectors are hashed (scoped to the view module they are used in) for accurate selection and "leakage" prevention. See ourWiki for examples.
Why? Because we prefer reserving classes for styling, and id's have limitations because they have to be unique.
- Floki v0.25.x and higher
defdepsdo[{:test_selector,"~> 0.3.3"}]end
UseTestSelector.HTML.Helpers
to your web.ex.
- In phoenix 1.2.0 at
web/web.ex
- In newer Phoenix versions
lib/your_project/web/web.ex
Add somewhere along:
defview(opts\\[])doquotedo...usePhoenix.HTMLuseTestSelector.HTML.Helpers...endend
Testing with Floki
In the tests import theTestSelector.Test.FlokiHelpers
:
defmoduleProject.Web.MyTestdo...importTestSelector.Test.FlokiHelpers...end
Run the tests:
mix test
Copyright (c) 2017 Defacto
Released under the MIT License, which can be found in the repository inLICENSE.md.