ESLINT插件CodeCptjs无法读取未定义的属性(Reading'属性')
在运行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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论