Eslint Plugin Test Id screenshot

Eslint Plugin Test Id

Author Avatar Theme by Prashantswami
Updated: 13 Feb 2025
15 Stars

This is rule of eslint plugin for vue templates which checks element with model has `data-test-id`

Overview

The npm package eslint-plugin-test-id is used to check if the data-test-id prop is present on certain tags, which is useful for end-to-end testing. It helps enforce consistency in adding test identifiers to elements in the codebase.

Features

  • Data-test-id Prop Check: Ensures the data-test-id prop is included on specified tags.
  • ESLint Integration: Works seamlessly with ESLint for code quality checks.
  • Customizable Rules: Configure rules in the .eslintrc file to suit specific project needs.

Installation

To install the eslint-plugin-test-id, first, ensure ESLint is installed. Then run the following commands:

npm install eslint --save-dev
npm install eslint-plugin-test-id --save-dev

Add test-id to the plugins section in your .eslintrc file and configure rules under the rules section. To enable all recommended rules at once, simply include them in the configuration.

Summary

The eslint-plugin-test-id npm package provides a straightforward way to enforce the presence of data-test-id props on certain tags, aiding in the creation of more testable code for end-to-end testing. By integrating with ESLint, it becomes a seamless part of the development workflow, ensuring code quality and consistency.