﻿---
title: testing
description: Defined in: var_invariant.ts:14 A var(...) whose custom property is never declared in the same CSS text. Defined in: var_invariant.ts:135 Throws if any...
url: https://docs-v3-preview.elastic.dev/distillate/reference/api/testing
---

# testing
## Interfaces


### VarInvariantViolation

Defined in: [var_invariant.ts:14](https://github.com/elastic/distillate/blob/d1dccb0eb5372d5984331c21603220340752a304/src/var_invariant.ts#L14)
A `var(...)` whose custom property is never declared in the same CSS text.

#### Properties


| Property    | Modifier   | Type     | Description                                                  | Defined in                                                                                                                          |
|-------------|------------|----------|--------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `context`   | `readonly` | `string` | Surrounding CSS text for error reporting.                    | [var_invariant.ts:18](https://github.com/elastic/distillate/blob/d1dccb0eb5372d5984331c21603220340752a304/src/var_invariant.ts#L18) |
| `reference` | `readonly` | `string` | The undeclared custom property name (e.g. `--aui-color-bg`). | [var_invariant.ts:16](https://github.com/elastic/distillate/blob/d1dccb0eb5372d5984331c21603220340752a304/src/var_invariant.ts#L16) |


## Functions


### assertVarRefsHaveDeclarations()

```ts
function assertVarRefsHaveDeclarations(css): void;
```

Defined in: [var_invariant.ts:135](https://github.com/elastic/distillate/blob/d1dccb0eb5372d5984331c21603220340752a304/src/var_invariant.ts#L135)
Throws if any `var(...)` in `css` has no matching custom-property declaration.

#### Parameters


| Parameter | Type     | Description            |
|-----------|----------|------------------------|
| `css`     | `string` | Full CSS text to scan. |


#### Returns

`void`

#### Throws

If any reference has no declaration in the same text.
---


### findVarRefViolations()

```ts
function findVarRefViolations(css): readonly VarInvariantViolation[];
```

Defined in: [var_invariant.ts:109](https://github.com/elastic/distillate/blob/d1dccb0eb5372d5984331c21603220340752a304/src/var_invariant.ts#L109)
Returns all `var(...)` references whose custom property is never declared in `css`.

#### Parameters


| Parameter | Type     | Description            |
|-----------|----------|------------------------|
| `css`     | `string` | Full CSS text to scan. |


#### Returns

readonly [`VarInvariantViolation`](#varinvariantviolation)[]
---


### tokenTreeDts()

```ts
function tokenTreeDts(
   typeName, 
   tree, 
   leafType?
): string;
```

Defined in: [testing.ts:23](https://github.com/elastic/distillate/blob/d1dccb0eb5372d5984331c21603220340752a304/src/testing.ts#L23)
Emits a TypeScript `interface` for a derived token tree, for Monaco extraLib text.

#### Parameters


| Parameter  | Type     | Default value       | Description                                                    |
|------------|----------|---------------------|----------------------------------------------------------------|
| `typeName` | `string` | `undefined`         | Interface identifier.                                          |
| `tree`     | `object` | `undefined`         | Derived CssToken / ScaleToken tree.                            |
| `leafType` | `string` | `'CssInterpolable'` | Identifier used for every leaf. Defaults to `CssInterpolable`. |


#### Returns

`string`