You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何使用eslint-plugin-jest时,跳过的测试未触发jest/no-disabled-tests报错?

解决Playwright跳过测试无法被ESLint检测的问题

你遇到的问题核心是:eslint-plugin-jest 是专门为Jest测试框架设计的规则集,它的jest/no-disabled-tests规则只能识别Jest生态下的禁用测试语法,无法识别Playwright的test.skip。

要解决这个问题,你需要改用Playwright官方的ESLint插件:

步骤1:安装Playwright ESLint插件

执行以下命令安装依赖:

npm install eslint-plugin-playwright --save-dev
# 或用yarn
yarn add eslint-plugin-playwright --dev
# 或用pnpm
pnpm add eslint-plugin-playwright --save-dev

步骤2:配置ESLint规则

在你的ESLint配置文件(比如.eslintrc.js、.eslintrc.json)中,添加Playwright插件的规则:

方式1:启用全部推荐规则

module.exports = {
  extends: [
    // 保留你已有的其他extends配置
    'plugin:playwright/recommended'
  ],
  plugins: ['playwright']
};

方式2:单独启用禁用测试检测规则

如果你不想启用所有推荐规则,可单独开启playwright/no-skipped-tests:

module.exports = {
  plugins: ['playwright'],
  rules: {
    // 其他规则...
    'playwright/no-skipped-tests': 'error' // 设为"warn"或"error"均可
  }
};

步骤3:验证效果

重新运行ESLint检查:

eslint .

此时被test.skip标记的跳过测试应该会被检测并报告为违规项。

内容的提问来源于stack exchange,提问作者Michael Durrant

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 03:27:03