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 · 6 comments · Fixed by #721
Closed

Fail conditions documentation is unclear #370

sedge opened this issue Jun 10, 2015 · 6 comments · Fixed by #721
Assignees
Labels
bug Bug or defect
Milestone

Comments

@sedge
Copy link

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 Non-code related changes label Jun 10, 2015
@geek
Copy link
Member

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
Copy link
Contributor

Marsup commented Jun 10, 2015

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

@sedge
Copy link
Author

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
Copy link
Author

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
Copy link
Member

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 Bug or defect label May 18, 2016
@geek geek added this to the 14.0.2 milestone Jun 20, 2017
@geek geek removed the documentation Non-code related changes label Jun 20, 2017
@geek geek self-assigned this Jun 20, 2017
@geek geek closed this as completed in #721 Jun 20, 2017
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants