Test result (as boolean)

Let’s say I have a test, eg

pm.test("Status code is 301", function () {

and I want the following actions to depend on wether the test passed or failed.

How to get the test result (as boolean)?


Hey @chrissbaumann,
I tried the following snippet and it prints “Test failed”

 pm.test("Check response code", function () {
            console.log("Test passed")  
            console.log("Test failed")
            //Add your action here

I’m curious however to understand more about the use case. Could you elaborate on what kinds of actions you would trigger based on the results of the test?

1 Like

Thank you!

No specific use case for me.
Saw couple of questions on StackOverflow, where this would have been useful.
Mostly asking to do things, I would not advise for from a testing perspective…

1 Like