This repository has been archived by the owner. It is now read-only.

async test returning resolved promise with truthy value is treated as an error #308

Closed
awwx opened this Issue Nov 15, 2012 · 2 comments

Comments

Projects
None yet
3 participants
@awwx

awwx commented Nov 15, 2012

In this test script, the first test returns a resolved promise (indicating an async test) with an undefined value, and the test succeeds correctly.

The second test also returns a resolved promise, but this time with a defined value. Since the promise is resolved (successful), and there are no failed assertions, the test should be treated as successful. However, buster treats it as a failing test with an error.

For illustration I'm resolving with an object that has a "message" key (which is displayed as if buster is printing out error.message), but any truthy value will cause the test to fail.

[green checkmark] promise with undefined value

[yellow X] promise with truthy value
undefined: hi there

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>async</title>
  </head>
  <body>
    <script src="http://cdn.busterjs.org/releases/latest/buster-test.js"></script>
    <script src="https://raw.github.com/cujojs/when/master/when.js"></script>
    <script>

      buster.testCase("async", {

        "promise with undefined value": function () {
          buster.assert(true);
          return when.resolve();
        },

        "promise with truthy value": function () {
          buster.assert(true);
          return when.resolve({message: "hi there"});
        }

      });

    </script>
  </body>
</html>
@cjohansen

This comment has been minimized.

Member

cjohansen commented Nov 19, 2012

Buster seems to think that your resolved object is an error object. Which is stupid. I know why too, and it needs to be fixed.

@ghost ghost assigned cjohansen Nov 19, 2012

@dwittner

This comment has been minimized.

Member

dwittner commented Sep 7, 2013

Fixed by 222b36148a.

@dwittner dwittner closed this Sep 7, 2013

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.