Uh oh!
There was an error while loading. Please reload this page.
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 into
Conversation
developer-diganta
commented
Mar 8, 2023
Hi @re-Tick! Can you please review the PR? |
re-Tick
commented
Mar 8, 2023
@Hermione2408 please resolve DCO and commitzen |
5cebecf to
7270469CompareHermione2408
commented
Mar 8, 2023
Can you have a look now @re-Tick |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hermione2408
commented
Mar 13, 2023
Hey @re-Tick , Can you please review the changes now |
re-Tick
commented
Mar 14, 2023
a test is failing. I will try these changes locally and request changes if any. |
Hermione2408
commented
Mar 14, 2023
Sure I'll try to resolve too where they are failing |
| 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
| 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.
| }; | ||
| 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
| 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
Hermione2408
commented
Mar 14, 2023
@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>
re-Tick
commented
Mar 15, 2023
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