test_that_json alternatives and similar packages
Based on the "Testing" category.
Alternatively, view test_that_json alternatives based on common mentions on social networks and blogs.
-
hound
Elixir library for writing integration tests and browser automation -
proper
PropEr: a QuickCheck-inspired property-based testing tool for Erlang -
bypass
Bypass provides a quick way to create a custom plug that can be put in place instead of an actual HTTP server to return prebaked responses to client requests. -
StreamData
Data generation and property-based testing for Elixir. ๐ฎ -
ExVCR
HTTP request/response recording library for elixir, inspired by VCR. -
propcheck
Property based Testing for Elixir (based upon PropEr) -
excheck
Property-based testing library for Elixir (QuickCheck style). -
amrita
A polite, well mannered and thoroughly upstanding testing framework for Elixir -
ponos
ponos is a simple yet powerful load generator written in erlang -
power_assert
Power Assert in Elixir. Shows evaluation results each expression. -
shouldi
Elixir testing libraries with nested contexts, superior readability, and ease of use -
FakerElixir
[unmaintained] FakerElixir generates fake data for you. -
katt
KATT (Klarna API Testing Tool) is an HTTP-based API testing tool for Erlang. -
FakeServer
FakeServer integrates with ExUnit to make external APIs testing simpler -
Stubr
Stubr is a set of functions helping people to create stubs and spies in Elixir. -
Mockery
Simple mocking library for asynchronous testing in Elixir. -
mecks_unit
A simple Elixir package to elegantly mock module functions within (asynchronous) ExUnit tests using Erlang's :meck library -
mix_test_interactive
Interactive watch mode for Elixir's mix test. https://hexdocs.pm/mix_test_interactive/ -
Walkman
Isolate tests from the real world, inspired by Ruby's VCR. -
test_selector
Elixir library to help selecting the right elements in your tests. -
factory_girl_elixir
Minimal implementation of Ruby's factory_girl in Elixir. -
toxiproxy_ex
ToxiproxyEx is an Elixir API client for the resilience testing tool Toxiproxy. -
ex_parameterized
This library support parameterized test with test_with_params macro. -
mix_erlang_tasks
Common tasks for Erlang projects that use Mix -
cobertura_cover
Output test coverage information in Cobertura-compatible format -
ex_unit_fixtures
A library for defining modular dependencies (fixtures) for ExUnit tests.
Tired of breaking your main and manually rebasing outdated pull requests?
Do you think we are missing an alternative of test_that_json or a related project?
README
Test That JSON!
Helpers for a better JSON testing experience in Elixir.
Using ESpec? Check out test_that_json_espec.
Docs
For now, see the Json
module for docs for much of the API.
This project has an extensive test suite, so see that for detailed usage.
Helpers
- [X]
has_json_keys
- [X]
has_only_json_keys
- [X]
has_json_values
- [X]
has_only_json_values
- [X]
has_json_properties
- [X]
has_only_json_properties
- [X]
has_json_path
- [X]
has_json_size
- [X]
has_json_type
- [X]
is_json_equal
- [X]
load_json
- [X]
load_json!
- [X]
parse_json
- [X]
parse_json!
- [X]
prettify_json
- [X]
prettify_json!
- [X]
to_json
- [X]
to_json!
- [X]
to_prettified_json
- [X]
to_prettified_json!
Additional Functionality
- [ ] Helpers that return a boolean can optionally take a path
- [ ] Helpers can be composed together w/ the pipe |> operator
Example
defmodule MyProject.ExampleTest
use ExUnit.Case
import TestThatJson.Helpers
test "verifying JSON key presence" do
json = load_json("test/support/json/valid.json") # example helper use
assert has_json_keys(["key1", "key2"])
end
end
Test That JSON! has extensive tests, but they're mostly written as ESpec specs because I like that style for complex testing. See the test
directory for some basic happy-path tests, and the spec
directory for detailed use cases.
Installation
- Add
test_that_json
as a test-only dependency inmix.exs
:
def deps do
[
{:test_that_json, "~> 0.6.0", only: :test},
]
end
Configuration
Key Exclusion
By default, to avoid needing to know the values of these ahead of time, the following keys are ignored for all JSON objects: id
, inserted_at
, and updated_at
.
This can be reconfigured as follows:
config :test_that_json,
excluded_keys: ~w(id inserted_at updated_at some other keys)
Paths
These are simple strings of "/"-separated object keys and array indexes passed to has_json_path
. For instance, with the following JSON:
{
"first_name": "Jon",
"last_name": "Snow",
"friends": [
{
"first_name": "Know",
"last_name": "Nothing"
}
]
}
We could access the first friend's first name with the path "friends/0/first_name".
Project Chores
- [X] Tests
- [ ] Docs for entire helper API
Related Projects
Thanks
Thanks to the creators and maintainers of the Ruby json_spec project for heavy inspiration.
Contributing
- Before opening a pull request, please open an issue first.
- Do the usual fork/add/fix/run tests dance, or whatever tickles your fancy. Tests are highly encouraged.
- Open a PR.
- Treat yourself. You deserve it.
License
See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).
*Note that all licence references and agreements mentioned in the test_that_json README section above
are relevant to that project's source code only.