Reputation: 12315
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:
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... ???
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.
Upvotes: 1
Views: 4694
Reputation: 3434
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.
Upvotes: 4