How to use the k6.fail function in k6

To help you get started, we’ve selected a few k6 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vendure-ecommerce / vendure / packages / dev-server / load-testing / utils / api-request.js View on Github external
post(variables = {}) {
        const res = http.post('http://localhost:3000/shop-api/', {
            query: this.document,
            variables: JSON.stringify(variables),
        }, {
            timeout: 120 * 1000,
        });
        check(res, {
            'Did not error': r => r.json().errors == null && r.status === 200,
        });
        const result = res.json();
        if (result.errors) {
            fail('Errored: ' + result.errors[0].message);
        }
        return res.json();
    }
}