question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for promises in `expect`

See original GitHub issue

Right now, if you have a promise in expect (for, say, an async function) it will be run but errors will not be detected.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:6

github_iconTop GitHub Comments

1reaction
Fundebugcommented, Jun 19, 2019

@LegNeato It seems the problem is not solved.

I‘m using supertest@4.0.2.

I find that the AssertionError will not be detected when I use async/await in expect.

 .expect(async res => {
     const orderId = res.body.orderId;
     const order = await Order.findById(orderId).lean(); // { price: 10 }

     // the AssertionError will not be detected
     order.should.deepEqual({
         price: 50
     });
 });
0reactions
LegNeatocommented, Oct 3, 2020

I don’t know, it could have regressed since this was landed years ago. I only use Rust these days so sadly can’t help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add support for asserting that a promise has resolved ... - GitHub
Currently, there is no declarative and easy way to check if a promise resolves or rejects. What is the expected behavior?
Read more >
How to support promises in Internet Explorer 11?
Use a JS transpiler (like babel) or don't use ES6 features. For Promise support you can use a library like bluebird. (BTW, note...
Read more >
Using promises - JavaScript - MDN Web Docs
A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of ...
Read more >
120260 – Add support for Promises - WebKit Bugzilla
Add support for Promises. Comment 1 Sam Weinig 2013-08-24 21:02:51 ... u'LayoutTests/fast/js/Promise-resolve-with-then-reject-expected.txt', ...
Read more >
Unit Testing Async Calls and Promises with Jasmine - Medium
This post will show you a simple approach to test a JavaScript service with an exported function that returns a promise. Unit testing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found