Hardhat test having problems

i have problems with test contract in hardhat trying to solve this i change name to box too

:computer: Environment
hardhat solidity 0.8.0

:memo:Details
error
describe(‘Box’, function () {
^
ReferenceError: describe is not defined
:1234: Code to reproduce

    // test/Box.js
    // Load dependencies
    const { expect } = require('chai');

    // Start test block
    describe('Box', function () {
      before(async function () {
        this.Box = await ethers.getContractFactory("Box");
      });

      beforeEach(async function () {
        this.box = await this.Box.deploy();
        await this.box.deployed();
      });

      // Test case
      it('retrieve returns a value previously stored', async function () {
        // Store a value
        await this.box.store(42);

        // Test if the returned value is the same one
        // Note that we need to use strings to compare the 256 bit integers
        expect((await this.box.retrieve()).toString()).to.equal('42');
      });
    });
1 Like

Hi @Guard_Colombia,

I suggest going through the following guide to ensure that you have your test environment setup: https://docs.openzeppelin.com/learn/writing-automated-tests#setting-up-a-testing-environment

1 Like

Make sure you're running npx hardhat test instead of npx hardhat run test. That tripped me over and resulted in the same Reference error.

3 Likes

This worked well for me, Thanks :pray:

I am having the same error.

:computer: Environment :
hardhat solidity 0.8.7

ReferenceError: describe is not defined

I'm running :

npx hardhat run test/Botminator.js --network hardhat

try

npx hardhat test test/Botminator.js

1 Like