Skip to content

Perform snapshot testing using md files #983

Closed
@tusharmath

Description

@tusharmath

Currently, our test suite is all over the place with various ways of writing and asserting test. I would like to propose an easier way of writing, executing and updating tests.

Proposal

  • Use Insta Snapshots to create and manage snapshot of outputs.

  • Use a markdown file to write tests using a mix of GraphQL, YAML or JSON syntax.


    config:

    type Query {
      greetings: String @const(data: "Hello World!")
    }

    assert:

    assert:
      - request:
          method: POST
          url: http://localhost:8080/graphql
          body:
            query: "query { greetings }"
        response:
          body:
            data:
              greetings: Hello World

Technical Requirements

  • Write a module that can convert all existing tests automatically to this new format. It can read the existing YAML files and generate a combined .md with the config embedded it it.
  • In the first run a series of snapshots should be generated:
    • Client SDL snapshots
    • Expected response snapshots
  • This approach should allow us to merge http_spec and graphql_spec into one spec. Call it execution_spec.
  • The md file may or may not have an assertion block in it. If it does have an assert block, use it to run the execution spec.
  • We could have more than one assertion in an MD file.
  • Do not touch the existing specs. We will delete them after a month of regression.
  • Make sure there is proper logging of what tests passed and what has failed.
  • There is an ability to run only one test using an annotation, make sure that also works in markdown.

Links
Youtube: https://www.youtube.com/watch?v=rCHrMqE4JOY&t=2s

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions