forked from extern/bruno
Add chai-http to enable to.be.json assertions Re #132
This commit is contained in:
parent
2120a562da
commit
074d72d885
@ -18,6 +18,7 @@
|
|||||||
"@usebruno/schema": "0.3.1",
|
"@usebruno/schema": "0.3.1",
|
||||||
"axios": "^0.26.0",
|
"axios": "^0.26.0",
|
||||||
"chai": "^4.3.7",
|
"chai": "^4.3.7",
|
||||||
|
"chai-http": "^4.3.0",
|
||||||
"chokidar": "^3.5.3",
|
"chokidar": "^3.5.3",
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.0.3",
|
||||||
"electron-is-dev": "^2.0.0",
|
"electron-is-dev": "^2.0.0",
|
||||||
|
@ -6,6 +6,7 @@ const BrunoRequest = require('../bruno-request');
|
|||||||
const { evaluateJsTemplateLiteral, evaluateJsExpression, createResponseParser } = require('../utils');
|
const { evaluateJsTemplateLiteral, evaluateJsExpression, createResponseParser } = require('../utils');
|
||||||
|
|
||||||
const { expect } = chai;
|
const { expect } = chai;
|
||||||
|
const chaiHttp = require('chai-http');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assertion operators
|
* Assertion operators
|
||||||
@ -92,7 +93,7 @@ const evaluateRhsOperand = (rhsOperand, operator, context) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gracefulle allyow both a,b as well as [a, b]
|
// gracefully allow both a,b as well as [a, b]
|
||||||
if(operator === 'in' || operator === 'notIn') {
|
if(operator === 'in' || operator === 'notIn') {
|
||||||
if(rhsOperand.startsWith('[') && rhsOperand.endsWith(']')) {
|
if(rhsOperand.startsWith('[') && rhsOperand.endsWith(']')) {
|
||||||
rhsOperand = rhsOperand.substring(1, rhsOperand.length - 1);
|
rhsOperand = rhsOperand.substring(1, rhsOperand.length - 1);
|
||||||
@ -225,6 +226,7 @@ class AssertRuntime {
|
|||||||
expect(lhs).to.be.false;
|
expect(lhs).to.be.false;
|
||||||
break;
|
break;
|
||||||
case 'isJson':
|
case 'isJson':
|
||||||
|
chai.use(chaiHttp);
|
||||||
expect(lhs).to.be.json;
|
expect(lhs).to.be.json;
|
||||||
break;
|
break;
|
||||||
case 'isNumber':
|
case 'isNumber':
|
||||||
@ -267,4 +269,4 @@ class AssertRuntime {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = AssertRuntime;
|
module.exports = AssertRuntime;
|
||||||
|
Loading…
Reference in New Issue
Block a user