> For the complete documentation index, see [llms.txt](https://docs.endless.link/endless/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.endless.link/endless/devbuild/build/endless-sdks/typescript-sdk/testing.md).

# Testing

## SDK Testing <a href="#sdk-testing" id="sdk-testing"></a>

The SDK uses two types of tests, `End-to-End (E2E)` and `unit` tests, located under the [tests](/endless/devbuild/build/endless-sdks/typescript-sdk/testing.md) folder.

### Unit Tests <a href="#unit-tests" id="unit-tests"></a>

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.

```js
test("account address is valid", () => {
  const { valid } = AccountAddress.isValid({
    input: "0x1",
  });
  expect(valid).toBe(true);
});
```

Can check [here](/endless/devbuild/build/endless-sdks/typescript-sdk/testing.md) for the SDK unit tests

### E2E Tests <a href="#e2e-tests" id="e2e-tests"></a>

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.

```js
test("transaction submission", async () => {
  const transaction = await endless.transaction.build.simple({
    sender: sender.accountAddress,
    data: {
      function: `0x1::endless_account::transfer`, // replace with your application's transaction
      functionArguments: [receiver.accountAddress, 1],
    },
  });
  const response = await endless.signAndSubmitTransaction({
    signer: sender,
    transaction,
  });
  await endless.waitForTransaction({
    transactionHash: response.hash,
  });
  expect(response.success).toBe(true);
});
```

Can check [here](/endless/devbuild/build/endless-sdks/typescript-sdk/testing.md) for the SDK e2e tests

### Integration Tests <a href="#integration-tests" id="integration-tests"></a>

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:

```js
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();
```
