dappuniversity / eth-todo-list

Blockchain Todo App Tutorial Powered by Ethereum Smart Contracts
549 stars 549 forks source link

Truffle test error "TypeError: Cannot read properties of undefined (reading 'address')" #41

Closed Subhrangsu90 closed 1 year ago

Subhrangsu90 commented 1 year ago

code:

const TodoList = artifacts.require("./TodoList.sol");

contract("TodoList", (accounts) => {
  before(async () => {
    this.TodoList = await TodoList.deployed();
  });

  it("deploys successfully", async () => {
    const address = await this.todoList.address;
    assert.notEqual(address, 0x0);
    assert.notEqual(address, "");
    assert.notEqual(address, null);
    assert.notEqual(address, undefined);
  });
});

error:

C:\Users\DELL\eth-todo-list>truffle test
Using network 'development'.

Compiling .\contracts\TodoList.sol...

  Contract: TodoList
    1) deploys successfully
    > No events were emitted

  0 passing (36ms)
  1 failing

  1) Contract: TodoList
       deploys successfully:
     TypeError: Cannot read properties of undefined (reading 'address')
      at Context.<anonymous> (test\TodoList.test.js:9:41)
      at C:\Users\DELL\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\testing\testrunner.js:134:1
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

Please help me to fix this error at the time of 'truffle test' .