如何解决错误“"before all" hook: prepare suite:”

How to solve the error ""before all" hook: prepare suite:"

当我测试我的合同时,我得到了这个错误“"before all" hook: prepare suite:”

有谁知道如何解决这个错误?

这是我的依赖项。 "truffle": "5.0.7", "web3":“1.0.0-beta.46”

npm uninstall -g truffle

npm install -g truffle@5.1.10(总是让我回到正轨)

此外,当使用 几个 测试套件时会出现此问题,这些测试套件使用没有 await 的异步测试助手(例如,OpenZeppelin Test Helpers: expectEvent, expectRevert).

考虑示例:

合同

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract Test03 {
    address public owner;
    int32 public id;

    event ContractCreated();

    constructor() {
        owner = msg.sender;

        emit ContractCreated();
    }

    function doSmth(int32 _id) public {
        require(id != 0, "id is zero");
        id= _id;
    }
}

测试

const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');

const TestContract = artifacts.require('Test03');

contract('Test03', function (accounts) {
    const [owner] = accounts;
    const txParams = { from: owner };

    beforeEach(async function () {
        this.testContract = await TestContract.new(txParams);
    });

    describe('construction', function () {
        it('initial state', async function () {
            expect(await this.testContract.owner()).to.equal(owner);

            // !! DONT FORGET await before expectEvent-call <<------------------------------
            await expectEvent.inConstruction(this.testContract, 'ContractCreated');
        });
    });

    describe('doSmth', function () {
      it('fail when passed zero id', async function () {

        // !! DONT FORGET await before expectRevert-call <<------------------------------
        await expectRevert(
          this.testContract.doSmth(0, txParams),
          "id is zero");
      });
  });    
});

package.json

{
..
  "devDependencies": {
    "@openzeppelin/test-helpers": "^0.5.10"
  }
..
}