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.

`expose-gc` not working after upgrading from mocha 8.x to mocha 9.1.2

See original GitHub issue

Prerequisites

test.js with:

console.log(global.gc)

Description

After upgrading from mocha 8.x to mocha 9.1.2 the old --expose-gc option (or expose-gc config item) is not functional anymore.

It seems that at some point along the way that option got renamed to --gc-global. However the Node.js option is still called --expose-gc. Passing --gc-global to mocha results in Node.js being launched with --gc-global which has no effect.

Steps to Reproduce

mocha --expose-gc ./test.js   # absolutely no effect, this option is not recognized anymore
mocha --gc-global ./test.js     # launches node with --gc-global which has no effect either

Expected behavior:

node --expose-gc node_modules/mocha/lib/cli/cli.js  ./test.js # functional

Versions

mocha 9.1.2 node 14.18.2 Ubuntu 20.04 ts-node 9.1.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
juergbacommented, Dec 2, 2021

Does mocha -n expose-gc work? Does mocha --v8-expose-gc work?

Node accepts both --gc_global and --gc-global, at least with my Node v16.12.0.

1reaction
Patrik-Stascommented, Dec 2, 2021

I have run into this just now as well. I was running mocha like this

TS_NODE_PROJECT=./test/tsconfig.json NODE_ENV=test RUST_BACKTRACE=full ./node_modules/.bin/mocha --timeout 10000 --expose-gc --recursive --use_strict --require ts-node/register ./mytest.test.ts

and global.gc is undefined on mocha 9.1.x but I found the latest version it works at is mocha 9.0.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

mocha/CHANGELOG.md at master - GitHub
simple, flexible, fun javascript test framework for node.js & the browser - mocha/CHANGELOG.md at master · mochajs/mocha.
Read more >
mocha - npm
Start using mocha in your project by running `npm i mocha`. There are 9462 other projects in the npm registry using mocha.
Read more >
Mocha - API Manual
Mocha is a feature-rich JavaScript test framework running on Node.js and the browser, making asynchronous testing simple and fun. Mocha tests run serially, ......
Read more >
Issue running mocha tests in nodejs - Stack Overflow
This seems like a problem with nyc itself. Try updating to the version suggested in this github issue: ...
Read more >
[vscode-go] package.json: update mocha@v9.2.0
Hyang-Ah Hana Kim has uploaded this change for review. View Change package.json: update mo...@v9.2.0 mo...@9.1.2 requires nan...@3.1.25.
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