{/* prettier-ignore */}
{/*
Copyright 2023 Comcast Cable Communications Management, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

SPDX-License-Identifier: Apache-2.0
\*/}

import { Meta } from '@storybook/blocks';

<Meta title="Docs / Unit Testing / Overview" />

# @lightningjs/ui-components-test-utils

The `@lightningjs/ui-components-test-utils` package provides 2 artifacts to assist with unit testing Lightning components.

1. **Test Renderer**

- [create](/story/docs-unit-testing-test-renderer-create--page): Generates a `testRenderer` object with built in utilities for unit testing Lightning Components.
- [toJSON](/story/docs-unit-testing-test-renderer-tojson--page): Converts Lightning components to JSON to be used in [Jest Snapshot Tests](https://jestjs.io/docs/snapshot-testing)

2. **Test Utils**

- [makeCreateComponent](/story/docs-unit-testing-test-utils-makecreatecomponent--page): Returns a `createComponent` function which is used to generate an instance of a component to run unit test cases against.
- [completeAnimation](/story/docs-unit-testing-test-utils-completeanimation--page): Returns a Promise that resolves once all animating properties have updated to their target value(s).
- [fastForward](/story/docs-unit-testing-test-utils-fastforward--page): Force all running Lightning Transitions on one or more Lightning Elements to finish and update the transitioning property to its target value immediately.
- [nextTick](/story/docs-unit-testing-test-utils-nexttick--page): Creates a Promise that resolves after a defined amount of time. If no amount of time is specified, the Promise will resolve immediately.

```js
// jest.config.js

const config = {
  // ...other Jest config properties
  setupFiles: ['jest-webgl-canvas-mock'],
  transformIgnorePatterns: [
    '/node_modules/(?!(@lightningjs/ui-components-test-utils)/)'
  ]
  // ...other Jest config properties
};

export default config;
```
