Skip to content

Commit bd44988

Browse files
committed
Add thresholds for failing test
1 parent 23371ba commit bd44988

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

k6/lib/util.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const envToBoolean = (envVar) => {
1010
* @param {boolean} [inScenario=isBrowser] Is this used as `scenarios: { <scenarioName>: defaultOptions(...) }`?
1111
* @param {boolean} [isBrowser=false] Is this a browser test?
1212
* @param {boolean} [isDebug=env.DEBUG_K6] Are we running in debug mode?
13+
* @param {import('k6/options').Options} [otherOptions] Other options to merge in
1314
* @return {import('k6/options').Options}
1415
* */
1516
export const defaultOptions = ({
@@ -18,16 +19,25 @@ export const defaultOptions = ({
1819
// Browser tests options can only be set inside `scenarios`
1920
// https://grafana.com/docs/k6/latest/using-k6-browser/
2021
inScenario = isBrowser,
22+
...otherOptions
2123
} = {}) => {
24+
const thresholds = {
25+
checks: ['rate>0.90'],
26+
http_req_failed: ['rate<0.05'],
27+
};
2228
const baseOptions = isDebug
2329
? {
2430
vus: 1,
2531
iterations: 1,
2632
httpDebug: inScenario ? undefined : 'full',
33+
thresholds,
34+
...otherOptions,
2735
}
2836
: {
2937
vus: 10,
3038
duration: '30s',
39+
thresholds,
40+
...otherOptions,
3141
};
3242
if (inScenario) {
3343
// See https://github.com/grafana/k6-learn/blob/main/Modules/III-k6-Intermediate/08-Setting-load-profiles-with-executors.md

0 commit comments

Comments
 (0)