Is there a way to test without needing to run dfx deploy all of the time?

Is there a way to test without needing to run dfx deploy each time? For example, in a typical React application, you can make a simple UI update without needing to manually build and deploy the application. Is there an equivalent of this using dfx?

1 Like

If you’re only testing the UI, you can run your regular web server and tell your JS code the address of the local replica running on DFX. But if you want to test canister code, then yes you need to run dfx deploy each time.

2 Likes

Thank you for the response!

Is the team working on any tools that would it make it easier to test canisters without running dfx deploy each time?

Are you using Rust or Motoko?

This is available for Motoko already actually (I only use Rust so I didn’t think about that when I first responded): Announcing `mo-dev`: live reloading for Motoko dapps

I’m not aware of any similar initiatives for Rust.

2 Likes

Thank you for the resource for Motoko! I am actually working with Azle and I’ll ask the Demergent Labs team if they have any tool or plans to create a tool in the future.

1 Like

Maybe you can reuse this idea with Azle:

In Rust canisters, we (the SDK team) try to split canister logic and the canister interface so that we can write unit tests for the canister logic. This way we can run unit tests quickly while developing and then write some integration tests for CI that confirms it works this way for a deployed canister as well.

This approach becomes pretty tedious to use once you have to perform a lot of calls to other canisters because you’ll have to mock a bunch of responses and have a bunch of functions that perform only part of the logic, but I still think it’s the best way to test if you want to test your canister as well as possible

1 Like

there’s also pocket-ic — emulator in Rust // Lib.rs

1 Like

In icpp, the C++ CDK, there are two build modes:

  • icpp build-wasm
  • icpp build-native

The first is the optimized wasm for the IC.
The latter is a native debug executable, using a MockIC.

You can use the exact same canister code to test without the need to deploy with dfx, and even more powerful is that you can debug interactively in VS Code.

I develop all my code like that and then do final testing in the network once it works natively.

1 Like