Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utility module for black box testing #242

Closed
jasonkuhrt opened this issue Jan 8, 2020 · 3 comments
Closed

Utility module for black box testing #242

jasonkuhrt opened this issue Jan 8, 2020 · 3 comments
Labels
scope/testing type/feat Add a new capability or enhance an existing one

Comments

@jasonkuhrt
Copy link
Member

What

  • Support specification-based testing (aka. black box testing)

  • Abstract the running of the app

  • Abstract the running of multiple app instances

  • API sketch (based on prior discussion)

     import { createTestContext } from "santa"
     
     const ctx = createTestContext()
     
     beforeAll(async () => {
       await ctx.app.server.start()
     })
     
     afterAll(async () => {
       await ctx.app.server.stop()
     })
     
     it('answers back', () => {
       expect(ctx.app.query(`
         query {
           foo {
             bar
           }
         }
       `)
     }).resolves.toMatchSnapshot()	

Why

  • While exploring Website guide for testing #239 we discovered a few issues, including this one.
  • We want to make it easy for users to test their santa app.

How

  • We'll need to do random port finding, as there is a running app per test suite (file) and sharing a port would conflict
@jasonkuhrt jasonkuhrt added type/feat Add a new capability or enhance an existing one scope/testing labels Jan 8, 2020
@jasonkuhrt
Copy link
Member Author

jasonkuhrt commented Jan 8, 2020

CC @Weakky I sketched above that the server start/stop be an explicit part of the test context api. Thoughts? This would appear to allow context creation to be synchronous.

@jasonkuhrt
Copy link
Member Author

jasonkuhrt commented Jan 8, 2020

Our approach is validated by how Spectrum.app tests.

https://github.com/withspectrum/spectrum/blob/alpha/docs/api/graphql/testing.md

Also, I don't think promises work with snapshots directly. That's what I encountered once and would explain the approach taken by Spectrum.app:

	return request(query).then(result => {
      // Use Jest snapshot testing for neater tests and easier diffs
      expect(result).toMatchSnapshot();
    });

@Weakky
Copy link
Collaborator

Weakky commented Jan 14, 2020

Shipped by #243

@Weakky Weakky closed this as completed Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope/testing type/feat Add a new capability or enhance an existing one
Projects
None yet
Development

No branches or pull requests

2 participants