# TestService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/TestService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/TestService

A service used by Roblox to run controlled tests of the engine. It is available for developers to use, to a limited degree.

## Properties

### Description

```luau
TestService.Description: string = ""
```

A description of the test being executed.

### Enabled

```luau
TestService.Enabled: boolean = false
```

- Tags: Read only, Thread unsafe

### AutoRuns

```luau
TestService.AutoRuns: boolean = true
```

If set to `true`, the game will start running when the service's [`TestService:RunAsync()`](https://rapi.sleaze.dev/classes/TestService.md) method is called.

### IsPhysicsEnvironmentalThrottled

```luau
TestService.IsPhysicsEnvironmentalThrottled: boolean = true
```

Sets whether or not the physics environment should be throttled while running this test.

### IsSleepAllowed

```luau
TestService.IsSleepAllowed: boolean = true
```

Sets whether or not physics objects will be allowed to fall asleep while the test simulation is running.

### ThrottlePhysicsToRealtime

```luau
TestService.ThrottlePhysicsToRealtime: boolean = true
```

Sets whether the test should be throttled to simulate time according to real world time or as fast as possible.

### Is30FpsThrottleEnabled

```luau
TestService.Is30FpsThrottleEnabled: boolean = true
```

- Tags: Deprecated, Not replicated, Load only
- Use instead: [`TestService.ThrottlePhysicsToRealtime`](https://rapi.sleaze.dev/classes/TestService.md)

**Deprecated:** This has been deprecated and directly renamed to [`ThrottlePhysicsToRealtime`](https://rapi.sleaze.dev/classes/TestService.md) to better reflect its practical use.

Sets whether or not the physics engine should be throttled to 30 FPS while the test is being ran.

### ErrorCount

```luau
TestService.ErrorCount: number = 0
```

- Tags: Read only, Save only

Measures how many errors have been recorded in the test session.

### TestCount

```luau
TestService.TestCount: number = 0
```

- Tags: Read only, Save only

Measures how many test calls have been recorded in the test session.

### WarnCount

```luau
TestService.WarnCount: number = 0
```

- Tags: Read only, Save only

Measures how many warning calls have been recorded in the test session.

### ExecuteWithStudioRun

```luau
TestService.ExecuteWithStudioRun: boolean = false
```

When set to `true`, [`TestService`](https://rapi.sleaze.dev/classes/TestService.md) will be executed when using the **Run** action in Roblox Studio.

### NumberOfPlayers

```luau
TestService.NumberOfPlayers: number = 0
```

The number of players expected in this test, if any.

### SimulateSecondsLag

```luau
TestService.SimulateSecondsLag: number = 0
```

Sets a specific amount of additional latency experienced by players during the test session.

### Timeout

```luau
TestService.Timeout: number = 10
```

The maximum amount of time that tests are allowed to run for.

## Methods

### CaptureScreenshotAsync

```luau
TestService:CaptureScreenshotAsync(artifactName: string? = "", options: { [string]: any }? = nil): ...any
```

- Tags: Yields, Capabilities: InternalTest

### Check

```luau
TestService:Check(condition: boolean, description: string, source: Instance? = nil, line: number? = 0)
```

Prints result of a condition to the output.

Parameters:

- `condition`: The boolean expression to evaluate as the test assertion.
- `description`: A label that identifies this check in the test output.
- `source`: The script instance that invoked the check, used for output attribution. Defaults to `nil`.
- `line`: The line number in the source script where the check was called. Defaults to `0`.

### Checkpoint

```luau
TestService:Checkpoint(text: string, source: Instance? = nil, line: number? = 0)
```

Prints `Test checkpoint:` followed by a string to the output in blue text.

Parameters:

- `text`: The message to print alongside the checkpoint label.
- `source`: The script instance that invoked the checkpoint, used for output attribution. Defaults to `nil`.
- `line`: The line number in the source script where the checkpoint was called. Defaults to `0`.

### ConvertSlimAcrToObj

```luau
TestService:ConvertSlimAcrToObj(acrFullFilePath: string, objFileName: string): string
```

- Tags: Roblox script security

### CreateAndSavePropertySet

```luau
TestService:CreateAndSavePropertySet(source: Instance): string
```

- Tags: Roblox script security

### CreateExtraAssetsFileFromPropertySet

```luau
TestService:CreateExtraAssetsFileFromPropertySet(psetFileName: string): string
```

- Tags: Roblox script security

### Done

```luau
TestService:Done()
```

Prints `Testing Done` to the output in blue text.

### Error

```luau
TestService:Error(description: string, source: Instance? = nil, line: number? = 0)
```

Prints a red error message to the output, prefixed by `TestService:`.

Parameters:

- `description`: The error message text to display.
- `source`: The script instance that raised the error, used for output attribution. Defaults to `nil`.
- `line`: The line number in the source script where the error was raised. Defaults to `0`.

### Fail

```luau
TestService:Fail(description: string, source: Instance? = nil, line: number? = 0)
```

Indicates a fatal error in a [`TestService`](https://rapi.sleaze.dev/classes/TestService.md) run.

Parameters:

- `description`: The failure message text to display.
- `source`: The script instance where the failure occurred, used for output attribution. Defaults to `nil`.
- `line`: The line number in the source script where the failure was triggered. Defaults to `0`.

### FetchExtraAssets

```luau
TestService:FetchExtraAssets(extraAssetsFileName: string): string
```

- Tags: Roblox script security

### FetchTestControlsAsync

```luau
TestService:FetchTestControlsAsync(category: string): ...any
```

- Tags: Yields, Capabilities: InternalTest

### GetTestControls

```luau
TestService:GetTestControls(providerName: string): { [string]: any }
```

- Tags: Capabilities: InternalTest

### GetTestControlSchema

```luau
TestService:GetTestControlSchema(providerName: string): { [string]: any }
```

- Tags: Capabilities: InternalTest

### ListTests

```luau
TestService:ListTests(): { any }
```

### Message

```luau
TestService:Message(text: string, source: Instance? = nil, line: number? = 0)
```

Prints `TestService:` followed by a string to the output in blue text.

Parameters:

- `text`: The message to print to the output.
- `source`: The script instance that sent the message, used for output attribution. Defaults to `nil`.
- `line`: The line number in the source script where the message was sent. Defaults to `0`.

### RegisterSuite

```luau
TestService:RegisterSuite(suiteName: string, options: { [string]: any }? = nil): TestSuite
```

### RegisterTest

```luau
TestService:RegisterTest(testName: string, options: { [string]: any }? = nil, callback: ((...any) -> ...any)? = nil): TestCase
```

### RequestValidationAsync

```luau
TestService:RequestValidationAsync(module: string, artifactName: string, options: any): ...any
```

- Tags: Yields, Capabilities: InternalTest

### Require

```luau
TestService:Require(condition: boolean, description: string, source: Instance? = nil, line: number? = 0)
```

Prints whether a condition is true along with a description string.

Parameters:

- `condition`: The boolean expression to evaluate as a required assertion.
- `description`: A label that identifies this requirement in the test output.
- `source`: The script instance that invoked the requirement, used for output attribution. Defaults to `nil`.
- `line`: The line number in the source script where the requirement was called. Defaults to `0`.

### ResetTestControl

```luau
TestService:ResetTestControl(providerName: string, controlName: string)
```

- Tags: Capabilities: InternalTest

### ResetTestRegistry

```luau
TestService:ResetTestRegistry()
```

### RunAsync

```luau
TestService:RunAsync()
```

- Tags: Yields, Plugin security

Runs scripts which are parented to [`TestService`](https://rapi.sleaze.dev/classes/TestService.md).

### RunTestsAsync

```luau
TestService:RunTestsAsync(filter: { [string]: any }? = nil): TestRunResult
```

- Tags: Yields

### ScopeTime

```luau
TestService:ScopeTime(): { [string]: any }
```

Returns a dictionary of per-scope physics simulation timings for performance testing.

Returns: A dictionary mapping physics simulation scopes to their measured step times.

### SetTestControl

```luau
TestService:SetTestControl(providerName: string, controlName: string, value: any)
```

- Tags: Capabilities: InternalTest

### SignalProfilingCapture

```luau
TestService:SignalProfilingCapture(target: string? = "", options: { [string]: any }? = nil)
```

- Tags: Capabilities: InternalTest

### SignalProfilingStart

```luau
TestService:SignalProfilingStart(target: string? = "", options: { [string]: any }? = nil)
```

- Tags: Capabilities: InternalTest

### SignalProfilingStop

```luau
TestService:SignalProfilingStop(target: string? = "")
```

- Tags: Capabilities: InternalTest

### StartAudioCaptureAsync

```luau
TestService:StartAudioCaptureAsync(artifactName: string? = "", options: { [string]: any }? = nil): ...any
```

- Tags: Yields, Capabilities: InternalTest

### StartTestSession

```luau
TestService:StartTestSession()
```

- Tags: Capabilities: InternalTest

### StartVideoCaptureAsync

```luau
TestService:StartVideoCaptureAsync(artifactName: string? = "", options: { [string]: any }? = nil): ...any
```

- Tags: Yields, Capabilities: InternalTest

### StopAudioCaptureAsync

```luau
TestService:StopAudioCaptureAsync(): ...any
```

- Tags: Yields, Capabilities: InternalTest

### StopTestSession

```luau
TestService:StopTestSession()
```

- Tags: Capabilities: InternalTest

### StopVideoCaptureAsync

```luau
TestService:StopVideoCaptureAsync(): ...any
```

- Tags: Yields, Capabilities: InternalTest

### TakeSnapshot

```luau
TestService:TakeSnapshot(snapshotname: string, source: Instance? = nil)
```

- Tags: Capabilities: InternalTest

### TranscodePropertySet

```luau
TestService:TranscodePropertySet(extraAssetsFileName: string, psetFileName: string): string
```

- Tags: Roblox script security

### Warn

```luau
TestService:Warn(condition: boolean, description: string, source: Instance? = nil, line: number? = 0)
```

Prints if a condition is `true`, otherwise prints a warning.

Parameters:

- `condition`: The boolean expression to evaluate as the warning assertion.
- `description`: A label that identifies this warning check in the test output.
- `source`: The script instance that invoked the warning, used for output attribution. Defaults to `nil`.
- `line`: The line number in the source script where the warning was called. Defaults to `0`.

### getTestSessionProviderStats

```luau
TestService:getTestSessionProviderStats(providerName: string): { [string]: any }
```

- Tags: Capabilities: InternalTest

### isFeatureEnabled

```luau
TestService:isFeatureEnabled(name: string): boolean
```

Returns whether the named feature identified by `name` is currently enabled.

Parameters:

- `name`: The name of the feature to query.

Returns: `true` if the named feature resolves to `true`, `false` otherwise.

### RegisterTestLegacy

```luau
TestService:RegisterTestLegacy(testOptions: { [string]: any }): TestCase
```

- Tags: Deprecated, Capabilities: InternalTest
- Use instead: [`TestService.RegisterTest`](https://rapi.sleaze.dev/classes/TestService.md)

### Run

```luau
TestService:Run()
```

- Tags: Deprecated, Yields, Plugin security
- Use instead: [`TestService.RunAsync`](https://rapi.sleaze.dev/classes/TestService.md)

**Deprecated:** Use [`RunAsync()`](https://rapi.sleaze.dev/classes/TestService.md) instead.

Runs scripts which are parented to [`TestService`](https://rapi.sleaze.dev/classes/TestService.md).

## Events

### ServerCollectConditionalResult

```luau
TestService.ServerCollectConditionalResult: RBXScriptSignal<(condition: boolean, text: string, script: Instance, line: number)>
```

Fires when the server should collect a conditional test result.

### ServerCollectResult

```luau
TestService.ServerCollectResult: RBXScriptSignal<(text: string, script: Instance, line: number)>
```

Fires when the server should collect a test result.

### TestRegistryChanged

```luau
TestService.TestRegistryChanged: RBXScriptSignal<()>
```

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
