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

[patch] [34] fix for long assertions #36

Merged
merged 4 commits into from
Oct 1, 2023
Merged
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
7 changes: 6 additions & 1 deletion integration/e2e/assertions/assertions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { visitHtml } from '../../common/helper';

describe('assertions', () => {
beforeEach(() => {
//visitHtml();
visitHtml({
body: `
<div data-test-id="item">
Expand Down Expand Up @@ -85,6 +84,12 @@ describe('assertions', () => {
});
});

it('05 repro no assert', () => {
cy.qaId('task-card-title').should(subj => {
expect((subj as any as JQuery).text(), 'text should %NOT_PLACE% match').match(/Task Card/i);
});
});

it('01 assertion: should contain', () => {
cy.window().then(w => {
cy.get('div').should('contain', 'Some text');
Expand Down
1 change: 1 addition & 0 deletions src/plugins/allure-reporter-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export class AllureReporter {

if (title?.indexOf('before each') !== -1 || title?.indexOf('after each') !== -1) {
this.endStep({ status: this.currentStep?.isAnyStepFailed ? Status.FAILED : Status.PASSED });
this.endAllSteps({ status: UNKNOWN });

return;
}
Expand Down
5 changes: 3 additions & 2 deletions src/setup/cypress-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const withTry = (message: string, callback: () => void) => {
};

const stepMessage = (name: string, args: string | undefined) => {
const argsLine = args && args.length > ARGS_TRIM_AT ? '' : args && args.length > 0 ? `: ${args}` : '';
const argsLine =
args && args.length > ARGS_TRIM_AT && name !== 'assert' ? '' : args && args.length > 0 ? `: ${args}` : '';

return `${name}${argsLine}`;
};
Expand Down Expand Up @@ -376,7 +377,7 @@ export const handleCyLogEvents = (

Cypress.Allure.startStep(cmdMessage);

if (log.message > ARGS_TRIM_AT) {
if (logName !== 'assert' && log.message && log.message.length > ARGS_TRIM_AT) {
Cypress.Allure.attachment(`${cmdMessage} args`, log.message, 'application/json');
}
Cypress.Allure.endStep(Status.PASSED);
Expand Down
28 changes: 17 additions & 11 deletions tests/test-folder/mocha-events/commands/long-name-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,17 @@ describe('custom commands', () => {

expect(steps).toEqual([
{
attach: [
{
name: 'tasklog1 args',
sourceContent:
'{"long":{"long":["chicken","chicken","chicken","chicken","chicken","chicken","chicken","chicken"]}}',
type: 'application/json',
},
],
name: 'tasklog1',
steps: [
{
name: 'task: log',
attach: [
{
name: 'task: log args',
Expand All @@ -106,24 +113,23 @@ describe('custom commands', () => {
type: 'application/json',
},
],
name: 'task: log',
steps: [
{
attach: [
{
name: 'task args',
sourceContent:
'log, {"long":{"long":["chicken","chicken","chicken","chicken","chicken","chicken","chicken","chicken"]}}',
type: 'application/json',
},
],
name: 'task',
attach: [],
steps: [],
},
],
},
],
attach: [
{
name: 'tasklog1 args',
sourceContent:
'{"long":{"long":["chicken","chicken","chicken","chicken","chicken","chicken","chicken","chicken"]}}',

type: 'application/json',
},
],
},
]);
});
Expand Down