-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Unit test cases for wrappedNodeFetch and adding github actions #59
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Signed-off-by: Hermione Dadheech <[email protected]>
Revert version and removing console from unit test file test #354 Signed-off-by: Hermione Dadheech <[email protected]>
Added expect test for mocks and deps after fetching in record and test mode test #354 Signed-off-by: Hermione Dadheech <[email protected]>
… output with response Added a check to compare the recorded output with response to ensure wrappedNodeFetch functionality test #354 Signed-off-by: Hermione Dadheech <[email protected]>
importing HTTP from src/keploy.ts test #354 Signed-off-by: Hermione Dadheech <[email protected]>
…reateExecutionContext Resolving the failed test cases by using fetch from node-fetch and createExecutionContext test#354 Signed-off-by: Hermione Dadheech <[email protected]>
updating test cases test #354 Signed-off-by: Hermione Dadheech <[email protected]>
removing createExecutionContext from octokit test #354 Signed-off-by: Hermione Dadheech <[email protected]>
LGTM. Please add this PR link in GSOC task list. |
For code coverage added unit test for wrappedNodeFetch function and integrated git hub actions.
test #354
Closes: keploy/keploy#354