Github test - #8
Conversation
| "chai-json-schema": "^1.5.1", | ||
| "isomorphic-fetch": "^3.0.0", | ||
| "md5": "^2.3.0" |
There was a problem hiding this comment.
these should be dev dependencies, run the following command to fix it:
npm i -D chai-json-schema isomorphic-fetch md5
| chai.use(chaiSubset); | ||
|
|
||
| describe('Github Api Repositories Test', () => { | ||
| let responseData; |
There was a problem hiding this comment.
you can rename it as userDataResponse
| expect(response.data.name).to.equal(data.name); | ||
| expect(response.data.location).to.equal(data.location); | ||
| expect(response.data.company).to.equal(data.company); | ||
| responseData = response; |
There was a problem hiding this comment.
this is redundant you don't need the response const
|
|
||
| describe('Github Api Repositories Test', () => { | ||
| let responseData; | ||
| let repoName; |
There was a problem hiding this comment.
instead of repoName you can rename it as jasmineRepo or something similar
| }); | ||
|
|
||
| describe('Consume POST and PATCH service on Github', () => { | ||
| let loggedIn; |
There was a problem hiding this comment.
it is more descriptive userData
| } | ||
| }; | ||
|
|
||
| let gists; |
There was a problem hiding this comment.
better to rename it as createdGistResponse or similar
| it('Gists verification', async () => { | ||
| gistsInf = await auth.get(gists.data.url); | ||
|
|
||
| expect(gistsInf.status).to.be.equal(StatusCodes.OK); |
There was a problem hiding this comment.
add one expect to verify gist data returned and stored in gistInf is the same than created in previous test
| try { | ||
| await auth.get(gists.data.url); | ||
| } catch (err) { | ||
| expect(err.response.status).to.be.equal(StatusCodes.NOT_FOUND); | ||
| } |
There was a problem hiding this comment.
with this way, the test only will pass if the error happens, but, if no error is retreived the test will pass but it should fail, you can create a variable, and then initialize it in the catch, and outside of the try-catch sentence perform the validation of the NOT_FOUND status
| try { | ||
| await fetch(gist.url, getBody); | ||
| } catch (err) { | ||
| expect(err.response.status).to.be.equal(StatusCodes.NOT_FOUND); | ||
| } |
There was a problem hiding this comment.
with this way, the test only will pass if the error happens, but, if no error is retreived the test will pass but it should fail, you can create a variable, and then initialize it in the catch, and outside of the try-catch sentence perform the validation of the NOT_FOUND status
|
OMG, you owe me a coffee for this large PR 😓 |
Uh oh!
There was an error while loading. Please reload this page.