Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/kiosion/vite-plugin-test-selectors
- Owner: kiosion
- License: mit
- Created: 2022-07-27T21:58:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-19T19:57:46.000Z (over 1 year ago)
- Last Synced: 2024-08-11T09:19:52.399Z (6 months ago)
- Topics: react, svelte, test-selectors, testing, vite, vite-plugin, vue
- Language: TypeScript
- Homepage:
- Size: 324 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
vite-plugin-test-selectors
Simple vite plugin for stripping test selectors in production builds
## 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)