Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Augmenting the Context type used by Mocha in beforeEach, it, etc.
import { Erc20 } from "../typechain/Erc20";
declare module "mocha" {
export interface Context {
token: Token;
}
}
import { deployContract } from "ethereum-waffle";
import Erc20Artifact from "../../artifacts/Erc20.json";
import { Erc20 } from "../../typechain/Erc20";
describe("Token", function () {
beforeEach(async function() {
const decimals: number = 18;
const name: string = "My Token";
const symbol: string = "TKN";
this.token = (await deployContract(deployer, Erc20Artifact, [name, symbol, decimals])) as Erc20;
});
it("should test something", async function() {
// this.token has auto-completion here!
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.