question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests not running with Mocha 9.0.2 and Yarn Berry (2.4.2)

See original GitHub issue

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 node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you not install Mocha globally.

Description

When our project upgrade to Mocha 9.0.2 from 8.3.1 running mocha would return 0 tests. Before the update we had over 400 tests. We ended up updating to 8.4.0 in the short term and our tests continued to function. I put together a demo repo that is just yarn 2.4.2, mocha 9.0.2, and chai 4.3.4 to showcase no tests appear. As a test I also removed chai and did the assert only test with the same result.

Steps to Reproduce

Link to demo repo.

  1. Clone demo repo
  2. Run yarn install to install mocha, chai, and their dependencies
  3. Run yarn test and the console will return 0 passing (1ms)

That repo should have 2 passing tests. Also, this shows with and without chai as part of the tests to rule that out.

If you downgrade to yarn 1.22.10 the tests work. If you downgrade mocah to 8.4.0 the tests work. I assume the issue is with Mocah because older versions work as expected.

Expected behavior: [What you expect to happen] 2 Passing tests

Actual behavior: [What actually happens]

No tests found: 0 passing (1ms)

Reproduces how often: [What percentage of the time does it reproduce?] 100% reproduction

Versions

  • The output of mocha --version and node node_modules/.bin/mocha --version: 9.0.2
  • The output of node --version: v14.15.5
  • Your operating system
    • name and version: macOS Big Sur (11.4)
    • architecture (32 or 64-bit): 64-bit
  • Your shell (e.g., bash, zsh, PowerShell, cmd): zsh
  • 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:24 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
charlessuhcommented, Aug 7, 2021

Question: should “0 passing” have a process exit status that indicates an error instead of success? Bugs like this could have the potential to give false positives, such as in CI/CD environments where successful tests can lead to automatic deploys.

1reaction
merceyzcommented, Jul 22, 2021

This issue boils down to the fact that Yarn PnP doesn’t support ESM yet https://github.com/yarnpkg/berry/issues/638

add “@yarnpkg/plugin-node-modules”: “*” to package.json https://github.com/mochajs/mocha/issues/4693#issuecomment-885126723

That’s an unnecessary step, it wont be used by the CLI

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is Mocha not working with Yarn Berry? - Stack Overflow
Tools I'm using: Mocha 9.0.2; Yarn Berry 2.4.2. Is mocha unsupported by Yarn 2? Should I use something else? I always use ...
Read more >
Gil Tayar on Twitter: "Interesting: @yarnpkg 2 (Berry) does not ...
Tests not running with Mocha 9.0.2 and Yarn Berry (2.4.2) · Issue #4693 · mochajs/mocha. Prerequisites Checked that your issue hasn't already been...
Read more >
mocha-junit-reporter | Yarn - Package Manager
JUnit Reporter for Mocha. Build Status npm. Produces JUnit-style XML test results. Installation. $ npm install mocha-junit-reporter --save-dev.
Read more >
Compare Packages Between Distributions - DistroWatch.com
In this way we can not only compare two competing projects, but also track ... cups (2.4.2), 2.4.2, 2.3.3op2 ... Dist-Zilla-Plugin-Test-CPAN-Changes 0.12.0
Read more >
Yarn 2 — the future of package managers for JavaScript? - Snyk
js versions prior to 10 are not supported anymore and so no bug fixes, and no security fixes. Switching to the new Yarn...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found