# @wix/wix-ui-test-utils

> > A common test utils used within the different `wix-ui` packages

Latest version **1.3.5** (published 2026-06-15) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @wix/wix-ui-test-utils
pnpm add @wix/wix-ui-test-utils
yarn add @wix/wix-ui-test-utils
bun add @wix/wix-ui-test-utils
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.3.5 |
| Published | 2026-06-15 |
| First published | 2017-11-27 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 267.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | wix-ci, shahata, wix-ambassador, wix-ci-publisher, wix-bi-publisher, yurynix, arielh, falconci, nadavlac, roir-wix, dorchaouat |

## Links

- npm: https://www.npmjs.com/package/@wix/wix-ui-test-utils
- Homepage: https://github.com/wix-private/wix-design-systems-utils/tree/master/packages/wix-ui-test-utils#wix-ui-test-utils
- npm.io page: https://npm.io/package/@wix/wix-ui-test-utils

## Dependencies (8)

- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.29.7
- [@wix/unidriver-core](https://npm.io/package/@wix/unidriver-core.md) ^1.4.8
- [@stylable/uni-driver](https://npm.io/package/@stylable/uni-driver.md) ^2.5.3
- [@wix/unidriver-puppeteer](https://npm.io/package/@wix/unidriver-puppeteer.md) ^1.4.8
- [@wix/unidriver-playwright](https://npm.io/package/@wix/unidriver-playwright.md) ^1.4.8
- [@wix/unidriver-jsdom-react](https://npm.io/package/@wix/unidriver-jsdom-react.md) ^1.4.8
- [@wix/unidriver-jsdom-react-legacy](https://npm.io/package/@wix/unidriver-jsdom-react-legacy.md) ^1.4.8

## Recent versions

- 1.3.5 (latest) — 2026-06-15
- 1.3.4 — 2025-10-29
- 1.3.3 — 2025-08-29
- 1.3.2 — 2025-08-06
- 1.3.1 — 2025-05-22
- 1.3.0 — 2025-05-15
- 1.2.3 — 2025-05-12
- 1.2.2 — 2025-05-08
- 1.2.1 — 2025-05-07
- 1.2.0 — 2025-04-17
- 1.1.16 — 2024-12-11
- 1.1.15 — 2024-12-11
- 1.1.14 — 2024-09-20
- 1.1.13 — 2024-05-31
- 1.1.12 — 2024-05-29
- … 18 more at https://npm.io/package/@wix/wix-ui-test-utils/versions

## README

# wix-ui-test-utils

> A common test utils used within the different `wix-ui` packages

## Generic test utils

The following helper functions can be used within the different `wix-ui` packages:

### `isClassExists`

Returns `true` if a certain class exists on an element.

```javascript
import {isClassExists} from '@wix/wix-ui-test-utils/react-helpers';

const element = document.createElement('div');
element.classList.add('big');

isClassExists(element, 'big'); // true
isClassExists(element, 'small'); // false
```

### `sleep`

Returns a promise that resolves after a given timeout.

```javascript
import {sleep} from '@wix/wix-ui-test-utils/react-helpers';

sleep(5000)
  .then(() => console.log('Hello world'));

async function foo() {
  await sleep(5000);
  console.log('Hello world');
}
```

### `makeControlled`

A HOC that makes underlying component "controlled". The "controlled" element will be
initiated with an initial value, invoke an `onChange` callback and will bind the passed
prop functions.

```javascript
import {mount} from 'enzyme';
import {makeControlled} from '@wix/wix-ui-test-utils/react-helpers';

const UncontrolledInput = props => (
  <input {...props}/>
);

const ControlledInput = makeControlled(UncontrolledInput);
const component = mount(
  <ControlledInput
    value={initialValue}
  />
);

// ...
```

## Testkit helpers

### `createDriverFactory`

Accepts a component driver. Returns a new driver factory. An explanation of drivers can be viewd
[here](./docs/COMPONENT_DRIVERS.md).

```javascript
import React from 'react';
import {createDriverFactory} from '@wix/wix-ui-test-utils/driver-factory';
import {buttonDriverFactory} from './Button.driver';
import Button from './';

const createDriver = createDriverFactory(buttonDriverFactory);

describe('Button', () => {
  it('should exist', () => {
    const driver = createDriver(<Button />);
    expect(driver.exists()).toBe(true);
  });
});
```

### Vanilla (react-test-utils)

#### `testkitFactoryCreator`

Accepts a component driver. Returns a testkit factory.

```javascript
import {testkitFactoryCreator} from '@wix/wix-ui-test-utils/vanilla';
import datePickerDriverFactory './driver';

const driverFactory = testkitFactoryCreator(datePickerDriverFactory);
const driver = driverFactory({
  // ...
});

driver.click();
driver.exists();
// ...
```

#### `isTestkitExists`

This function should be used inside the component tests in order to to perform a sanity check for the exposed testkit.
It accepts a React Element and a testkit factory. Returns `true` if the driver
works as expected.

```javascript
import {testkitFactoryCreator, isTestkitExists} from '@wix/wix-ui-test-utils/vanilla';
import datePickerDriverFactory './driver';

const driverFactory = testkitFactoryCreator(datePickerDriverFactory);

isTestkitExists(
  <DatePicker />,
  driverFactory
); // true
```

### Enzyme

#### `enzymeTestkitFactoryCreator`

Accepts a component driver. Returns a testkit factory based on enzyme.

```javascript
import {enzymeTestkitFactoryCreator} from '@wix/wix-ui-test-utils/enzyme';
import datePickerDriverFactory './driver';

const driverFactory = enzymeTestkitFactoryCreator(datePickerDriverFactory);
const driver = driverFactory({
  // ...
});

driver.click();
driver.exists();
// ...
```

#### `isEnzymeTestkitExists`

This function should be used inside the component tests in order to to perform a sanity check for the exposed testkit.
It accepts a React Element and a testkit factory. Returns `true` if the driver
works as expected.

```javascript
import {enzymeTestkitFactoryCreator, isEnzymeTestkitExists} from '@wix/wix-ui-test-utils/enzyme';
import datePickerDriverFactory './driver';
import {mount} from 'enzyme';

const driverFactory = enzymeTestkitFactoryCreator(datePickerDriverFactory);

isEnzymeTestkitExists(
  <DatePicker />,
  driverFactory,
  mount
); // true
```

---
_Source: https://npm.io/package/@wix/wix-ui-test-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
