Cypress: Screenshots saved under 'All Specs' directory when running all specs

Created on 10 Aug 2018  路  7Comments  路  Source: cypress-io/cypress

We want to save screenshots under a directory with the spec path, but when running all specs, all screenshots end up under an All Specs directory. We need to ensure each screenshot gets saved under its own spec's directory when running all specs.

See https://github.com/cypress-io/cypress/issues/2091#issuecomment-412028972

ready for work screenshots 馃摳 bug

Most helpful comment

I'd like to contribute a fix for this bug. Where would I start?

All 7 comments

This has been a major pain point for me.

Related (or the root cause), Cypress.spec.name should always return the spec being run (ex my-subfolder/my-test.spec.ts), not All Specs

This is really part of the refactor that needs to happen to All Specs. We don't really want to ever run All Specs the way we're currently doing it.

In fact this is hangover from when we implemented spec isolation and there is an open issue that discusses possible avenues for handling it better.

TLDR: when running all the specs it will "transition" between specs so that each still loads in isolation. That would fix this issue as well.

https://github.com/cypress-io/cypress/issues/1586

I see that the assigned people were removed, is this on hold? Or do we have a timeline for this issue?

This issue is still in the 'ready for work' stage, which means no work has been done on this issue as of today, so we do not have an estimate on when this will be delivered.

Mine is not under the specs actually and I do not have any issue with it.
image

I'd like to contribute a fix for this bug. Where would I start?

We have also seen a issue where in when we run a particular set of tests with spec for eg: if all tests under UI folder then if tests have been stored under multiple subfolders then path from mochawesome doesnt report correctly leading to screenshot not displaying in the mochawesome reports , My code looks like this // //adding screenshots to the report

const addContext = require('mochawesome/addContext');
Cypress.on('test:after:run', (test, runnable) => {
  if (test.state === 'failed') {
    const screenshotFileName = `${runnable.parent.title} -- ${test.title} (failed).png`;
    addContext(
      {
        test,
      },
      `assets/${Cypress.spec.name}/${screenshotFileName}`
    );
  }

folder structure is abc > def > ui\out\clinic\appointments_page_test.js\ then the screenshots by default dont go into the folder.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stormherz picture stormherz  路  3Comments

carloscheddar picture carloscheddar  路  3Comments

weskor picture weskor  路  3Comments

rbung picture rbung  路  3Comments

scottcrowe picture scottcrowe  路  3Comments