graphql-framework-experiment
graphql-framework-experiment copied to clipboard
Testing system
Perceived Problem
- setting up testing is too hard
-
remember to set
testEnvironment
tonode
otherwise hitting false negatives like this (I came to that issue after hittinginterval.unref is not a function
in a santa project b/c ofgetPort
because wasn'tnode
testEnvironment
. -
remember to install
ts-jest
and use its preset (and probably have issues down the line) -
remember to install
prettier
if usingtoMatchInlineSnapshot
(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
anddev
workflows, so to should it be intest
workflow. - We suggest patterns that smell like boilerplate
Ideas / Proposed Solution(s)
-
nexus test
- ...
Other Points
- precedent: tsdx wraps jest for a better experience
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
- ...?
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.