Adding Unit test cases for wrappedNodeFetch and adding github actions #59
Adding Unit test cases for wrappedNodeFetch and adding github actions #59Hermione2408 wants to merge 10 commits intokeploy:mainfrom
Conversation
|
Hi @re-Tick! Can you please review the PR? |
|
@Hermione2408 please resolve DCO and commitzen |
5cebecf to
7270469
Compare
|
Can you have a look now @re-Tick |
|
Hey @re-Tick , Can you please review the changes now |
|
a test is failing. I will try these changes locally and request changes if any. |
|
Sure I'll try to resolve too where they are failing |
test/wrappedNodeFetch.test.ts
Outdated
|
|
||
| describe('wrappedNodeFetch', () => { | ||
| it('should call fetch function with correct arguments in record mode', async () => { | ||
| const mockFetch = jest.fn().mockResolvedValueOnce(new Response()); |
There was a problem hiding this comment.
Since, outputs are recorded when end event is triggered for response of fetch. We dont need to mock fetch here. We can use the actual fetch of node-fetch
test/wrappedNodeFetch.test.ts
Outdated
| deps: [], | ||
| }; | ||
| createExecutionContext(ctx) | ||
| const wrappedFetch = (wrappedNodeFetch(mockFetch) as any).bind({ fetch: mockFetch }); |
There was a problem hiding this comment.
And pass actual fetch here. To capture the outputs.
test/wrappedNodeFetch.test.ts
Outdated
| }; | ||
| createExecutionContext(ctx) | ||
| const wrappedFetch = (wrappedNodeFetch(mockFetch) as any).bind({ fetch: mockFetch }); | ||
| const url = 'http://example.com'; |
There was a problem hiding this comment.
We can use keploy's health API "https://api.keploy.io/healthz" here as url
test/wrappedNodeFetch.test.ts
Outdated
| const deps=updatedctx.deps.length; | ||
| const responseBody = await response.text(); | ||
| const recordedOutput = updatedctx.mocks[0].Spec.Res.Body; | ||
| expect(mockFetch).toHaveBeenCalledWith(url, options); |
There was a problem hiding this comment.
We also dont need to do this since we use actual fetch of node-fetch
|
@re-Tick I have made the changes and it is passing all the test cases now. |
…b action and wrote unit test For code coverage added unit test for wrappedNodeFetch function and integrated git hub actions. test #354 Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
Revert version and removing console from unit test file test #354 Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
Added expect test for mocks and deps after fetching in record and test mode test #354 Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
… output with response Added a check to compare the recorded output with response to ensure wrappedNodeFetch functionality test #354 Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
importing HTTP from src/keploy.ts test #354 Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
…reateExecutionContext Resolving the failed test cases by using fetch from node-fetch and createExecutionContext test#354 Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
updating test cases test #354 Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
removing createExecutionContext from octokit test #354 Signed-off-by: Hermione Dadheech <hermionedadheech@gmail.com>
|
LGTM. Please add this PR link in GSOC task list. |
|
Nice Pr 😄. We currently support Unit Test Generation only for Go projects. |
1 similar comment
|
Nice Pr 😄. We currently support Unit Test Generation only for Go projects. |
For code coverage added unit test for wrappedNodeFetch function and integrated git hub actions.
test #354
Closes: keploy/keploy#354