Older `tests[]` syntax vs `pm.test()`

I recognize that tests[] is being deprecated and so I wanted to change to pm.test(). However, when I use the same function that worked before in passing and failing with test[], I get false positives with pm.test(). The example pictured below.

I am using an API that is returning an object that looks like this:

[
    {
        "id": 0,
        "heading": "",
        "title": "Title name",
        "images": {
            "phone": {
                "type": "IMAGE",
                "width": 828,
                "height": 1159
            },
            "tablet": {
                "type": "IMAGE",
                "width": 1170,
                "height": 602
            }
        },
        "menu_order": 6
    },
...

And I am testing to make sure the fields are empty.

Addtional intel:
image

macOS Mojave 10.14.5

@aredman
Hey buddy.

Have you read the documentation on test writing below?

You’re not performing an actual test/assertion in line 18 in your code example.
I’d suggest you read the official docs on tests, maybe watch a Youtube video or two.

I’d recommend these:


Amber Race has a great free tutorial on the Test Automation University website too:
https://testautomationu.applitools.com/exploring-service-apis-through-test-automation/

2 Likes

I did read the doc’s and watched those videos. However, they all brought me back to question how are they different in use? Can you clarify more around this?

If line 18 is not a test then what is it and how do I test? All those examples never cover how to use these snippets but not dialogue on syntax.