A test framework for
async_graphql API servers in
Rust.
Currently, it's published "as is" and barely documented.
- Widely-supported, plain-text format:
- Test cases as plain
.graphqlfiles. - Assertions as GraphQL directives.
- Great IDE support. Interactive tweaking/debugging in GraphQL Playground, etc.
- No rebuilds after editing your test cases!
- Test cases as plain
- Flexible, performant and lightweight:
- Async runtime-agnostic. The crate is just "plumbing", "pure", in-memory logic.
- No HTTP/TLS stack required. Can read GraphQL inputs directly from memory.
- In fact, we only depend on
async_graphqland its dependencies (you already depend on those), anditertools. - The crate is just a few functions. You can add arbitrary setup/teardown around those.
- Integrate a snapshot testing library and snapshot the output.
# Queries and mutations are executed from top to bottom.
#
# Use @directives to assert the relevant outputs directly,
# or integrate a snapshot testing library and snapshot the full server output.
# 1.
query initialUsers {
users @shouldHaveLength(n: 0) {
name
}
}
# 2.
mutation createUser {
createUser(form: {name: "John Doe"}) {
name @shouldBeEqual(to: "John Doe")
deletedAt @shouldBeNull
}
}
# 3.
query doubleCheckPersistenceUsingASeparateQuery {
users @shouldHaveLength(n: 1) {
name @shouldBeEqual(to: "John Doe")
deletedAt @shouldBeNull
}
}Assuming the following schema:
input UserForm {
name: String!
}
type User {
name: String!
deletedAt: String
}
type Query {
users: [User!]!
}
type Mutation {
createUser(form: UserForm!): User!
}Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.