question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to get screenshot on mocha when i have multiple context

See original GitHub issue

im trying to find a way to set specific naming for cypress screenshot, as i have noticed when im using multiple context in one test spec the screenshot wont be visible

as mocha will search for file with this naming pattern

const filename = `${titleToFileName(runnable.parent.title)} -- ${titleToFileName(test.title)} (failed).png`;

but the actual screenshot will be

00.Login Page Test -- Login page Functionality -- TC_00.08 User should be able to login with valid credential (failed)

main suite name – context name – test name

how i can manage this issue, since i have some spec file has only with one describe block and other spec file has multiple context with same describe

is there way to just save screenshot with only test name so it can work with both approach

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Jun 5, 2020

@Amrkamel1 This is being thrown from fs and is not related to Cypress. See the stack trace.

Issues in our GitHub repo are reserved for potential bugs or feature requests.

We recommend questions relating to how to use Cypress be asked in our community chat. Also try searching our existing GitHub issues, reading through our documentation, or searching Stack Overflow for relevant answers.

0reactions
amrsa1commented, Jun 5, 2020

@jennifer-shehane

Im getting this error below and nothing is changing

    const titleToFileName = (title) => title.replace(/[:\/]/g, '');
    on('after:screenshot', (test, details) => {
        // const filename = `${titleToFileName(test.title)} (failed).png`;
        const filename = '(failed).png';

        return new Promise((resolve, reject) => {
                fs.rename(details.name, filename, (err) => {
                    if (err) return reject(err);
                    resolve({ name: filename })
                })
            })
    });

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocha using Dual Screen - Boris FX Forum
I have a dual monitor setup and the issue is that Mocha fills up the entire screen whereas I can't access desk top...
Read more >
Attach Screenshot into Mochawesome HTML Report in Cypress
When I expand failed test spec details, The screenshot is attached for the failed test case,
Read more >
Selenium Tests with Mocha and Screenshot Reports for failed ...
Automated Selenium Javascript tests with Mocha and complete Test Reports with Screenshot for failed Tests using Mochawesome packageComplete ...
Read more >
Can I add cypress screenshot in mocha awesome html report
I use the following code to add screenshots automatically to any (and only) failed tests: import addContext ...
Read more >
How to Attach Cypress Screenshots to the Mochawesome ...
In this article, we will look at how to add the failed test screenshot to the Mochawesome report and set a custom screen...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found