web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

could not be able to run test for web3.js

Open jaikrish5 opened this issue 7 years ago • 2 comments

All issues which aren't created with this template will get immediately closed. "ganache-cli": "^6.0.3", "mocha": "^4.0.1", "solc": "^0.4.19", "web3": "^1.0.0-beta.26"

code at my Inbox.test.js:-

const assert = require('assert'); const ganache = require('ganache-cli'); const Web3 = require('web3'); const web3 = new Web3(ganache.provider());

// beforeEach(() => { // web3.eth.getAccounts().then(fetchedAccounts => { // // console.log(fetchedAccounts); // // }); // // }); // // describe('Inbox',() => { // it('deploys a contract',() => {}); // // // });

class Car{ stop() { return 'stopped'; } drive() {

return 'drive';

}

}

describe('car',()=>{

   it('can drive',()=>{

         const car = new Car();
          assert.equal(car.stop(),'stopped');

});

});

when i run the test through the command npm run test i get the error like this:-

C:\Users\S.Jaikrish\Desktop\ethereum\inbox\node_modules\ganache-cli\build\lib.node.js:63898

var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&"function"==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_W

TypeError: core.addProviders is not a function at Object. (C:\Users\S.Jaikrish\Desktop\ethereum\inbox\node_modules\web3\src\index.js:76:6) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (C:\Users\S.Jaikrish\Desktop\ethereum\inbox\test\Inbox.test.js:3:14) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at C:\Users\S.Jaikrish\Desktop\ethereum\inbox\node_modules\mocha\lib\mocha.js:231:27 at Array.forEach () at Mocha.loadFiles (C:\Users\S.Jaikrish\Desktop\ethereum\inbox\node_modules\mocha\lib\mocha.js:228:14) at Mocha.run (C:\Users\S.Jaikrish\Desktop\ethereum\inbox\node_modules\mocha\lib\mocha.js:514:10) at Object. (C:\Users\S.Jaikrish\Desktop\ethereum\inbox\node_modules\mocha\bin_mocha:484:18) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:191:16) at bootstrap_node.js:612:3 npm ERR! code ELIFECYCLE npm ERR! errno 7 npm ERR! [email protected] test: mocha npm ERR! Exit status 7 npm ERR! npm ERR! Failed at the [email protected] test script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\S.Jaikrish\AppData\Roaming\npm-cache_logs\2019-02-01T10_01_58_108Z-debug.log

please help!!

jaikrish5 avatar Feb 01 '19 10:02 jaikrish5

please use template to submit issues. Closing due to no template used.

joshstevens19 avatar Feb 01 '19 17:02 joshstevens19

same problem

Hrishabhgaur avatar Jun 25 '19 18:06 Hrishabhgaur