poenneby / eslint-plugin-codeceptjs Goto Github PK
View Code? Open in Web Editor NEWEslint rules for CodeceptJS
Eslint rules for CodeceptJS
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:
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,
})
})
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"
}
Can you help resolve the error?
Why would you want to prevent the usage of these methods within a Scenario()? What does it mean to prefer to "delegate to page objects"?
Using your plugin I'm having a problem with lint complaining when I try to use the tryTo plugin for CodeceptJS, even though the function use works in the tests. Are Codecept plugins missing from this eslint plugin?
I did add the plugin to the .eslintrc file as instructed (tried both the "extends" and the "plugins" way but neither makes a difference) and based on all the other Codeceptjs warnings disappearing from the tests I assume it is working.
I'm happy to provide additional information if needed.
This plugin is extremely simple as it currently only defines the globals in CodeceptJS.
Here are some ideas of rules:
I
within Scenario
Scenario
s without Feature
function callyield
within a Scenario
while missing generator function *
declarationFeel free to suggest others!
Functions BeforeSuite
and AfterSuite
are missing from env globals.
These globals are used for data driven tests in codeceptjs: https://codecept.io/advanced/
How can i handle eslint checking for my custom actor method.
My project has plugin with REST and it added another actor method as file below
https://gist.github.com/Tanapat-S/2c7eceb0385efaf3099465a175e05a1d
So a rules "codeceptjs/no-actor-in-scenario": 2" do not work properly on this cases
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.