TypeError: Cannot read properties of undefined (reading 'equal') and also in truffle console when i try to see the number of candidates it is also undefined. is there any problme with the command (.candidatesCount().toNumber)?
const { assert } = require("assert");
var Election = artifacts.require("./Election.sol");
contract("Election", function (acc) {
it("initializes with two candidates", function () {
return Election.deployed()
.then(function (ins) {
return ins.candidatesCount();
})
.then(function (count) {
assert.equal(count, 2);
});
});
});
CodePudding user response:
const assert = require("assert");
Why import a name value? That's whats causing the issue
CodePudding user response:
assert
gets exported with a default export (module.exports = function assert() {...}
) so you need to import it accordingly.
const assert = require('assert');