bruno/packages/bruno-tests/collection/scripting/local modules/invalid and valid module imports.bru
2024-08-24 14:29:43 +05:30

38 lines
658 B
Plaintext

meta {
name: invalid and valid module imports
type: http
seq: 3
}
get {
url: {{host}}/ping
body: none
auth: none
}
assert {
invalid_module_error_thrown: eq true
valid_module_no_error: eq true
}
script:pre-request {
try {
bru.setVar('invalid_module_error_thrown', false);
// should throw an error
const invalid = require("./lib/invalid");
}
catch(error) {
bru.setVar('invalid_module_error_thrown', true);
}
try {
bru.setVar('valid_module_no_error', true);
// should not throw an error
const math = require("./lib/math");
}
catch(error) {
bru.setVar('valid_module_no_error', false);
}
}