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

Error when using the --dry-run flag with many suites #4838

Closed
4 tasks done
pheyos opened this issue Mar 1, 2022 · 1 comment · Fixed by #4839
Closed
4 tasks done

Error when using the --dry-run flag with many suites #4838

pheyos opened this issue Mar 1, 2022 · 1 comment · Fixed by #4839
Assignees
Labels
type: bug a defect, confirmed by a maintainer

Comments

@pheyos
Copy link

pheyos commented Mar 1, 2022

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq 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_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you not install Mocha globally.

Description

Using the --dry-run flag with many suites causes an execution error.

Steps to Reproduce

Basically following the getting started steps:

  1. Create a new directory, execute the following steps in that directory
  2. npm install mocha
  3. mkdir test
  4. $EDITOR test/test.js
  5. Create many suites with one test each in test.js:
    var assert = require('assert');
    describe('Wrapper suite', function () {
      for(let i=0; i < 300; i++) {
        describe(`suite ${i}`, function () {
          it(`test ${i}`, function () {
            assert.equal(1, 1);
          });
        });
      }
    });
  6. Dry-run the tests with ./node_modules/mocha/bin/mocha --dry-run

Expected behavior: The test output lists the suits and tests correctly.

Actual behavior:

  • At some point, the test execution stops with an error, no summary is logged:
    image
  • Running with DEBUG=mocha:*, logs mocha:runner uncaught(): got truthy exception RangeError: Maximum call stack size exceeded

Reproduces how often: 100%

Versions

  • The output of mocha --version and node_modules/.bin/mocha --version: No global install, node_modules/.bin/mocha --version is 9.2.1
  • The output of node --version: v16.13.2
  • Your operating system
    • name and version: Ubuntu 20.04.4 LTS
    • architecture (32 or 64-bit): 64-bit
  • Your shell (e.g., bash, zsh, PowerShell, cmd): zsh v5.8
  • Your browser and version (if running browser tests): n/a
  • Any third-party Mocha-related modules (and their versions): n/a
  • Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version): n/a

Additional Information

  • The test run finished as expected when running ./node_modules/mocha/bin/mocha without the --dry-run flag.
  • Running many tests in one suite instead of many suites with one test each works as expected with the --dry-run flag, e.g. this slightly modified test.js runs fine:
    var assert = require('assert');
    describe('Wrapper suite', function () {
      for(let i=0; i < 300; i++) {
        it(`test ${i}`, function () {
          assert.equal(1, 1);
        });
      }
    });
@juergba juergba added type: bug a defect, confirmed by a maintainer and removed unconfirmed-bug labels Mar 1, 2022
@juergba juergba self-assigned this Mar 1, 2022
@juergba
Copy link
Contributor

juergba commented Mar 1, 2022

@pheyos thanks for your detailed analysis and excellent samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants