0

Long story short my contract is not passing the deployment test using truffle, mocha, and chai.

I ran the code individually in the truffle console and it was returning an address just fine but it won't pass the test I wrote. I'm positive I wrote the mocha test well but I can't figure it out.

side note: running truffle test from the truffle console causes node.js to throw an error. However, running truffle test from the CLI works fine and just returns 0 passing.

Here is the code

const { expect } = require('chai')
.use(require('chai-as-promised'))
.should()

const Auction = artificats.require('./implementor.sol');

contract('Go',(accounts) => {
    let contract 
    
    describe('deployment',async() =>{
        it('deploys successfully',async ()=>{
            contract = await Go.deployed()
            const address = contract.address
            console.log(address)
            console.log('ran')
            assert.NotEqual(address,'')
        })
    } )
})

So I tried it this way because I thought maybe the contract wasn't being created at all.

const { expect } = require('chai')
.use(require('chai-as-promised'))
.should()

const Auction = artificats.require('./implementor.sol');

contract('Go',(accounts) => {
    beforeEach(async () => {
        this.Go = await Go.new()
    });
    
    describe('deployment',async() =>{
        let contract 
        it('deploys successfully',async ()=>{
            contract = await Go.deployed();
            const address = contract.address;
            assert.NotEqual(address,'');
            return(address);
        });
    } );
});
0

I see at least a couple of issues to be addressed:

  • You should replace artificats by artifacts
  • You should use the correct variable when creating the new contract instance. In your case, Auction instead of Go.

In summary:

const Auction = artifacts.require('./implementor.sol');

contract('Go',(accounts) => {
    let Go;
    beforeEach(async () => {
        Go = await Auction.new()
    });

    //...
 }
0

So @sergi Juanati was correct my spelling was super off. However, that wasn't the reason I wasn't getting anything returned not even an error. The reason is for some reason running

truffle test

wasn't running the actual test. No matter which directory I was in it was not running the test so I had to specify it myself. I appreciate all the help!.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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