chore: add tests

This commit is contained in:
StarpTech 2023-02-27 13:36:40 +01:00
parent aab6173f05
commit 6672e6c369
5 changed files with 5874 additions and 499 deletions

View File

@ -14,6 +14,12 @@ Fetch all SpaceX Dragons from your WunderGraph.
curl -X GET http://localhost:9991/operations/Dragons
```
### Run tests
```shell
npm test
```
### Deploy to WunderGraph Cloud
1. Fork this repo

8
jest.config.js Normal file
View File

@ -0,0 +1,8 @@
module.exports = {
roots: ['<rootDir>/test/'],
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
testRegex: '(/__tests__/.*|\\.(test|spec))\\.[tj]sx?$',
moduleFileExtensions: ['ts', 'js'],
};

6332
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,15 +5,20 @@
"scripts": {
"start": "wunderctl up --debug",
"build": "wunderctl generate --debug",
"check": "tsc --noEmit"
"check": "tsc --noEmit",
"test": "jest"
},
"author": "",
"license": "ISC",
"dependencies": {
"@wundergraph/sdk": "^0.134.0"
"@wundergraph/sdk": "0.134.0"
},
"devDependencies": {
"@jest/globals": "^29.4.3",
"@swc/core": "^1.3.36",
"@swc/jest": "^0.2.24",
"@types/node": "^14.14.37",
"typescript": "^4.8.2"
"jest": "^29.4.3",
"typescript": "^4.9.5"
}
}

16
test/index.test.ts Normal file
View File

@ -0,0 +1,16 @@
import { afterAll, beforeAll, describe, expect, test } from '@jest/globals';
import { createTestServer } from '../.wundergraph/generated/testing';
const wg = createTestServer();
beforeAll(() => wg.start());
afterAll(() => wg.stop());
describe('SpaceX API', () => {
test('Should return dragons', async () => {
const result = await wg.client().query({
operationName: 'Dragons',
});
const dragons = result.data?.spacex_dragons;
expect(dragons?.length).toBeGreaterThan(0);
});
});