.expect() with custom assertion method always succeeds
See original GitHub issueit('Should have response, time, code', function(done){
apis.get('/')
.expect('Content-Type', /json/)
.expect(406)
.expect(function(res){
return true
/*
if(!('responses' in res.body)) return "Missing response key"
if(!('timed' in res.body)) return "Missing time key"
if(!('codes' in res.body)) return "Missing code key"*/
})
.end(done)
})
My test is always successful even when returning true from the method - which should fail. My other attempts at tackling these are commented in the code.
Issue Analytics
- State:
- Created 8 years ago
- Comments:23
Top Results From Across the Web
expect() with custom assertion method always succeeds #253
AlexZeitler commented on Jul 12, 2015 ... Just tried this and it works: var request = require('supertest'); var app = require('../app.js'); var ...
Read more >Java - TestNG : Why does my Assertion always passes when ...
@Test (expected = NotFoundException.class) public void example2() throws ... That's why your method always will be finished with success.
Read more >Assertions Reference | GoogleTest
SUCCEED. SUCCEED(). Generates a success. This does not make the overall test succeed. A test is considered successful only if none of its...
Read more >Assertions - Go Packages
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
Read more >Expect / Should - Chai Assertion Library
The BDD styles are expect and should . Both use the same chainable language to construct assertions, but they differ in the way...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This seems to be still an issue:
I wrote the above to intentionally fail the test, however it passes.
However, if I use a promise, it fails as expected:
Output:
PS, throwing an exception does produce the right result.
e.g.