我得到一个错误:“quot;TypeError:无法读取属性';2';未定义的&引用;在javascript测试文件中

我得到一个错误:“quot;TypeError:无法读取属性';2';未定义的&引用;在javascript测试文件中,javascript,arrays,solidity,truffle,Javascript,Arrays,Solidity,Truffle,使用块菌测试套件,我得到以下结果: it("should not allow non-owner to delete people", async function(){ let instance = await People.deployed(); await instance.createPerson("Lisa", 35, 160, {from: accounts[2], value: web3.utils.toWei("

使用块菌测试套件,我得到以下结果:

  it("should not allow non-owner to delete people", async function(){
    let instance = await People.deployed();
    await instance.createPerson("Lisa", 35, 160, {from: accounts[2], value: web3.utils.toWei("1", "ether")});
    await truffleAssert.fails(instance.deletePerson(accounts[2], {from: accounts[2]}), truffleAssert.ErrorType.REVERT);
  });
  it("should allow the owner to delete people", async function(){
   let instance = await People.new();
   await instance.createPerson("Lisa", 35, 160, {from: accounts[2], value: web3.utils.toWei("1", "ether")});
   await truffleAssert.passes(instance.deletePerson(accounts[1], {from: accounts[0]}));
  });
合同:人
√ 不应创建年龄超过150岁(134ms)的人
√ 不应创建未付款的人员(143ms)
√ 应正确设置传感器状态(333ms)
√ 应正确设置年龄(65毫秒)
1) 不应允许非所有者删除人员
>没有发出任何事件
2) 应允许所有者删除人员
>没有发出任何事件
4次通过(898ms)
2失败
1) 合同:人
不应允许非所有者删除人员:
TypeError:无法读取未定义的属性“2”
在上下文中。(test\peopletest.js:31:65)
在进程中。_tick回调(内部/process/next_tick.js:68:7)
2) 合同:人
应允许所有者删除人员:
TypeError:无法读取未定义的属性“2”
在上下文中。(test\peopletest.js:36:64)
在进程中。_tick回调(内部/process/next_tick.js:68:7)
最后两次测试应该和其他学生一样有效。然而,我有同样的打字错误。
我不明白为什么它不能识别数组语法。

看起来好像
帐户
没有定义(这很有意义-我在你的代码中没有看到任何声明…)也许你的意思是
web3.eth.accounts
或类似的东西?你能显示完整的测试文件吗?我已经解决了这个问题,虽然我不知道具体怎么做。
 Contract: People
    √ should't create a person with age over 150 years (134ms)
    √ shouldn't create a person without payment (143ms)
    √ should set seniour status correctly (333ms)
    √ should set age correctly (65ms)
    1) should not allow non-owner to delete people
    > No events were emitted
    2) should allow the owner to delete people
    > No events were emitted


  4 passing (898ms)
  2 failing

  1) Contract: People
       should not allow non-owner to delete people:
     TypeError: Cannot read property '2' of undefined
      at Context.<anonymous> (test\peopletest.js:31:65)
      at process._tickCallback (internal/process/next_tick.js:68:7)

  2) Contract: People
       should allow the owner to delete people:
     TypeError: Cannot read property '2' of undefined
      at Context.<anonymous> (test\peopletest.js:36:64)
      at process._tickCallback (internal/process/next_tick.js:68:7)