简体   繁体   English

松露测试,类型错误:它不是 function

[英]Truffle tests, Type Error: it is not a function

I am new to testing with java script and also new to writing smart contracts.我是使用 java 脚本测试的新手,也是编写智能合约的新手。 I have watched some tutorials regarding writing the tests and tried to orientate my test with for example the Metacoin example from truffle.我看过一些关于编写测试的教程,并尝试用例如来自 truffle 的 Metacoin 示例来定位我的测试。

Now when I try to run my basic first test to get the total supply of my ERC20 token, i get the following error message:现在,当我尝试运行基本的第一个测试以获取我的 ERC20 代币的总供应量时,我收到以下错误消息:

  1. Uncaught error outside test suite测试套件外未捕获的错误

0 passing (2ms) 1 failing 0 通过 (2ms) 1 失败

  1. Uncaught error outside test suite: Uncaught TypeError: it is not a function测试套件外未捕获的错误:未捕获的类型错误:它不是 function

My test code looks like this:我的测试代码如下所示:

 const { assert } = require("console"); const { it } = require("ethers/wordlists"); const charytoken = artifacts.require("CharyToken"); contract("CharyToken test", async accounts => { it("should get the Balance of CT of this contract", async() => { const instance = await charytoken.deployed(); const ctbalance = await instance.totalSupply.call(); assert.equal(ctbalance.valueOf(), 10000000000000000000000); }); });

If anyone knows what I am doing wrong/ I am missing, I would appreachiate help a lot如果有人知道我做错了什么/我错过了,我会提供很多帮助

It's because you imported the wrong it .那是因为你输入了错误的it It's not from ethers/wordlist它不是来自ethers/wordlist

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM