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()`.

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.
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
npm install eslint-plugin-testcafe
yarn add eslint-plugin-testcafe
pnpm add eslint-plugin-testcafe

Configures ESLint with the testcafe plugin and recommended rules, then shows a TestCafe test using common patterns.

// .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');
});