-
-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: handle logging step #4751
fix: handle logging step #4751
Conversation
package.json
Outdated
@@ -33,7 +33,8 @@ | |||
".": "./lib/index.js", | |||
"./els": "./lib/els.js", | |||
"./effects": "./lib/effects.js", | |||
"./steps": "./lib/steps.js" | |||
"./steps": "./lib/steps.js", | |||
"./step": "./lib/step.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about adding step export to index.js
?
const { step } = require('codeceptjs')
this is how we access all internal API
codeceptjs/steps
is userland API which is used inside tests, not custom helpers, or plugins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds better @DavertMik
lib/output.js
Outdated
if (step.comment) { | ||
stepLine += colors.grey(step.comment.split('\n').join('\n' + ' '.repeat(4))) | ||
} | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better would be:
if (step instanceof Step) {
// ...
} elseif (typeof step == 'string') {
} else {
// incorrect step
}
try catch is not the best approach here if we know where error can happen and how to avoid it
Something happened with tests in this 😢 |
Hey @kobenguyent , I have a better idea for this case How about create a Step that can execute arbitrary function See my implementation in #4781 here is what you can do: const FuncStep = require('codeceptjs/lib/steps/func')
const step = new Step(`expect "${JSON.stringify(actualValue)}" to not equal "${JSON.stringify(expectedValue)}"`);
step.setCallable(...) // actual assertion happens here?
output.step(step) you can actually add this step to promise chain const recordStep = require('codeceptjs/lib/steps/record')
const FuncStep = require('codeceptjs/lib/steps/func')
const step = new Step(`expect "${JSON.stringify(actualValue)}" to not equal "${JSON.stringify(expectedValue)}"`);
step.setCallable(...) // actual assertion happens here?
recordStep(step) In this case, all steps should are actual Steps so no need to pass strings |
Hi @DavertMik thanks for sharing this. So still do we need this PR just to handle the custom helpers for instance that are not yet adapted with new implementation? |
@kobenguyent if you think it is needed for backwards compatibility with Expect helper I'm ok |
Oh, if this shall be dropped in 4.0 then I'd say let's exclude this. |
Motivation/Description of the PR
Type of change
Checklist:
npm run docs
)npm run lint
)npm test
)