Skip to content

Commit

Permalink
[patch] [34] fix for long assertions (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmisty committed Oct 1, 2023
1 parent 5e97ee4 commit 59a5911
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
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);

Check warning on line 89 in integration/e2e/assertions/assertions.cy.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 89 in integration/e2e/assertions/assertions.cy.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
});
});

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

0 comments on commit 59a5911

Please sign in to comment.