Skip to content
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

The onActionDone method should take TestRunErrorFormattableAdapter instance instead of Error (closes #4867) #4847

Closed
wants to merge 2 commits into from

Conversation

AlexKamaev
Copy link
Contributor

@AlexKamaev AlexKamaev commented Mar 6, 2020

The array of adapters is created when the executeTestFn function catches the error. When it happens we make the screenshot (if screenshot-on-fails is enabled), create adapters and store them into the testRun.errs property. After that we pass testRun.errs to the reportTestDone method.

Now we also need to pass the TestRunErrorFormattableAdapter to the onActionDone. So we need to create adapters on the executeAction method. In addition, we need to make screenshot on the executeAction method. So we need to catch the error on executeAction, create adapter and screenshot and rethrow the error to stop test execution. However, if we rethrow the error we will catch it again on executeTestFn.
We know that some errors does not occur on the executeAction step, but occurs on executeTestFn, i.e. error in custom user's code. Thus we somehow need to detect if the error already was processed, and if it was not, we need to process it. I think it's a very bad idea to create adapters and screenshots in two places.
Moreover, we have one more layer of catching the errors - wrapTestFunction. Inside the wrapTestFuncion we catch execution errors and missing awaits, then create the TestCafeErrorList object and rethrow it.
Thus, inside the catch block of executeTestFn we catch the TestCafeErrorList object.

I think that it's better to leave creating adapters and making screenshots on fails as is, in one place: in the executeTestFn catch block. So in this block I emit new execution-error event which can be handled inside the executeAction method.

@testcafe-build-bot
Copy link
Collaborator

@testcafe-build-bot
Copy link
Collaborator

@AlexKamaev AlexKamaev changed the title [WIP][test]try to move testRun error handing to onActionDone [WIP]try to move testRun error handing to onActionDone Mar 13, 2020
@testcafe-build-bot
Copy link
Collaborator

@AlexKamaev AlexKamaev changed the title [WIP]try to move testRun error handing to onActionDone The onActionDone method should take TestRunErrorFormattableAdapter instance instead of Error (closes #4867) Mar 16, 2020
@testcafe-build-bot
Copy link
Collaborator

@testcafe-build-bot
Copy link
Collaborator

@testcafe-build-bot
Copy link
Collaborator

Copy link
Collaborator

@miherlosev miherlosev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's possible, I propose to reorganize this code using the following idea:

  • error adapters for action errors should be created into the 'executeAction' function
  • error adapters for testRun errors (MissingAwaitError, UncaughtError) should be created into the '_executeTestFn'

@testcafe-build-bot
Copy link
Collaborator

@AlexKamaev
Copy link
Contributor Author

I closed this version in favor of #4895

@AlexKamaev AlexKamaev closed this Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants