eslint-plugin-codeceptjs
raw JSON → 1.3.0 verified Sat Apr 25 auth: no javascript maintenance
An ESLint plugin providing lint rules for CodeceptJS test files. Version 1.3.0 is the latest stable release, with a low release cadence (latest in 2020). It includes rules to prevent common testing anti-patterns: no-exclusive-tests (focusing tests), no-disabled-tests (skipping), no-actor-in-scenario (forcing page objects), and no-pause-in-scenario (removing debug pauses). Unlike generic ESLint rules, it understands CodeceptJS globals (I, Scenario, Data) and provides a recommended config for easy setup. It is fixable for three of its four rules, automatically removing `.only`, `.skip`, and `pause()` calls.
Common errors
error Cannot find module 'eslint-plugin-codeceptjs' ↓
cause ESLint cannot locate the plugin because it's not installed or not in node_modules.
fix
Run 'npm install eslint-plugin-codeceptjs --save-dev' (or global flag if ESLint is global).
error ESLint configuration error: Unknown environment 'codeceptjs' ↓
cause Environment was specified as 'codeceptjs' instead of 'codeceptjs/codeceptjs'.
fix
Change env to { 'codeceptjs/codeceptjs': true }.
error ESLint configuration error: Cannot read property 'recommended' of undefined ↓
cause Using 'extends: 'codeceptjs/recommended' without the 'plugin:' prefix.
fix
Use 'extends: ['plugin:codeceptjs/recommended']'.
error Definition for rule 'no-exclusive-tests' was not found ↓
cause Rule name not prefixed with plugin namespace when not using recommended config.
fix
Prefix rule with 'codeceptjs/', e.g., 'codeceptjs/no-exclusive-tests'.
Warnings
gotcha The 'no-disabled-tests' rule was renamed to 'no-skipped-tests' in version 1.0.0. Using the old name will be silently ignored. ↓
fix Replace 'no-disabled-tests' with 'no-skipped-tests' in your ESLint config.
gotcha The environment must be specified as 'codeceptjs/codeceptjs', not just 'codeceptjs'. Omitting the namespace fails to register globals. ↓
fix Set env to { 'codeceptjs/codeceptjs': true } in your ESLint config.
deprecated The 'no-pause-in-scenario' rule is fixable but its auto-fix removes pause() calls entirely, which may break tests if pause is used for debugging during development. ↓
fix Use fix: false on the rule or manually review removals.
gotcha When using the recommended config, all fixable rules default to 'error'. This may be too strict for development; adjust severity as needed. ↓
fix Override rule severity in your config, e.g., 'codeceptjs/no-pause-in-scenario': 'warn'.
breaking Version 1.0.0 removed the old 'no-disabled-tests' rule and replaced it with 'no-skipped-tests'. Configs using the old name stop working silently. ↓
fix Update to 'no-skipped-tests' in your ESLint config.
Install
npm install eslint-plugin-codeceptjs yarn add eslint-plugin-codeceptjs pnpm add eslint-plugin-codeceptjs Imports
- configs.recommended wrong
extends: ['codeceptjs/recommended']correctextends: ['plugin:codeceptjs/recommended'] - rules wrong
rules: { 'no-exclusive-tests': 'error' }correctrules: { 'codeceptjs/no-exclusive-tests': 'error' } - env wrong
env: { 'codeceptjs': true }correctenv: { 'codeceptjs/codeceptjs': true }
Quickstart
// Install dependencies
npm install eslint eslint-plugin-codeceptjs --save-dev
// .eslintrc.json
{
"plugins": ["codeceptjs"],
"env": {
"codeceptjs/codeceptjs": true
},
"rules": {
"codeceptjs/no-exclusive-tests": "error",
"codeceptjs/no-skipped-tests": "error",
"codeceptjs/no-pause-in-scenario": "warn"
}
}
// Example test file that will trigger errors
Feature('Sample');
Scenario.only('focused test', ({ I }) => {
I.amOnPage('/');
pause(); // warns
});
xScenario('skipped test', ({ I }) => {
I.see('Hello');
});
// Run: npx eslint test.js