Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail conditions documentation is unclear #370

Closed
sedge opened this issue Jun 10, 2015 · 5 comments
Closed

Fail conditions documentation is unclear #370

sedge opened this issue Jun 10, 2015 · 5 comments
Assignees
Labels
bug
Milestone

Comments

@sedge
Copy link

@sedge sedge commented Jun 10, 2015

I tried causing a before hook to fail by passing an error to its done callback, since the docs say that's one way to cause a test to fail. Apparently this has no effect on the before/after hooks.

I know the docs say tests will fail if something is passed to done, but I found it confusing and thought I would surface it.

@geek geek added the documentation label Jun 10, 2015
@geek

This comment has been minimized.

Copy link
Member

@geek geek commented Jun 10, 2015

We can clarify this, do you know where in the readme it says this, I didn't find it?

@Marsup

This comment has been minimized.

Copy link
Member

@Marsup Marsup commented Jun 10, 2015

It should fail, either a bug or something wrong with your setup.

@sedge

This comment has been minimized.

Copy link
Author

@sedge sedge commented Jun 11, 2015

Ahh! I stand corrected.

I'm used to mocha's explicit reporting of the hook failing. Lab reports it as a test script error without reference to where it occurred:
screen shot 2015-06-11 at 12 56 28 pm

In addition, despite the hook failing, the tests are still reported to have run:

screen shot 2015-06-11 at 12 59 17 pm

Is this normal behaviour? There's no way those tests can pass if the hook fails. My test script (modified to trigger the behaviour) looks like this:

var config;

before(function(done) {
    asyncOp(function(err, value) {
      return done("This string was passed to done");

      config = value;
      done();
    });
});

experiment('[Get one file]', function() {
  experiment('[Parameter errors]', function() {
    test('user_id must be valid', function(done) {
      // Next line should throw if before hook failed,
      // failing this test:
      var opts = config.fail.invalidUserid; 

      // ...
      done();
    });

    test('project_id must be valid', function(resp) {
      // ditto
      var opts = config.fail.invalidProjectid;

       // ...
       done();
    });

    test('file_id must be valid', function(resp) {
      // And here
      var opts = config.fail.invalidFileid;

      // ...
      done();
    });
  });

  test('default', function(done) {
    // One more...
    var opts = config.success.default;

    // ...
    done();
  });
});
@sedge

This comment has been minimized.

Copy link
Author

@sedge sedge commented Jun 11, 2015

I'm aware that this now touches a couple of different potential problems. Should I split that last piece out into another issue?

@geek

This comment has been minimized.

Copy link
Member

@geek geek commented May 18, 2016

@sedge good find. When the parent experiment before function fails then the inner experiment tests shouldn't run. Marking as a bug.

@geek geek added the bug label May 18, 2016
@geek geek added this to the 14.0.2 milestone Jun 20, 2017
@geek geek removed the documentation label Jun 20, 2017
@geek geek self-assigned this Jun 20, 2017
@geek geek closed this in #721 Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.