eslint-plugin-test-id
This checks is data-test-id prop is present, on some tags which are useful for e2e testing
10,384
17
| Install | |
|---|---|
npm install eslint-plugin-test-id |
|
| Latest Version: | 2.4.0 |
| License: | ISC |
| Last Updated: | Aug 3, 2026 |
| Links: | GitHub · npm |
Maintainer: prashantswami
eslint-plugin-test-id
This checks is data-test-id prop is present, on some tags which are useful for e2e testing
Installation
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-test-id:
$ npm install eslint-plugin-test-id --save-dev
Usage
Add test-id to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": [
"test-id"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"test-id/data-test-id": 'error'
}
}
You can also enable all the recommended rules at once:
{
"extends": [
"plugin:test-id/recommended"
]
}
Rule Details
This rule aims to...
Examples of incorrect code for this rule:
<input v-model="someModel">
Examples of correct code for this rule:
<input data-test-id="someUniqueString" v-model="someModel">
How Fix will work
Scenario 1
<template><custom v-model="test" /></template>
will fix to
<template><input data-test-id="test" v-model="test"></template>
Scenario 2
<template><input v-model="test.again.src"></template>
will fix to
<template><custom data-test-id="test.again.src" v-model="test.again.src" /></template>
Scenario 3
<template><custom v-model="test.again" /></template>
will fix to
<template><custom data-test-id="test.again" v-model="test.again" /></template>
Scenario 4
<template><custom v-model="test['again']" /></template>
will fix to
<template><custom data-test-id="test.again" v-model="test['again']" /></template>
Scenario 5
<template><custom v-model="test[5]" /></template>
will fix to
<template><custom data-test-id="test.5" v-model="test[5]" /></template>
Scenario 5
<template><custom v-model="test[5]['val']" /></template>
will fix to
<template><custom data-test-id="test.5.val" v-model="test[5]['val']" /></template>
Related Packages
Version History
| Version | Released | License |
|---|---|---|
| 2.4.0 | ISC | |
| 2.3.0 | ISC | |
| 2.2.0 | ISC | |
| 2.1.0 | ISC | |
| 2.0.0 | ISC | |
| 1.7.0 | ISC | |
| 1.5.7 | ISC | |
| 1.5.5 | ISC | |
| 1.5.4 | ISC | |
| 1.5.3 | ISC | |
| 1.5.2 | ISC | |
| 1.5.0 | ISC | |
| 1.4.0 | ISC | |
| 1.1.0 | ISC | |
| 1.0.2 | ISC | |
| 1.0.1 | ISC | |
| 1.0.0 | ISC | |
| 0.0.2 | ISC | |
| 0.0.1 | ISC |