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

addContext to selected context in the suite #392

Open
joo920131 opened this issue Mar 7, 2023 · 0 comments
Open

addContext to selected context in the suite #392

joo920131 opened this issue Mar 7, 2023 · 0 comments

Comments

@joo920131
Copy link

Would we be able to use addContext() so we can add to previously executed contexts?

This will be useful for cases where you would resolve async processes all in parallel, while adding the contexts to the relevant hooks/tests for better viewing of mochawesome reports.

I've tried with the following code:

/* eslint-disable @typescript-eslint/no-this-alias */
import addContext from 'mochawesome/addContext';

describe(`Test`, function () {
  let this1: Mocha.Context, this2: Mocha.Context;
  before(`before block1`, async function () {
    this1 = this;
  })
  before(`before block2`, async function () {
    this2 = this;
  })
  before(`resolve befores`, async function () {
    addContext(this1, `hello`);
    addContext(this2, `world`);
  })
  it(`test`, async function () {
    addContext(this, `my test`);
  })
})

Result was like this:

SCR-20230307-k8t

This isn't so useful when you imagine if you have lots of context in one hook block in the report to figure out which one's which. I'm suggesting if we could add the contexts so it's added to the context we have saved previously (this1, #this2).

So the report would show something like this below:

image

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

No branches or pull requests

1 participant