---
url: https://huldoser.github.io/test-inventory/api/functions/scanSource.md
---
# Function: scanSource()

> **scanSource**(`options`): [`Inventory`](../interfaces/Inventory.md)

Scans the code of one test file, without reading anything from disk.

Throws a `TypeError` for invalid options. Problems in the code itself are reported as diagnostics.
A custom `test` object imported from a local file can't be followed here; use `scan()` for that.

## Parameters

### options

#### code

`string`

#### relativeFilePath

`string`

Path of the file from the project root, used in the output and in ids.

#### framework

`"playwright"` | `"vitest"` | `"jest"` | `"mocha"` | `"jasmine"` | `"cypress"` | `"webdriverio"` | `"node"` | `"bun"`

#### frameworkVersion?

`string` | `null`

The framework version whose rules apply. The newest rules apply when it is missing.

#### comments?

`"all"` | `"non-active"` | `"none"`

Which tests get the comments above them. Defaults to `non-active`.

#### expandCases?

`boolean`

One test or describe per case of a `.each` or `.for` table and per pass of a loop whose values the scan can work
out, each with the title the runner gives it. Defaults to `false`: one record per declaration.

## Returns

[`Inventory`](../interfaces/Inventory.md)
