eslint-plugin-testcafe
raw JSON → 0.2.1 verified Sat Apr 25 auth: no javascript
ESLint plugin providing rules for TestCafe end-to-end testing framework. Current version 0.2.1 (pre-1.0) allows referencing `t` variable from TestCafe test context. Installation requires ESLint (peer dependency). Plugin exports a recommended configuration that enforces good practices. Differentiator: avoids false positives from TestCafe globals and supports TestCafe-specific patterns like `t.expect()`.
Common errors
error ESLint: Failed to load plugin 'testcafe': Cannot find module 'eslint-plugin-testcafe' ↓
cause eslint-plugin-testcafe is not installed or is installed globally while ESLint is local (or vice versa).
fix
Install locally: npm install eslint-plugin-testcafe --save-dev. Ensure ESLint and the plugin are installed in the same scope (both global or both local).
error ESLint: Error while loading rule 'testcafe/no-valid-testcafe-pattern': Could not find rule ↓
cause The rule name might be incorrect or the plugin is not specified in plugins array.
fix
Ensure 'testcafe' is in the plugins array and the rule is prefixed with 'testcafe/'.
error Definition for rule 'no-valid-testcafe-pattern' was not found ↓
cause Missing namespace prefix 'testcafe/' on the rule.
fix
Use 'testcafe/no-valid-testcafe-pattern' in rules configuration.
Warnings
deprecated Plugin version 0.2.1 is outdated and may not support newer TestCafe features (e.g., Role, RequestMock). Consider using more actively maintained alternatives. ↓
fix Switch to a more maintained ESLint plugin for TestCafe, or contribute to this one.
gotcha The 'no-valid-testcafe-pattern' rule might incorrectly flag valid TestCafe code if the rule is not updated for newer TestCafe APIs. ↓
fix Review rule configs and consider disabling the rule if it causes false positives.
gotcha Install both eslint and eslint-plugin-testcafe as devDependencies, not globally, unless you prefer global install. Global installs can cause conflicts. ↓
fix Run: npm install eslint eslint-plugin-testcafe --save-dev
Install
npm install eslint-plugin-testcafe yarn add eslint-plugin-testcafe pnpm add eslint-plugin-testcafe Imports
- plugin:testcafe/recommended wrong
extends: 'testcafe/recommended' (missing 'plugin:' prefix)correctextends: 'plugin:testcafe/recommended' - no-valid-testcafe-pattern wrong
rules: { 'no-valid-testcafe-pattern': 'error' } (missing namespace)correctrules: { 'testcafe/no-valid-testcafe-pattern': 'error' } - plugin import wrong
using the plugin name with scope (e.g., '@testcafe/eslint-plugin') which is not the package namecorrectplugins: ['testcafe']
Quickstart
// .eslintrc.js
module.exports = {
plugins: ['testcafe'],
extends: 'plugin:testcafe/recommended',
rules: {
'testcafe/no-valid-testcafe-pattern': 'error',
},
};
// Example TestCafe test that will pass ESLint with the plugin
fixture('Example fixture')
.page('https://example.com');
test('Example test', async t => {
await t
.click('#button')
.typeText('#input', 'hello')
.expect('#result').eql('hello');
});