-
Notifications
You must be signed in to change notification settings - Fork 218
Add msw tests for gh-api-client #1663
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
Conversation
This adds some really simple tests for the `gh-api-client` file to ensure that we can use msw mocks in pure tests.
extensions/ql-vscode/test/pure-tests/remote-queries/gh-api/gh-api-client.test.ts
Outdated
Show resolved
Hide resolved
| it('returns the variant analysis', async () => { | ||
| await loadScenario('problem-query-success'); | ||
|
|
||
| const result = await getVariantAnalysis(mockCredentials, 557804416, 146); |
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.
What do you think about getting these ids from the scenario data instead of hard-coding in a test as well? I'm not sure if that would be super ugly so happy to be told no :)
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.
I've implemented it and I don't think it's ugly, but I did have to change how the tsconfig.json for tests was loaded.
This splits the mock GitHub API server class into two parts: one for the interactive, VSCode parts and one for the non-VSCode parts. This allows us to use the non-VSCode part in tests.
charisk
left a comment
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.
LGTM, just a suggestion left around test data usage. Happy to leave that for another day too.
This will change the pure tests Mocha setup to actually use the `tsconfig.json` located in the `test` directory. Before, it was using the root-level `tsconfig.json`. To ensure we are still using mostly the same settings, this will extend the `test/tsconfig.json` from the root-level `tsconfig.json`.
This will check that the data returned matches the data in the JSON files, rather than checking against constants/magic values.
This adds some really simple tests for the
gh-api-clientfile to ensure that we can use msw mocks in pure tests.Checklist
ready-for-doc-reviewlabel there.