I need some assistance running the approving test. Currently running one of the basic test script to approve the token from exchange. I am getting the below attached err in WSL. Also, i believe the error also seems to be happening in token.test.js in highlight area. As per the error, the exchange seems to be an invalid argument, which doesn't make sense for me as I did pass the receiver argument in the same way. Any help would be appreciated.


contract ('Token', ([deployer, receiver, exchange])=>{
describe('approving tokens', ()=>{
    let result
    let amount
        amount= tokens(1000)
        ***result = await token.approve(exchange, amount, {from: deployer})***
    describe('success', ()=>{
        it('//allocates an allowance for delegated token spending on exchange ', async()=>{
            const allowance = await token.allowance(deployer,exchange)

    describe('failure', ()=>{




mapping (address=>mapping(address =>uint256)) public allowance;
function approve(address _spender, uint256 _value) public returns(bool success){
    allowance[msg.sender][_spender] = _value;


enter image description here

1 Answer 1


The issue was happening in Token.test.js file. Compiler was expecting an exception as the code block ended with rejectedWith. It should have been just rejected. There was nothing wrong with the above code. Hope it helps, as I wasted a whole day an half on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.