The SDK uses two types of tests, End-to-End (E2E) and unit tests, located under the folder.
Unit Tests
Unit tests are meant to test the output of a function in the SDK with the provided input. For example, we can test whether an account address is valid.
End-to-end tests are meant to test the end-to-end operations starting from the SDK methods through to the blockchain.
For example, to test if a transaction has been submitted, we start with building a transaction payload that the SDK expects, submit the request to the REST API, and fetch the transaction data to make sure it has been fully committed to the blockchain.
The SDK provides an easy way to run integration tests by spinning up a local node and running tests against it. For example, one can build their integration tests against a local node with the SDK like below:
import { LocalNode, EndlesssConfig, Endless } from "@endless-labs/ts-sdk";
// initiate a LocalNode instance
const localNode = new LocalNode();
// Run a local node
await localNode.run();
// Write some tests
test("test my app", async () => {
const endlesssConfig = new EndlessConfig({network:Network.LOCAL})
const endless = new Endless(endlessConfig)
// rest of test.....
}
// Stop the local node
localNode.stop();