ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - joshrieken/test_that_json: JSON-related helpers for your Elixir testing needs
JSON-related helpers for your Elixir testing needs - joshrieken/test_that_json
Visit Site

GitHub - joshrieken/test_that_json: JSON-related helpers for your Elixir testing needs

GitHub - joshrieken/test_that_json: JSON-related helpers for your Elixir testing needs

Test That JSON!

Helpers for a better JSON testing experience in Elixir.

Build Status Inline docs

Using ESpec? Check out test_that_json_espec.

Docs

All 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

  • has_json_keys
  • has_only_json_keys
  • has_json_values
  • has_only_json_values
  • has_json_properties
  • has_only_json_properties
  • has_json_path
  • has_json_size
  • has_json_type
  • is_json_equal
  • load_json
  • load_json!
  • parse_json
  • parse_json!
  • prettify_json
  • prettify_json!
  • to_json
  • to_json!
  • to_prettified_json
  • 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

  1. Add test_that_json as a test-only dependency in mix.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

  • 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

  1. Before opening a pull request, please open an issue first.
  2. Do the usual fork/add/fix/run tests dance, or whatever tickles your fancy. Tests are highly encouraged.
  3. Open a PR.
  4. Treat yourself. You deserve it.

License

See the LICENSE file for license rights and limitations (MIT).

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory