# Translate old test assertion to pm.test

**URL:** <https://community.postman.com/t/translate-old-test-assertion-to-pm-test/6376>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [July 8, 2019, 2:27pm UTC](https://community.postman.com/t/translate-old-test-assertion-to-pm-test/6376 "2019-07-08T14:27:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![laureline.gagnon](https://avatars.discourse-cdn.com/v4/letter/l/a3d4f5/32.png) [@laureline.gagnon](https://community.postman.com/u/laureline.gagnon)\
**Post date:** [July 8, 2019, 2:27pm UTC](https://community.postman.com/t/translate-old-test-assertion-to-pm-test/6376/1 "2019-07-08T14:27:11Z")

</div>

Hey,

I’m working on rewriting all the tests of all the requests but after 2 hours of searching the Internet, I can’t find a way to rewrite this test:

`tests["Name not null"] = response.name !== null && response.name !== ""`

If anyone has an idea to help me, I’ll be grateful.

Laurre

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 8, 2019, 2:49pm UTC](https://community.postman.com/t/translate-old-test-assertion-to-pm-test/6376/2 "2019-07-08T14:49:51Z")

</div>

Hey @laureline.gagnon,

Welcome and thank you for posting your question ⭐

If I understand what you’re trying to achieve, would this work:

```
pm.test("Name not null", () => {
    pm.expect(response.name).to.not.be.null
    pm.expect(response.name).to.not.be.empty
}) 

```

I don’t really know the full context behind the question so this is only based on the limited information I have, happy to edit the response if this doesn’t work for you.

Adding this link for reference:

> **[Expect / Should - Chai](https://www.chaijs.com/api/bdd/)**
>
> Chai is a BDD / TDD assertion library for \[node\](http://nodejs.org) and the browser that can be delightfully paired with any javascript testing framework.

---

<div class="post-metadata">

**Author:** ![laureline.gagnon](https://avatars.discourse-cdn.com/v4/letter/l/a3d4f5/32.png) [@laureline.gagnon](https://community.postman.com/u/laureline.gagnon)\
**Post date:** [July 8, 2019, 2:54pm UTC](https://community.postman.com/t/translate-old-test-assertion-to-pm-test/6376/3 "2019-07-08T14:54:02Z")

</div>

Thanks !  
That’s exactly what I want to do.  
Is there a list of all possible functions/commands following an expect?  
Because I didn’t find its possibilities during my research.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 8, 2019, 3:20pm UTC](https://community.postman.com/t/translate-old-test-assertion-to-pm-test/6376/4 "2019-07-08T15:20:17Z")

</div>

You’ll find all of the chai expect functions in the link that I provided in the answer 🙂

You can also find more Postman `Tests` information here:

[https://learning.getpostman.com/docs/postman/scripts/test\_scripts/#writing-postman-tests](https://learning.getpostman.com/docs/postman/scripts/test_scripts/#writing-postman-tests)

[https://learning.getpostman.com/docs/postman/scripts/test\_examples/](https://learning.getpostman.com/docs/postman/scripts/test_examples/)

And more test related goodness covered in this documentation with the added bonus of using the ‘Run in Postman’ button, at the top of the page, to import the collection into your own Postman instance. 🙂

> **[Intro to writing tests - with examples](https://documenter.getpostman.com/view/1559645/RzZFCGFR?version=latest)**
>
> This collection contains examples of tests that you can use to automate your testing process.
> 
> \- Basic test syntax
> \- API tests
> \- Integration tests
> 
> \# Quick tips for writing tests
> \- Organize your test scenarios by grouping your requests in...

---

<div class="post-metadata">

**Author:** ![laureline.gagnon](https://avatars.discourse-cdn.com/v4/letter/l/a3d4f5/32.png) [@laureline.gagnon](https://community.postman.com/u/laureline.gagnon)\
**Post date:** [July 9, 2019, 6:52am UTC](https://community.postman.com/t/translate-old-test-assertion-to-pm-test/6376/5 "2019-07-09T06:52:52Z")

</div>

Thanks for your help 🙂

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 9, 2019, 7:00am UTC](https://community.postman.com/t/translate-old-test-assertion-to-pm-test/6376/6 "2019-07-09T07:00:12Z")

</div>


