testing: TypeError: simpleStorage.retrieve is not a function #1007
-
I am trying to run first test(on YT video its around @9:35:00). Deploy.js works fine for SimpleStorage. But test has issues with retrieve function: $ yarn hardhat test
yarn run v1.22.19
$ .../hardhat-simple-storage/node_modules/.bin/hardhat test
SimpleStorage
1) should start with a favourite number of 0
0 passing (28s)
1 failing
1) SimpleStorage
should start with a favourite number of 0:
TypeError: simpleStorage.retrieve is not a function
at Context.<anonymous> (test/test-deploy.js:13:47)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. If deploy.js is working fine, why test-deploy is having issues with a function? |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Jul 16, 2022
Replies: 3 comments 5 replies
-
@mghildiy make sure you are adding parenthesis along with retrieve |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here is my test code: const { assert } = require("chai");
const { ethers } = require("hardhat");
describe("SimpleStorage", function () {
let simpleStorageFactory, simpleStorage;
beforeEach(async function () {
simpleStorageFactory = await ethers.getContractFactory("SimpleStorage");
simpleStorage = simpleStorageFactory.deploy();
});
it("should start with a favourite number of 0", async function () {
const currentNumber = await simpleStorage.retrieve();
assert.equal(currentNumber.toString(), 0);
});
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
- assert.equal(currentNumber.toString(), 0);
+ assert.equal(currentNumber.toString(), "0"); |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
alymurtazamemon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mghildiy