# Test that response doesn't contain a specific word

**URL:** <https://community.postman.com/t/test-that-response-doesnt-contain-a-specific-word/59258>\
**Category:** Help Hub\
**Tags:** tests, scripts, response\
**Created:** [March 26, 2024, 12:12pm UTC](https://community.postman.com/t/test-that-response-doesnt-contain-a-specific-word/59258 "2024-03-26T12:12:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shailendrakumaromkar](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@shailendrakumaromkar](https://community.postman.com/u/shailendrakumaromkar)\
**Post date:** [March 26, 2024, 12:12pm UTC](https://community.postman.com/t/test-that-response-doesnt-contain-a-specific-word/59258/1 "2024-03-26T12:12:20Z")

</div>

My response body is like below

```auto
{
    "jsonrpc": "2.0",
    "id": "1",
    "result": "0x129d421"
}

```

I want to write a test like, in whole JSON response body there should not be any “error” word

So my test should handle any of the below word combination & should pass  
error, Error, Errors, errors, Error’s, error’s etc

How can I write test for that ?

Thank You

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [March 26, 2024, 12:54pm UTC](https://community.postman.com/t/test-that-response-doesnt-contain-a-specific-word/59258/2 "2024-03-26T12:54:01Z")

</div>

Parse the response to text() and then use a simple includes assertion.

```auto
const response = pm.response.text();

let errors = ["error", "Error", "Errors", "errors", "Error’s", "error’s"];

pm.test('Response does not have any errors', () => {
    pm.expect(response).to.not.include.oneOf(errors);
});

```

---

<div class="post-metadata">

**Author:** ![shailendrakumaromkar](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@shailendrakumaromkar](https://community.postman.com/u/shailendrakumaromkar)\
**Post date:** [March 31, 2024, 6:51am UTC](https://community.postman.com/t/test-that-response-doesnt-contain-a-specific-word/59258/3 "2024-03-31T06:51:14Z")

</div>

> [@michaelderekjones](#):
>
> ```auto
> errors', () => {
>     
> 
> ```

Thank You for the suggestion & help.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [April 30, 2024, 6:51am UTC](https://community.postman.com/t/test-that-response-doesnt-contain-a-specific-word/59258/4 "2024-04-30T06:51:52Z")

</div>

Closed on April 30, 2024, 6:51am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
