Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

testing a series of events #376

Closed
rodneyrehm opened this Issue · 4 comments

3 participants

@rodneyrehm

It would be nice to have a more semantic declaration of asnyc tests, that are comprised of multiple async tests. What I'm doing right now:

test("foo", function() {
  stop(3);

  foobar.on("first", function(data) {
    // some assertions
    start();
  });

  foobar.on("second", function(data) {
    // some assertions
    start();
  });

  foobar.on("third", function(data) {
    // some assertions
    start();
  });

  foobar.trigger();
});

what I would like this to change to is something along the lines of

stepTest("foo", function() {
  steps(3);

  foobar.on("first", function(data) {
    // some assertions
    step(1, "first step");
  });

  foobar.on("second", function(data) {
    // some assertions
    step(2, "second step");
  });

  foobar.on("third", function(data) {
    // some assertions
    step(3, "third step");
  });

  foobar.trigger();
});

steps() would pretty much work like stop. step(num, message) works like start, except that it additionally asserts the sequence (1, 2, 3). This allows better error messages than "test xyz timed out" (and you have to figure out which step failed yourself).

@jzaefferer
Owner

The step addon is somewhat similar: https://github.com/jquery/qunit/tree/master/addons/step - maybe it could be extended to also do the async control? Though for that #374 should be implemented first.

@jzaefferer
Owner

This also overlaps with #331 - not sure yet what the right approach is, but we certainly need to make async testing a lot more reliable.

@JamesMGreene
Collaborator

Update: The "step addon" that @jzaefferer referred to in an earlier comment has been moved to JamesMGreene/qunit-assert-step.

@jzaefferer
Owner

Closing due to lack of interest/value. The step plugin should be sufficient. We are definitely improving async testing in general (see #331).

@jzaefferer jzaefferer closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.