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

Mocha's retries implementation has unexpected consenquences #3274

Open
rockwalrus opened this issue Mar 16, 2022 · 1 comment
Open

Mocha's retries implementation has unexpected consenquences #3274

rockwalrus opened this issue Mar 16, 2022 · 1 comment
Labels

Comments

@rockwalrus
Copy link

When using mocha's retries functionality, such as with Scenario().retries(2), on failure, mocha does a shallow clone of the test, copying just (some of) the properties it knows about, and then eventually replaces the original test object in the suite with the clone. This leads to surprises such as:

  • Documented CodeceptJS-specific test properties such as opts not being present on the test object in hooks on retries
  • Mochawesome contexts added using MochawesomeHelper not appearing in the output, because they are added to the context for the original object, not the context for the cloned object.

This appears to be the cause of some of the issues reported in #1299, #1809, and #3028.

A cloned retry can be distinguished from an original by a truthy return from test.retriedTest(). In that case, the return value is the original test object. It might be possible for CodeceptJS to add a hook early in the lifecycle of a retried test that clones the CodeceptJS-specific properties. Otherwise, this quirk of mocha should be documented in the section on retries and in the hooks documentation so that users aren't surprised.

Likewise, MochawesomeHelper should be adapted to add context to the correct test, and maybe even (optionally?) copy the context over from previous runs.

Copy link

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale label Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant