Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hellocomet/graphql-codegen-typescript-operations-tester
graphql-code-generator plugin to generate test functions on operations
https://github.com/hellocomet/graphql-codegen-typescript-operations-tester
codegen codegeneration codegenerator graphql graphql-code-generator graphql-codegen graphql-schema plugin schema test testing-tools typescript
Last synced: about 1 month ago
JSON representation
graphql-code-generator plugin to generate test functions on operations
- Host: GitHub
- URL: https://github.com/hellocomet/graphql-codegen-typescript-operations-tester
- Owner: hellocomet
- License: mit
- Created: 2021-02-12T14:24:02.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-26T07:03:31.000Z (over 3 years ago)
- Last Synced: 2024-10-12T13:20:30.364Z (2 months ago)
- Topics: codegen, codegeneration, codegenerator, graphql, graphql-code-generator, graphql-codegen, graphql-schema, plugin, schema, test, testing-tools, typescript
- Language: TypeScript
- Homepage:
- Size: 596 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graphql-codegen-typescript-operations-tester
[![Version](https://img.shields.io/npm/v/graphql-codegen-typescript-operations-tester.svg)](https://www.npmjs.com/package/graphql-codegen-typescript-operations-tester)
![Test workflow](https://github.com/hellocomet/graphql-codegen-typescript-operations-tester/workflows/Tests/badge.svg?branch=main)
![Release workflow](https://github.com/hellocomet/graphql-codegen-typescript-operations-tester/workflows/Release%20package/badge.svg)## Install
`npm i -D @graphql-codegen/typescript @graphql-codegen/typescript-operations graphql-codegen-typescript-operations-tester`
## Example
codegen.yml
```yaml
schema: ['./schema.graphql']generated/tests.ts:
documents: './documents.graphql'
plugins:
- typescript
- typescript-operations
- graphql-codegen-typescript-operations-tester
config:
prefix: test
```schema.graphql
```graphql
type Author {
firstname: String
lastname: String
fullname: String
}type Book {
title: String
author: Author
}type Query {
books: [Book]
}
```documents.graphql
```graphql
query getBooks($var1: String!) {
books(var1: $var1) {
title
author {
firstname
lastname
fullname
}
}
}
```test.spec.ts
```typescript
import { testGetBooksQuery } from './generated/tests.ts'
import { schema } from 'path/to/my/schema'describe('Test something cool', () => {
it('testGetBooksQuery should return something', async () => {
const res = await testGetBooksQuery({ schema }, { var1: 'hello' })
expect(res.data?.books).toBeAwesome()
})
})
```