I'm new to ethereum development and trying to test SimpleStorage
contract using truffle:
I created file structure using turffle init
and here is the files sturctur:
~/Desktop/truffle-test$ tree .
.
├── build
│ └── contracts
│ └── SimpleStorage.json
├── contracts
│ └── SimpleStorage.sol
├── migrations
│ └── 3_deploy_simpleStorage.js
├── test
│ └── simpleStorage-test.js
└── truffle-config.js
my simpleStorage-test.js
is:
const simpleStorage = artifacts.require('../contracts/SimpleStorage.sol');
contrcat('SimpleStorage', ()=> {
it('should update data', async ()=> {
const storage = await simpleStorage.new();
await storage.set(10);
const data = await storage.get();
assert(data.toString()==='10');
});
});
I can migrate the contract and I see transaction appear on Ganache-GUI but when I run truffle test
I get:
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
ReferenceError: contrcat is not defined
at Object.<anonymous> (/home/pc/Desktop/truffle-test/test/simpleStorage-test.js:3:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:390:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:387:14)
at Mocha.run (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:961:10)
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/testing/Test.js:157:1
at new Promise (<anonymous>)
at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/testing/Test.js:156:1)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.module.exports [as run] (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/test/run.js:56:1)
at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)
Truffle v5.4.26 (core: 5.4.26)
Node v16.13.0
I tried differnt things like SimpleStorage
instead of ../contracts/SimpleStorage.sol
in tartifacts.require
but none solved the issue. So appreciate your help.