Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Testing

Icon LinkTesting

In order to test your Sway and TS-SDK applications, you can test your code in a number of ways:

  1. Testing with TS-SDK: Compiling you Sway code and connecting to the methods using TS-SDK and JS testing frameworks
  2. Using forc test see the Sway docs Icon Link for more info
  3. Using the Rust SDK Icon Link

Icon LinkTesting with TS-SDK

To test your Sway applications using the TS-SDK, you can pick whatever testing library or framework you feel comfortable with. There isn't any specific testing framework needed, it is entirely up to the user. That being said, the TS-SDK uses Vitest Icon Link for its tests.

Icon LinkWallet Test Utilities

You'll often want to create one or more test wallets when testing your contracts.

For this, you can find two simple utilities on the account package:

On top of these two utilities, if you want to quickly get up and running with a local node, you can use the launchNodeAndGetWallets from the @fuel-ts/account/test-utils package.

import { launchNodeAndGetWallets } from "@fuel-ts/account/test-utils";
 
const { stop, wallets, provider } = await launchNodeAndGetWallets();
 
// ... do your tests - deploy contracts using the wallets, fetch info from the provider, etc.
 
// stop the node when you're done
stop();

See also:

  1. Setting up test wallets
  2. Testing in TS