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

async describe #3106

Closed
4 tasks done
Maximaximum opened this issue Nov 15, 2017 · 1 comment
Closed
4 tasks done

async describe #3106

Maximaximum opened this issue Nov 15, 2017 · 1 comment

Comments

@Maximaximum
Copy link

Prerequisites

  • Checked that your issue isn't already filed by cross referencing issues with the common mistake label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
    node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend avoiding the use of globally installed Mocha.

Description

In my use case, I'm declaring my test routines declaratively using https://github.com/pana-cc/mocha-typescript, so the tests get registered the moment the @suite classes are loaded.

I'm currently loading part of the test classes using require inside of a describe block that groups a couple of tests together:

  describe('Authorized calls on the part of a staff member', () => {
    require('./tests/asp-net-user');
    require('./tests/crawler-status');
    ...
  });

However, I'm now trying to use https://github.com/shannonmoeller/require-glob so that all files the conform to a given glob pattern (e.g., are located in a specifc folder) are included automatically inside that describe block:

  describe('Authorized calls on the part of a staff member', () => {
    requireGlob('./tests/staff/*.ts');
  });

However, the problem with require-glob is that it works asynchronously. Resulting in that the tests get run outside of the 'Authorized calls on the part of a staff member' block.

Steps to Reproduce

Expected behavior:
It would be nice if describe supported the done() parameter, just like it, beforeEach, afterEach do:

  describe('Authorized calls on the part of a staff member', (done) => {
    requireGlob('./tests/staff/*.ts').then(_ => { done(); });
  });

Actual behavior:
done parameter of describe callback is not supported

Reproduces how often: Always

Versions

Additional Information

This is a duplicate of #1431, but that one had been illustrated using a different use case and has been legitimately closed.

@Maximaximum
Copy link
Author

I'm sorry - I've already found out that this issue can be easily overcome by using requireGlob.sync() instead of requireGlob() 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant