Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kiosion/vite-plugin-test-selectors

Simple vite plugin for stripping test selectors in production builds
https://github.com/kiosion/vite-plugin-test-selectors

react svelte test-selectors testing vite vite-plugin vue

Last synced: about 2 months ago
JSON representation

Simple vite plugin for stripping test selectors in production builds

Awesome Lists containing this project

README

        


vite-plugin-test-selectors


Simple vite plugin for stripping test selectors in production builds

Demo

## Supported frameworks

- React
- Vue
- Svelte

## Installation

> **Warning:** This plugin is still in development!

Install using yarn or npm:
```bash
yarn add vite-plugin-test-selectors -D
```

## Usage

Add to your vite config:
```js
import { defineConfig } from 'vite';
import StripTestSelectors from 'vite-plugin-test-selectors';

export default defineConfig({
plugins: [
StripTestSelectors()
]
});
```

Then, customize any of the following options:

```js
StripTestSelectors({
dev: false,
selectors: ['data-test'],
suffixes: ['.jsx', '.tsx', '.vue', '.svelte'],
})
```

'Dev' is a boolean that determines whether to apply the plugin on serve or build. It defaults to 'false', only stripping test attributes in production builds.

The provided selectors are optional (defaulting to only 'data-test'), and are parsed as `selector-*`, where `*` is any string optionally followed by a value assignment. For example:

```html

```

Suffixes are also optional, and are an array of any valid file extensions. They default to '.jsx', '.tsx', '.vue', and '.svelte'.

For example usage, check out the [included demos](demos/).

## Testing

```bash
yarn test
```

## Credits

Authors: [kiosion](https://github.com/kiosion/vite-plugin-test-selectors)