'when i try to run solidity-coverage with truffle run coverage then I got this error

I try to run solidity coverage for testing test case and its coverage but when I run coverage command its give error like this : - command used (truffle run coverage)

Using Truffle library from local node_modules.

solidity-coverage cleaning up, shutting down ganache server UnhandledRejections detected Promise { TypeError: Cannot read private member from an object whose class did not declare it at __classPrivateFieldGet (C:\Users\RahulMuwal\Downloads\smartcontract (2)\smartcontract\node_modules\truffle\node_modules\ganache\dist\node\webpack:\Ganache\core\lib\src\server.js:10:94)



Solution 1:[1]

solidity-coverage doesn't work well with ganache 7, which is packaged in latest Truffle 5.4.x.

To resolve:

  1. yarn add -D [email protected] (or npm install --save-dev [email protected])

  2. Create a file called .solcover.js in your working directory and add this content (or modify the existing content to include):

    module.exports = {
      client: require('ganache-cli'),
    };
    

More info can be found here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pang