> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/legacy-commands-deprecated/running-tests.md).

# Running Tests

Gathering coverage and test information using the SeaLights Node.js Test Listener is done in a few steps.

There are 4 basic steps to gathering coverage and test information using the SeaLights Node.js Agent (`slnodejs`).

1. Start the test stage with `slnodejs start ...`
2. Run the Tests
3. Upload Test Reports
4. End the test stage with `slnodejs end...`

Use the Lab ID to connect the test listener to the application under test. For Unit Tests, see [Unit Tests](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/legacy-commands-deprecated/running-tests/unit-tests.md).

## Starting the Test Stage <a href="#starting-the-test-stage" id="starting-the-test-stage"></a>

First, the SeaLights server needs to be notified that a test stage is starting.

{% tabs %}
{% tab title="Bash" %}

```bash
npx slnodejs start \
  --tokenFile /path/to/sltoken.txt \
  --labId "<Lab ID>" \
  --testStage "Functional Tests"
```

{% endtab %}

{% tab title="PowerShell" %}

```powershell
npx slnodejs start `
  --tokenFile "C:\path\to\sltoken.txt" `
  --labId "<Lab ID>" `
  --testStage "Functional Tests"
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
See [Command Reference](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/command-reference.md#starting-a-test-stage) for full parameter details
{% endhint %}

## Running your tests <a href="#running-your-tests" id="running-your-tests"></a>

### Functional Tests <a href="#functional-tests" id="functional-tests"></a>

Before running your functional tests you need to set up the backend server to receive the test footprints. See [Running Backend Server](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/legacy-commands-deprecated/backend-server-application/running-backend-server.md)

Once set up you now run your tests normally while generating one or more JUnit XML result files to be reported to the SeaLights server.

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

As the Unit Tests are not run against a backend server, you need to run the actual tests using the Sealights Node.js Agent while generating one or more JUnit XML result files to be reported to the SeaLights server. Note that both Junit and Coverage reports must be uploaded for SeaLights to reflect data for your Unit Tests.

For clarification, see: [Unit Tests](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/legacy-commands-deprecated/running-tests/unit-tests.md)

## Upload report files <a href="#upload-report-files" id="upload-report-files"></a>

### Test Case JUnit Report <a href="#test-case-junit-report" id="test-case-junit-report"></a>

The `slnodejs uploadReports` command can be used to upload the junit.xml file.

{% tabs %}
{% tab title="Bash" %}

```bash
npx slnodejs uploadReports \
  --tokenFile /path/to/sltoken.txt \
  --labId "<Lab ID>" \
  --file "/path/to/junit_report.xml"
```

{% endtab %}

{% tab title="PowerShell" %}

```powershell
npx slnodejs uploadReports `
  --tokenFile "C:\path\to\sltoken.txt" `
  --labId "<Lab ID>" `
  --file "C:\path\to\junit_report.xml"
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}

* See [Uploading Reports - More options](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/advanced-features/uploading-reports-more-options.md#uploading-multiple-files) for information on how to upload multiple files
* See [Command Reference](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/command-reference.md#upload-report-files) for full parameter details
  {% endhint %}

### Coverage (nyc) Report <a href="#coverage-nyc-report" id="coverage-nyc-report"></a>

The `slnodejs uploadReports` command can be used to upload the coverage file generated by nyc.

{% tabs %}
{% tab title="Bash" %}

```bash
npx slnodejs nycReport \
  --token $SL_TOKEN \
  --labId $LABID \
  --report "/path/to/coverage/coverage-final.json"
```

{% endtab %}

{% tab title="PowerShell" %}

```powershell
npx slnodejs nycReport `
  --token $env:SL_TOKEN `
  --labId $env:LABID `
  --report "C:\path\to\coverage\coverage-final.json"
```

{% endtab %}
{% endtabs %}

## Ending the Test Stage <a href="#ending-the-test-stage" id="ending-the-test-stage"></a>

Finally, notify the server that a test stage has ended.

{% tabs %}
{% tab title="Bash" %}

```bash
npx slnodejs end \
  --tokenFile /path/to/sltoken.txt \
  --labId "<Lab ID>"
```

{% endtab %}

{% tab title="PowerShell" %}

```powershell
npx slnodejs end `
  --tokenFile "C:\path\to\sltoken.txt" `
  --labId "<Lab ID>"
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
See [Command Reference](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/command-reference.md#ending-a-test-stage) for full parameter details
{% endhint %}


---

# 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.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/node.js-agent/legacy-commands-deprecated/running-tests.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.
