首先我们来测试一下
Typescript
yarn add -D ts-node typescript
测试之前
hardhat.config.js -> hardhat.config.ts
写测试
import "@nomiclabs/hardhat-ethers";
import { ethers } from "hardhat";
import { expect } from "chai";
describe("Hello World", () => {
it("should get the hello world", async () => {
const HW = await ethers.getContractFactory("HelloWorld");
const hello = await HW.deploy();
expect(await hello.hello()).to.equal("Hello, World!");
});
});
安装测试类型依赖
yarn add -D @types/mocha
Error
An unexpected error occurred:
error TS5109: Option 'moduleResolution' must be set to 'NodeNext' (or left unspecified) when option 'module' is set to 'NodeNext'.