From 99e242affd8a28a05b746756b50c83b0db6e8b25 Mon Sep 17 00:00:00 2001 From: Lawrence Forman Date: Sun, 28 Jul 2019 01:52:00 -0400 Subject: [PATCH] `@0x/contracts-test-utils`: Make `blockchainTests()` automatically call `blockchainLifecycle.startAsync()` and `blockchainLifecycle.revertAsync()` in a `before()` and `after()` directive. --- contracts/test-utils/src/mocha_blockchain.ts | 13 ++++++++++++- contracts/test-utils/test/mocha_blockchain.ts | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/contracts/test-utils/src/mocha_blockchain.ts b/contracts/test-utils/src/mocha_blockchain.ts index 68263c834a..8dc00b5c42 100644 --- a/contracts/test-utils/src/mocha_blockchain.ts +++ b/contracts/test-utils/src/mocha_blockchain.ts @@ -80,7 +80,18 @@ function defineBlockchainSuite( describeCall: Mocha.ContextDefinitionCallback, ): T { return describeCall(description, function(this: Mocha.ISuiteCallbackContext): void { - callback.call(this, BlockchainTestsEnvironment.create()); + const env = BlockchainTestsEnvironment.create(); + before( + async (): Promise => { + return env.blockchainLifecycle.startAsync(); + }, + ); + before( + async (): Promise => { + return env.blockchainLifecycle.revertAsync(); + }, + ); + callback.call(this, env); }); } diff --git a/contracts/test-utils/test/mocha_blockchain.ts b/contracts/test-utils/test/mocha_blockchain.ts index 2f291781b1..e4c2f35038 100644 --- a/contracts/test-utils/test/mocha_blockchain.ts +++ b/contracts/test-utils/test/mocha_blockchain.ts @@ -29,7 +29,7 @@ blockchainTests('mocha blockchain extensions', env => { }); }); - blockchainTests/*.only*/('only', () => { + blockchainTests('only', () => { it.skip("can't test `only` :-(", () => { // no-op. });