@0x/contracts-test-utils: Make blockchainTests() automatically call blockchainLifecycle.startAsync() and blockchainLifecycle.revertAsync() in a before() and after() directive.

This commit is contained in:
Lawrence Forman 2019-07-28 01:52:00 -04:00
parent 9792246970
commit 99e242affd
2 changed files with 13 additions and 2 deletions

View File

@ -80,7 +80,18 @@ function defineBlockchainSuite<T>(
describeCall: Mocha.ContextDefinitionCallback<T>,
): T {
return describeCall(description, function(this: Mocha.ISuiteCallbackContext): void {
callback.call(this, BlockchainTestsEnvironment.create());
const env = BlockchainTestsEnvironment.create();
before(
async (): Promise<void> => {
return env.blockchainLifecycle.startAsync();
},
);
before(
async (): Promise<void> => {
return env.blockchainLifecycle.revertAsync();
},
);
callback.call(this, env);
});
}

View File

@ -29,7 +29,7 @@ blockchainTests('mocha blockchain extensions', env => {
});
});
blockchainTests/*.only*/('only', () => {
blockchainTests('only', () => {
it.skip("can't test `only` :-(", () => {
// no-op.
});