0

I'm writing a simple Postman test that even checks if true == false but it always passes. What am I doing wrong? You can see the green light here:

enter image description here

Just a single test on its own without the wrapper function will fail [good!], but that doesn't seem a scalable way to write a lot of tests.

so wrapping stuff in pm.test( ) with either a function() or an ()=> arrow function means everything false passes... ???

enter image description here

enter image description here

If I use a test runner, or check test results below I can see the fails. So maybe that little happy green light in the test authoring panel is just buggy / should be ignored? Or maybe it means syntax error rather than results error? Confusing.

enter image description here

dcsan
  • 11,333
  • 15
  • 77
  • 118
  • if you remove everything from the body of the test except for the true == false test does it still pass? – byake Sep 08 '20 at 23:42
  • updated my question to inc that case. – dcsan Sep 08 '20 at 23:46
  • 1
    I'm not sure that I can see an actual question - What is the problem that you having issues with here? All `pm.expect()` need to be wrapped in a `pm.test` statement to be considered a test. Closing out the `pm.test()` will be considered true and pass the test. – Danny Dainton Sep 09 '20 at 05:49
  • Why do you think the test is passing? On this screenshot (https://i.stack.imgur.com/59Qin.png) at the bottom you can clearly see that the test failed. – Christian Baumann Sep 09 '20 at 13:05
  • there is a green indicator above the tests themselves, even when the results panel shows failing. – dcsan Sep 12 '20 at 01:35
  • @ChristianBaumann reorder images to make it more clear. – dcsan Sep 12 '20 at 01:38

1 Answers1

2

I think there is a misunderstanding here. pm.expect(true).to.eql(false); throws an error. If it is wrapped by a test, this error is being caught. If no test wrapper, it's not being caught.

The red/ green dot next to "Tests" just indicates if the Javascript has been executed without problems. So if you execute this as a test, the Javascript went trough without errors, thus the green dot. Because the error has been caught by the test function. If you only execute the .expect() without a test, the error is not caught, thus the Javascript failed, thus the red dot.

Did you check the Test Results area at the bottom? There you can clearly see, that a test which expects true to equal false is failing.

enter image description here

Christian Baumann
  • 3,188
  • 3
  • 20
  • 37