Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sadabnepal/graphql-supertest-api
GraphQL API Test framework using TypeScript supertest library and mocha framework
https://github.com/sadabnepal/graphql-supertest-api
graphql graphql-testing mocha supertest supertest-mocha-chai type-utility types typescript
Last synced: 2 days ago
JSON representation
GraphQL API Test framework using TypeScript supertest library and mocha framework
- Host: GitHub
- URL: https://github.com/sadabnepal/graphql-supertest-api
- Owner: sadabnepal
- Created: 2024-05-13T08:34:57.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-06-25T00:40:45.000Z (8 months ago)
- Last Synced: 2024-12-25T18:41:34.800Z (about 2 months ago)
- Topics: graphql, graphql-testing, mocha, supertest, supertest-mocha-chai, type-utility, types, typescript
- Language: HTML
- Homepage:
- Size: 612 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# GraphQL Test Automation framework
Boilerplate graphql test framework using Mocha, SuperTest and TypeScript.### Pre-requisite:
[](https://nodejs.org/en/download/)
[](https://code.visualstudio.com/download)### Getting Started
Clone Repository
```bash
git clone https://github.com/sadabnepal/graphql-supertest-api.git
cd graphql-supertest-api
```Install packages:
```bash
npm install
```Setup user token:
```bash
- Open the URL 'https://gorest.co.in/'
- Login or Sign
- Click on Login user drop down --> Access Token --> Copy token
- Create .env file in root project folder
- paster actual token `GO_RES_USER_TOKEN=`, refer .env.example file
```Setup husky:
```bash
npm run prepare
```Run tests:
```bash
npm run test
```Lint & fix:
```bash
npm run lint
npm run lint:fix
```Github Actions :
Currently test is setup to execute in github action on push event. You need to [create github secrete](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) with name `API_TOKEN` and value generated in `Setup user token` step.
Github Permission to update report: Go to Repository -> Settings -> Actions -> General
Scroll to bottom of the page and look for 'Workflow permissions' section
Check 'Read and write permission' and click on saveSample Report
### Features:
- Supertest library
- Mocha framework to organize tests
- Mochawesome report integration with logs
- Custom types for better code intellisense
- Github Action integration
- Lint for better code quality
- Husky for auto lint check before code commit
- Manage secretes using dotenv library
- Runtime dynamic test data generation using faker js library### Tech stacks:
[](https://www.npmjs.com/package/supertest)
[](https://www.npmjs.com/package/supertest)
[](https://www.typescriptlang.org/)
[](https://mochajs.org/)
[](https://www.chaijs.com/)
[](https://github.com/features/actions)
[]([https://www.docker.com/](https://typescript-eslint.io/))
[]([https://www.docker.com/](https://typicode.github.io/husky/))### learning references:
| topic | references |
|-----------------|-------------------------------------------------------------|
| GraphQL | https://graphql.org/learn |
| SuperTest | https://github.com/ladjs/supertest#readme |
| Mocha | https://ricostacruz.com/mocha/ |
| Mocha config | https://github.com/mochajs/mocha/tree/master/example/config |
| TS style guide | https://google.github.io/styleguide/tsguide.html |
| ChaiJs | https://www.chaijs.com |
| Mochawesome | https://github.com/adamgruber/mochawesome |
| DotEnv | https://www.npmjs.com/package/dotenv |
| Eslint | https://eslint.org/docs/latest/use/getting-started |
| Husky | https://typicode.github.io/husky/ |
| VScode settings | https://code.visualstudio.com/docs/getstarted/settings |### GraphQL Topics to Explore
- [x] basics of GraphQL (query, mutation)
- [ ] advance topics (fragments, unions, aliases)
- [x] filters using arguments, variables, directive
- [ ] setting default variable
- [ ] variables inside fragments
- [ ] use of directive to build dynamic/reusable query
- [ ] fields in query vs fields in mutation
- [ ] inline fragments (unions)
- [ ] meta fields (fetch type of field __typename)