diff --git a/.gitignore b/.gitignore index 1a650f6..1dcef2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ node_modules -report/ .env \ No newline at end of file diff --git a/report/index.html b/report/index.html new file mode 100644 index 0000000..c3c2a82 --- /dev/null +++ b/report/index.html @@ -0,0 +1,17 @@ + +Mochawesome Report
\ No newline at end of file diff --git a/report/index.json b/report/index.json new file mode 100644 index 0000000..04d194f --- /dev/null +++ b/report/index.json @@ -0,0 +1,246 @@ +{ + "stats": { + "suites": 1, + "tests": 8, + "passes": 8, + "pending": 0, + "failures": 0, + "start": "2024-05-13T09:22:40.875Z", + "end": "2024-05-13T09:22:43.802Z", + "duration": 2927, + "testsRegistered": 8, + "passPercent": 100, + "pendingPercent": 0, + "other": 0, + "hasOther": false, + "skipped": 0, + "hasSkipped": false + }, + "results": [ + { + "uuid": "590e966a-09cf-410b-a537-29013d118d1a", + "title": "", + "fullFile": "/Users/mohammadsadabsaqib/Developer/TestProjects/graphql-supertest-api/tests/specs/goRestTests.ts", + "file": "/tests/specs/goRestTests.ts", + "beforeHooks": [], + "afterHooks": [], + "tests": [], + "suites": [ + { + "uuid": "3fe182e2-09f9-4383-9210-38e04492dc10", + "title": "go rest graphql tests", + "fullFile": "/Users/mohammadsadabsaqib/Developer/TestProjects/graphql-supertest-api/tests/specs/goRestTests.ts", + "file": "/tests/specs/goRestTests.ts", + "beforeHooks": [], + "afterHooks": [], + "tests": [ + { + "title": "should query all users", + "fullTitle": "go rest graphql tests should query all users", + "timedOut": false, + "duration": 703, + "state": "passed", + "speed": "slow", + "pass": true, + "fail": false, + "pending": false, + "context": null, + "code": "", + "err": {}, + "uuid": "7d50d26e-bf2e-42ae-b9fc-1e86a13b5441", + "parentUUID": "3fe182e2-09f9-4383-9210-38e04492dc10", + "isHook": false, + "skipped": false + }, + { + "title": "should create user", + "fullTitle": "go rest graphql tests should create user", + "timedOut": false, + "duration": 303, + "state": "passed", + "speed": "slow", + "pass": true, + "fail": false, + "pending": false, + "context": null, + "code": "", + "err": {}, + "uuid": "a827a6ed-29d6-4f10-82b0-2fcd337717fa", + "parentUUID": "3fe182e2-09f9-4383-9210-38e04492dc10", + "isHook": false, + "skipped": false + }, + { + "title": "should query user by id", + "fullTitle": "go rest graphql tests should query user by id", + "timedOut": false, + "duration": 268, + "state": "passed", + "speed": "slow", + "pass": true, + "fail": false, + "pending": false, + "context": null, + "code": "", + "err": {}, + "uuid": "2e7f85ea-6307-4ae6-b309-648f938634a1", + "parentUUID": "3fe182e2-09f9-4383-9210-38e04492dc10", + "isHook": false, + "skipped": false + }, + { + "title": "should update user by id", + "fullTitle": "go rest graphql tests should update user by id", + "timedOut": false, + "duration": 299, + "state": "passed", + "speed": "slow", + "pass": true, + "fail": false, + "pending": false, + "context": null, + "code": "", + "err": {}, + "uuid": "89b2e1d6-b930-4ace-b506-07ea5518f333", + "parentUUID": "3fe182e2-09f9-4383-9210-38e04492dc10", + "isHook": false, + "skipped": false + }, + { + "title": "should delete user", + "fullTitle": "go rest graphql tests should delete user", + "timedOut": false, + "duration": 310, + "state": "passed", + "speed": "slow", + "pass": true, + "fail": false, + "pending": false, + "context": null, + "code": "", + "err": {}, + "uuid": "3722a09d-2b50-4e05-a6ac-1454edad8630", + "parentUUID": "3fe182e2-09f9-4383-9210-38e04492dc10", + "isHook": false, + "skipped": false + }, + { + "title": "should query non existing user by id", + "fullTitle": "go rest graphql tests should query non existing user by id", + "timedOut": false, + "duration": 298, + "state": "passed", + "speed": "slow", + "pass": true, + "fail": false, + "pending": false, + "context": null, + "code": "", + "err": {}, + "uuid": "2d95df69-bf64-4ee6-998e-360bf9099830", + "parentUUID": "3fe182e2-09f9-4383-9210-38e04492dc10", + "isHook": false, + "skipped": false + }, + { + "title": "should query user count only using directives", + "fullTitle": "go rest graphql tests should query user count only using directives", + "timedOut": false, + "duration": 389, + "state": "passed", + "speed": "slow", + "pass": true, + "fail": false, + "pending": false, + "context": null, + "code": "", + "err": {}, + "uuid": "c47b3c24-ba1d-45eb-a162-53ae66cc74f1", + "parentUUID": "3fe182e2-09f9-4383-9210-38e04492dc10", + "isHook": false, + "skipped": false + }, + { + "title": "should query user with all nodes using directives", + "fullTitle": "go rest graphql tests should query user with all nodes using directives", + "timedOut": false, + "duration": 350, + "state": "passed", + "speed": "slow", + "pass": true, + "fail": false, + "pending": false, + "context": null, + "code": "", + "err": {}, + "uuid": "60091fa2-7730-4a4c-9b10-bb6dbc506dba", + "parentUUID": "3fe182e2-09f9-4383-9210-38e04492dc10", + "isHook": false, + "skipped": false + } + ], + "suites": [], + "passes": [ + "7d50d26e-bf2e-42ae-b9fc-1e86a13b5441", + "a827a6ed-29d6-4f10-82b0-2fcd337717fa", + "2e7f85ea-6307-4ae6-b309-648f938634a1", + "89b2e1d6-b930-4ace-b506-07ea5518f333", + "3722a09d-2b50-4e05-a6ac-1454edad8630", + "2d95df69-bf64-4ee6-998e-360bf9099830", + "c47b3c24-ba1d-45eb-a162-53ae66cc74f1", + "60091fa2-7730-4a4c-9b10-bb6dbc506dba" + ], + "failures": [], + "pending": [], + "skipped": [], + "duration": 2920, + "root": false, + "rootEmpty": false, + "_timeout": 5000 + } + ], + "passes": [], + "failures": [], + "pending": [], + "skipped": [], + "duration": 0, + "root": true, + "rootEmpty": true, + "_timeout": 5000 + } + ], + "meta": { + "mocha": { + "version": "10.4.0" + }, + "mochawesome": { + "options": { + "quiet": false, + "reportFilename": "index", + "saveHtml": true, + "saveJson": true, + "consoleReporter": "spec", + "useInlineDiffs": false, + "code": false + }, + "version": "7.1.3" + }, + "marge": { + "options": { + "reportDir": "report", + "reportFilename": "index", + "reportTitle": "GraphQL Test Report", + "charts": "true", + "code": "false", + "inline": "true", + "autoOpen": "false", + "showPassed": "true", + "showFailed": "true", + "showPending": "true", + "showSkipped": "true", + "showHooks": "failed" + }, + "version": "6.2.0" + } + } +} \ No newline at end of file diff --git a/tests/specs/goRestTests.ts b/tests/specs/goRestTests.ts index 88831bf..e6b9b8f 100644 --- a/tests/specs/goRestTests.ts +++ b/tests/specs/goRestTests.ts @@ -8,12 +8,14 @@ import { queryAllUserPayload, queryUserByIdPayload } from '../payload/queries'; import { INonExistingUserError, IUser, IUserCreate, IUserDelete, IUserUpdate, IUsers } from '../types/users'; config(); +const TOKEN = process.env.GO_RES_USER_TOKEN; + describe('go rest graphql tests', () => { let userId: number; it('should query all users', async () => { - const response = await queryGraphQl(process.env.GO_RES_USER_TOKEN, queryAllUserPayload); + const response = await queryGraphQl(TOKEN, queryAllUserPayload); expect(response.statusCode).equal(200); const responseData: IUsers = response.body.data; @@ -34,7 +36,7 @@ describe('go rest graphql tests', () => { it('should create user', async () => { - const response = await mutateGraphQl(process.env.TOKEN, createUserPayload(createUserData.name, createUserData.gender, createUserData.email, createUserData.status)); + const response = await mutateGraphQl(TOKEN, createUserPayload(createUserData.name, createUserData.gender, createUserData.email, createUserData.status)); expect(response.statusCode).equal(200); const responseData: IUserCreate = response.body.data; @@ -54,7 +56,7 @@ describe('go rest graphql tests', () => { it('should query user by id', async () => { - const response = await queryGraphQl(process.env.TOKEN, queryUserByIdPayload(userId)); + const response = await queryGraphQl(TOKEN, queryUserByIdPayload(userId)); expect(response.statusCode).equal(200); expect(response.body.data).not.undefined; @@ -74,7 +76,7 @@ describe('go rest graphql tests', () => { it('should update user by id', async () => { - const response = await queryGraphQl(process.env.TOKEN, updateUserPayload(userId, updateUserData.name, updateUserData.gender, updateUserData.email, updateUserData.status)); + const response = await queryGraphQl(TOKEN, updateUserPayload(userId, updateUserData.name, updateUserData.gender, updateUserData.email, updateUserData.status)); expect(response.statusCode).equal(200); expect(response.body.data).not.undefined; @@ -95,7 +97,7 @@ describe('go rest graphql tests', () => { }); it('should delete user', async () => { - const response = await queryGraphQl(process.env.TOKEN, deleteUserPayload(userId)); + const response = await queryGraphQl(TOKEN, deleteUserPayload(userId)); expect(response.statusCode).equal(200); expect(response.body.data).not.undefined; @@ -116,7 +118,7 @@ describe('go rest graphql tests', () => { it('should query non existing user by id', async () => { - const response = await queryGraphQl(process.env.TOKEN, queryUserByIdPayload(userId)); + const response = await queryGraphQl(TOKEN, queryUserByIdPayload(userId)); expect(response.statusCode).equal(200); expect(response.body.data.user).to.be.null; @@ -133,7 +135,7 @@ describe('go rest graphql tests', () => { }); it('should query user count only using directives', async () => { - const response = await queryGraphQl(process.env.TOKEN, queryUsersWithNodeDirectivePayload(false)); + const response = await queryGraphQl(TOKEN, queryUsersWithNodeDirectivePayload(false)); expect(response.statusCode).equal(200); const responseData: IUsers = response.body.data; @@ -144,7 +146,7 @@ describe('go rest graphql tests', () => { }); it('should query user with all nodes using directives', async () => { - const response = await queryGraphQl(process.env.TOKEN, queryUsersWithNodeDirectivePayload(true)); + const response = await queryGraphQl(TOKEN, queryUsersWithNodeDirectivePayload(true)); expect(response.statusCode).equal(200); const responseData: IUsers = response.body.data;