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

Feature request: support mocha private Mocha.Suite.create API #279

Open
adriaandotcom opened this issue Feb 18, 2020 · 2 comments
Open

Feature request: support mocha private Mocha.Suite.create API #279

adriaandotcom opened this issue Feb 18, 2020 · 2 comments

Comments

@adriaandotcom
Copy link
Contributor

When using this code:

// const Mocha = require("mocha");
const Mocha = require("mocha-parallel-tests").default;
const { expect } = require("chai");

const mochaInstance = new Mocha();
mochaInstance.timeout(90000);

const suiteInstance = Mocha.Suite.create(mochaInstance.suite, "Test Suite");

suiteInstance.addTest(
  new Mocha.Test(`Testing 1 is not 2`, async function() {
    expect(1).to.be.equal(2);
  })
);

mochaInstance.run(amountFailures => {
  process.exitCode = amountFailures > 0;
});

The output is (empty lines):



When using require("mocha") instead it returns fine:

  Test Suite
    1) Testing 1 is not 2


  0 passing (12ms)
  1 failing

  1) Test Suite
       Testing 1 is not 2:

      AssertionError: expected 1 to equal 2
      + expected - actual

      -1
      +2
      
      at Context.<anonymous> (bug.js:12:21)
      at processImmediate (internal/timers.js:439:21)
@adriaandotcom adriaandotcom changed the title Silelently failing when using Mocha Mocha.Suite.create Silelently failing when using Mocha.Suite.create Feb 18, 2020
@adriaandotcom adriaandotcom changed the title Silelently failing when using Mocha.Suite.create ilently failing when using Mocha.Suite.create Feb 18, 2020
@adriaandotcom adriaandotcom changed the title ilently failing when using Mocha.Suite.create Silently failing when using Mocha.Suite.create Feb 18, 2020
@1999
Copy link
Collaborator

1999 commented Feb 25, 2020

I'm not sure Mocha.Suite.create is a public mocha API.

@adriaandotcom
Copy link
Contributor Author

adriaandotcom commented Feb 26, 2020

It's the only way to have dynamically generate async tests: https://github.com/simpleanalytics/scripts/pull/5/files#diff-910eb6f57886ca16c136101fb1699231R118. It's uncommon, but I think it's the only way to run tests when you don't use the cli.

@1999 1999 changed the title Silently failing when using Mocha.Suite.create Feature request: support mocha private Mocha.Suite.create API Feb 26, 2020
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

2 participants