Open jjgonecrypto opened 4 years ago
Thanks for raising this issue!
We've been discussing this issue a bunch recently. Note that there are edge cases, if your tests alter your contract state. We're looking at solutions for allowing this special-case behavior in a "buyer beware" way (i.e., we can't solve the edge cases, but maybe your tests aren't affected by those)
Thanks @gnidan . We are using evm_snapshot
on beforeEach
and evm_revert
on afterEach
so tests altering contract state is not an issue.
plus one... i think allowing exec to run tests would be perfect make truffle test keep cleanroom behaviour, but use exec for quick iterations when doing TDD
Issue
I'd like to know if there is a way to execute tests in truffle console (or otherwise) without having to restart ganache and redeploy between test runs. This is imperative to speed up the feedback loop when iterating on test specs when there are no changes to the underlying Solidity files. (Note: we are employing snapshot and restores before and after each test respectively).
Steps to Reproduce
truffle console
> deploy
> exec singleTest.js
Expected Behavior
I'm looking for a way to run step 3 with mocha injected, with the same globals available (
web3
,contract
,it
,before(Each)?|after(Each)?
, that way I don't have to rewrite tests in a generic way forexec
and then port them back to regular specs when done.An alternative might be adding flags to the
test
command as in:> test --no-compile --no-deploy singleTest.js
- but that's a feature request I suspect.Actual Results
exec
won't setup testing globals andtest
will always try to recompile and redeploy, adding on redundant wait time to the testing feedback loopEnvironment
truffle version
): 5.1.4node --version
): 10.16.3npm --version
): 6.13.7