Skip to main content
Changed it to use the actual function name
Source Link

you can either use truffle-assertions with

npm install truffle-assertions

in your test code

const truffleAssert = require('truffle-assertions');
await truffleAssert.reverts(InstancecontractInstance.testwithdraw(1));

or you can use a simple try catch with

try {
    await InstancecontractInstance.testwithdraw(1);
} catch(err) {
    Error = err
}
assert.equal(Error.reason, 'not valid!');

you can either use truffle-assertions with

npm install truffle-assertions

in your test code

const truffleAssert = require('truffle-assertions');
await truffleAssert.reverts(Instance.test(1));

or you can use a simple try catch with

try {
    await Instance.test(1);
} catch(err) {
    Error = err
}
assert.equal(Error.reason, 'not valid!');

you can either use truffle-assertions with

npm install truffle-assertions

in your test code

const truffleAssert = require('truffle-assertions');
await truffleAssert.reverts(contractInstance.withdraw());

or you can use a simple try catch with

try {
    await contractInstance.withdraw();
} catch(err) {
    Error = err
}
assert.equal(Error.reason, 'not valid!');
Source Link

you can either use truffle-assertions with

npm install truffle-assertions

in your test code

const truffleAssert = require('truffle-assertions');
await truffleAssert.reverts(Instance.test(1));

or you can use a simple try catch with

try {
    await Instance.test(1);
} catch(err) {
    Error = err
}
assert.equal(Error.reason, 'not valid!');