graphql-framework-experiment icon indicating copy to clipboard operation
graphql-framework-experiment copied to clipboard

Testing system

Open jasonkuhrt opened this issue 5 years ago • 2 comments

Perceived Problem

  • setting up testing is too hard
    • remember to set testEnvironment to node otherwise hitting false negatives like this (I came to that issue after hitting interval.unref is not a function in a santa project b/c of getPort because wasn't node testEnvironment.

    • remember to install ts-jest and use its preset (and probably have issues down the line)

    • remember to install prettier if using toMatchInlineSnapshot (issue):

        ```
        ● info  app:shutdown  --  reason: overheat
        ● info  app:engine-room:loaded  --  duration: 500
        ● info  app:engine-room:ok  --  root: data
        ● info  app:engine-room:statusChange  --  root: data  color: red  newStatus: offline
         FAIL  tests/integration.spec.ts
          ● Test suite failed to run
      
            Cannot find module 'prettier' from 'setup_jest_globals.js'
      
              at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
        ```
      
  • when working from a fresh start user needs to run generation before test suite. This is transparent to them in build and dev workflows, so to should it be in test workflow.
  • We suggest patterns that smell like boilerplate

Ideas / Proposed Solution(s)

  • nexus test
  • ...

Other Points

  • precedent: tsdx wraps jest for a better experience

jasonkuhrt avatar Jan 21 '20 02:01 jasonkuhrt

We've had some time to think about this. Status of my thoughts:

  • Still think we should have nexus test

  • Think it should be based on, wrap, jest

  • Sane defaults:

    • colocated unit test modules
    • support needed tsconfig settings for this tricky pattern
    • node environment, not jsdom
    • fully managed base jest config like we do for tsconfig
    • ts-jest auto config
  • vscode debugger test integration if needed

  • vscode test explorer integration if needed

  • bundle jest

  • bundle ts-jest

  • bundle https://github.com/mattphillips/jest-chain

  • bundle https://github.com/jest-community/jest-extended#typescript

  • bundle https://github.com/jest-community/jest-watch-typeahead

  • bundle https://github.com/unional/jest-watch-suspend

    • make suspend on watch init to avoid running potentially many system tests you don't actually want to run
  • ? bundle https://github.com/Raathigesh/majestic

  • ? bundle https://github.com/zaqqaz/jest-allure

  • ? bundle https://github.com/hipstersmoothie/jest-github-reporter

  • ? a jest plugin that allows for interactive Nexus-aware testing features https://jestjs.io/docs/en/watch-plugins#hooking-into-jest, examples:

    • pass a log filter
    • ...?

jasonkuhrt avatar Jun 28 '20 03:06 jasonkuhrt

Would it not be simpler to wrap vitest than jest.

With jest we also need to configure ts-jest. vitest comes with ts support from the box.

with vitest you have almost zero congifuration. I also think that the nexus tutorial would benefit from vitest's simplicity.

ulisses-cruz avatar Mar 08 '22 01:03 ulisses-cruz