Created
July 29, 2020 17:15
-
-
Save PaulRBerg/0a8b4806898d81685719d7f7a26afff0 to your computer and use it in GitHub Desktop.
Augmenting the Context type used by Mocha in beforeEach, it, etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Erc20 } from "../typechain/Erc20"; | |
declare module "mocha" { | |
export interface Context { | |
token: Token; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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