My response body is below, how can I write below tests -
- Response body contains elements (âoldestBlockâ,ârewardâ, âbaseFeePerGasâ,âgasUsedRatioâ), in a single test
I tried below but it should fail instead of pass because âgasUsedRatiosâ contains extra âsâ at end, correct value = gasUsedRatio.
pm.expect(pm.response.text()).to.includes(âoldestBlockâ,ârewardâ, âbaseFeePerGasâ,âgasUsedRatiosâ)
-
Response body does not contains elements except above ones.
-
reward is an array & shouldnât be empty
-
value in reward array should begin with â0xâ
-
Below Json schema validation
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"oldestBlock": "0x128c528",
"reward": [
[
"0xc2f6ed",
"0xc2f6ed"
],
[
"0xbd4bf3",
"0xc2f6ed"
],
[
"0xbd1d99",
"0xbd4bf3"
],
[
"0xbd1d99",
"0xbd1d99"
],
[
"0xf4240",
"0xb79e27"
]
],
"baseFeePerGas": [
"0xb3a42c70d",
"0xb367ecc49",
"0xaaeb73d77",
"0xa3480338a",
"0xa6f4fc367",
"0xa98e65669"
],
"gasUsedRatio": [
0.49475963333333334,
0.3107929,
0.3212392,
0.5900452,
0.5622738
]
}
}