Truffle offers many conveniences for writing tests for Ethereum smart contracts. The benefits include no need for a separate chain process like Ganache, complex automation of linking and deploying of library contracts like SafeMath However, there is an inverse of control and tests must be executed using truffle command and must follow Mocha/Chai pattern.
Are there alternatives for Truffle that would especially
-
Would use modern and standard test runners like Jest instead of a custom wrapper commands
-
Play nicely with TypeScript
-
Set up and tear down in-process blockchain easily
-
Support automatic compilation, linking and deployment of complex contracts like ones with SafeMath library
I found e.g. this example for Jest, but it is unfinished project. There is another one with Ganache and Jest, but very simplified and does not support linking contracts.
Best Answer
I found openzeppelin-test-environment solving my problem. It allows ephemeral Ethereum blockchain setup, contract deployment, etc. relatively easy.
Below is my original Truffle + TypeScript test translated to OpenZeppelin + Jest + power-assert.
Jest test
Original Truffle test (Mocha + power-assert)
My package.json
For further information how to set up Jest + TypeScript + power-assert look here.