#
Running tests
Once you've created a test suite for your API, you can run the generated tests to verify that your API is working as expected from the Test Suite Details page.
This is how running tests from the KushoAI web app works:
- You can run tests using one of these options: run a single test, run all, or run a subset of tests.
- When you run a test, KushoAI makes an API call using the API payload for that test. You can view the API payload in the "Requests" tab of the Test Details section, which can be opened by clicking on the "Details" button for a test.
- This API call is routed via a KushoAI's Chrome Extension to bypass the browser's CORS restrictions. More about this
below .
Note that API calls for tests go from your browser via KushoAI's Chrome Extension. So you will be able to run tests even if your backend is running on localhost or behind a VPN.
- Once the API call returns, the response is displayed in the "Response" tab in the Test Details section.
- If you have defined assertions for the test, these assertions will be validated against the API response. You can view assertion results under the "Assertion Results" tab in the Test Details section. Along with that, you'll see a passed/failed status under the "Assertions" column.
- If you have not defined any assertions, you'll see blank or "N/A" under the "Assertions" column.
Apart from running tests from the Test Suite Details page, you also have the option to add test suites to a group and run an entire group in one go or run tests from your CI/CD platform.
#
Why do I need to install an extension to run tests?
KushoAI needs to make API calls to your test setup (which could be localhost, behind a VPN or running on the cloud) from the browser to test your APIs. The problem with doing this is that modern browsers generally block all API calls going to different origins than the one from which the page was loaded due to CORS restrictions.
For example, KushoAI's webapp is loaded from kusho.ai
domain, but your test setup might be hosted on qa.foobar.com
domain. Because the origin of the webpage (kusho.ai
) will always be different from the domain on which tests will be executed, making an API call directly from the webapp will result in it getting blocked
.
To bypass this restriction, we developed a Chrome extension designed solely to act as a proxy for API calls. When you run tests, the KushoAI web app instructs the Chrome extension to make the API call (which is not blocked by browser CORS restrictions) and send the response back to the web app.
KushoAI's Chrome extension is active only when the domain of the web page is kusho.ai
. You can verify this by looking at the extension's manifest.yml. So you don't need to worry about the extension intercepting API calls from any other web pages. You can also download the extension as a CRX file and review its code to verify that it only performs the actions mentioned here. Here is a short tutorial on how to do that.
If you're still unsure, please visit our Slack workspace and ping us on the #support channel. We'll be more than happy to hop on a call to explain how it works.