-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Description
Feature Description
k6's initial focus has been to provide functionality for load testing. When a test such as the one below fails with "Uncaught (in promise)", the test is actually marked as passed:
import { browser } from 'k6/browser';
export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
}
export default async function() {
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://quickpizza.grafana.com/');
await page.locator('a[href="/fake-link.php"]').click({ timeout: 1000 });
await page.close();
}As mentioned before, with a non-functional test this might not matter in most cases since you might be running multiple VUs and many iterations, where a few tests would fail and we don't want to abort the whole test run in those cases.
However in the functional case, this is a problem. The expectation is that the test actually fail since the test didn't complete to the end. Current workarounds include:
- Having to parse the logs for "Uncaught (in promise)" or "stacktrace".
- Catching the error and calling
failor asserting withexpect.
This is just extra boilerplate code which makes adopting k6 harder than other JS testing libraries.
Suggested Solution (optional)
- Create a CLI flag/envvar/option that tells k6 that if it encounters "Uncaught (in promise)" or "stacktrace" (and maybe other errors) to fail the test and make sure it is marked as failed.
Already existing or connected issues / PRs (optional)
No response