- Lean into config and types generated by
@graphql-codegen/typescriptand@graphql-codegen/typescript-resolvers
Create unit test files next to the implementation:
functionA.ts
functionA.spec.ts # Here's the unit test fileRun unit tests in this package:
nx test typescript-resolver-filesCreate new e2e test setup (with own codegen.yml and schema files) from template:
nx g @graphql-code-generator-plugins/workspace-plugin:typescript-resolver-files-add-e2e-test <test-name-in-kebab-case>The expected output of each test are the files generated by running codegen command, then committed. In CI/CD, all e2e tests are run and if there is a difference between the generated version in CI vs committed version, it will fail. In a way, this is similar to Jest's snapshot testing.
# Run one e2e test with no assertion
nx graphql-codegen typescript-resolver-files-e2e -c <test-name> --verbose
# Run all tests with no assertion
nx e2e-run typescript-resolver-files-e2e -c clean-run
# Run tests and assert. This is run in CI/CD.
nx e2e typescript-resolver-files-e2e