ESLINT插件CodeCptjs无法读取未定义的属性(Reading'属性')

发布于 2025-01-28 20:09:26 字数 3229 浏览 3 评论 0原文

在运行ESLINT命令时,我会遇到以下错误,

PS C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project> eslint "**/*.ts" --ignore-pattern node_modules/

Oops! Something went wrong! :(

ESLint: 8.15.0

TypeError: Cannot read properties of undefined (reading 'property')
Occurred while linting C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\src\tests\rest\Get.test.ts:3
Rule: "codeceptjs/no-actor-in-scenario"
    at C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint-plugin-codeceptjs\lib\rules\no-actor-in-scenario.js:30:63
    at Array.map (<anonymous>)
    at C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint-plugin-codeceptjs\lib\rules\no-actor-in-scenario.js:29:32
    at Array.map (<anonymous>)
    at C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint-plugin-codeceptjs\lib\rules\no-actor-in-scenario.js:27:34
    at Array.map (<anonymous>)
    at CallExpression (C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint-plugin-codeceptjs\lib\rules\no-actor-in-scenario.js:21:26)
    at ruleErrorHandler (C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint\lib\linter\linter.js:1114:28)
    at C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)

这是get.test.ts文件,该文件引起了错误:

Feature('GET tests').tag('@REST')

Scenario('Verify a successful call', async ({ I }) => {
  await I.sendGetRequest('/api/users?page=2')
  I.seeResponseCodeIsSuccessful()
})

Scenario('Verify a not found call', async ({ I }) => {
  await I.sendGetRequest('/api/users/266')
  I.seeResponseCodeIsClientError()
})

Scenario('Verify getting a single user', async ({ I }) => {
  const { data } = await I.sendGetRequest('/api/users/2')

  I.seeResponseContainsKeys(data)
  I.seeResponseValidByCallback(({ data, expect }) => {
    expect(data.id)
  })
})

Scenario('Verify getting list of users', async ({ I }) => {
  const { data } = await I.sendGetRequest('/api/users?page=2')

  I.seeResponseContainsKeys(data)
  I.seeResponseContainsJson({
    page: 2,
    total: 12,
    per_page: 6,
  })
})

这些是用于衬里的配置文件: 这是.eslintrc文件:

{
  "plugins": [
    "codeceptjs"
  ],
  "parserOptions": {
    "sourceType": "module"
  },
  "env": {
    "codeceptjs/codeceptjs": true,
    "es2020": true
  },

  "rules": {
    "codeceptjs/no-actor-in-scenario": "warn",
    "codeceptjs/no-skipped-tests": "error"
  }
}

这是我的软件包

"dependencies": {
    "@codeceptjs/configure": "^0.8.0",
    "@codeceptjs/ui": "0.4.6",
    "codeceptjs": "3.3.2",
    "codeceptjs-expectwrapper": "^1.0.2",
    "codeceptjs-resemblehelper": "^1.9.6",
    "expect": "^26.6.2",
    "faker": "^4.1.0",
    "form-data": "^3.0.0",
    "fs-extra": "^10.1.0",
    "playwright": "^1.21.0",
    "prettier": "2.6.2",
    "ts-node": "^10.7.0",
    "typescript": "^4.6.3"
  },
  "devDependencies": {
    "eslint": "^8.15.0",
    "eslint-plugin-codeceptjs": "^1.3.0"
  }

。 似乎可能像一些插件问题。不太确定。
您可以帮助解决错误吗?

I get the following error while running the eslint command

PS C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project> eslint "**/*.ts" --ignore-pattern node_modules/

Oops! Something went wrong! :(

ESLint: 8.15.0

TypeError: Cannot read properties of undefined (reading 'property')
Occurred while linting C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\src\tests\rest\Get.test.ts:3
Rule: "codeceptjs/no-actor-in-scenario"
    at C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint-plugin-codeceptjs\lib\rules\no-actor-in-scenario.js:30:63
    at Array.map (<anonymous>)
    at C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint-plugin-codeceptjs\lib\rules\no-actor-in-scenario.js:29:32
    at Array.map (<anonymous>)
    at C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint-plugin-codeceptjs\lib\rules\no-actor-in-scenario.js:27:34
    at Array.map (<anonymous>)
    at CallExpression (C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint-plugin-codeceptjs\lib\rules\no-actor-in-scenario.js:21:26)
    at ruleErrorHandler (C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint\lib\linter\linter.js:1114:28)
    at C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)

This is Get.test.ts file that is causing the error:

Feature('GET tests').tag('@REST')

Scenario('Verify a successful call', async ({ I }) => {
  await I.sendGetRequest('/api/users?page=2')
  I.seeResponseCodeIsSuccessful()
})

Scenario('Verify a not found call', async ({ I }) => {
  await I.sendGetRequest('/api/users/266')
  I.seeResponseCodeIsClientError()
})

Scenario('Verify getting a single user', async ({ I }) => {
  const { data } = await I.sendGetRequest('/api/users/2')

  I.seeResponseContainsKeys(data)
  I.seeResponseValidByCallback(({ data, expect }) => {
    expect(data.id)
  })
})

Scenario('Verify getting list of users', async ({ I }) => {
  const { data } = await I.sendGetRequest('/api/users?page=2')

  I.seeResponseContainsKeys(data)
  I.seeResponseContainsJson({
    page: 2,
    total: 12,
    per_page: 6,
  })
})

These are the configuration files for lining:
This is the .eslintrc file:

{
  "plugins": [
    "codeceptjs"
  ],
  "parserOptions": {
    "sourceType": "module"
  },
  "env": {
    "codeceptjs/codeceptjs": true,
    "es2020": true
  },

  "rules": {
    "codeceptjs/no-actor-in-scenario": "warn",
    "codeceptjs/no-skipped-tests": "error"
  }
}

This is my package.json:

"dependencies": {
    "@codeceptjs/configure": "^0.8.0",
    "@codeceptjs/ui": "0.4.6",
    "codeceptjs": "3.3.2",
    "codeceptjs-expectwrapper": "^1.0.2",
    "codeceptjs-resemblehelper": "^1.9.6",
    "expect": "^26.6.2",
    "faker": "^4.1.0",
    "form-data": "^3.0.0",
    "fs-extra": "^10.1.0",
    "playwright": "^1.21.0",
    "prettier": "2.6.2",
    "ts-node": "^10.7.0",
    "typescript": "^4.6.3"
  },
  "devDependencies": {
    "eslint": "^8.15.0",
    "eslint-plugin-codeceptjs": "^1.3.0"
  }

I couldn't find anything on this one.
It seems maybe like some plugin issue. Not really sure.
Can you help resolve the error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文