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

Support for nested suites. #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cypress/integration/todo-app-v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ describe('TodoApp', () => {
'do lunch and learn about Cypress'
);
});

describe('Nesting', () => {
it('should work', () => {
cy.get('.todo-list li').should('have.length', 3);

cy.getFirstTodoItem().should(
'be.equal',
'do lunch and learn about Cypress'
);
});
});

});
10 changes: 7 additions & 3 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import addContext from 'mochawesome/addContext';

Cypress.on('test:after:run', (test, runnable) => {
if (test.state === 'failed') {
const screenshot = `${Cypress.config('screenshotsFolder')}/${
Cypress.spec.name
}/${runnable.parent.title} -- ${test.title} (failed).png`;
// It can also be a relative dir like `../screenshots/${Cypress.spec.name}`
// Cypress.config('screenshotsFolder') is now an absolute path, so it no longer works.
const screenshotDir = `assets/${Cypress.spec.name}`;
const screenshotFileBaseName =
runnable.titlePath().join(' -- ') +
(test.hookName ? ` -- ${test.hookName} hook` : '');
Copy link
Author

Choose a reason for hiding this comment

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

It looks like test.hookName is not part of the public interface, this could be a problem. :(

Copy link
Author

Choose a reason for hiding this comment

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

This PR keeps getting outdated, sorry. Most recent code is here: cypress-io/cypress#18543 (comment)

const screenshot = `${screenshotDir}/${screenshotFileBaseName)} (failed).png`;
addContext({ test }, screenshot);
}
});