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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.endless.link/endless/devbuild/build/endless-sdks/typescript-sdk/testing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
