Skip to content

Commit

Permalink
[patch] fixing watching attachments (issue 61) (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmisty authored Nov 1, 2023
1 parent fcf6e73 commit 117e914
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 58 deletions.
36 changes: 36 additions & 0 deletions integration/e2e/groups/groups.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
export interface Chainable {
step(name: string): Chainable<any>;

Check warning on line 4 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 4 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
other(name: string): Chainable<any>;

Check warning on line 5 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 5 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
}
}

describe('groupped', () => {
Cypress.Commands.add('other', name => {
Cypress.log({ name: 'other', message: name, groupStart: true, type: 'parent' } as any);

Check warning on line 11 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 11 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
cy.log('other').then(() => {
Cypress.log({ emitOnly: true, groupEnd: true } as any);

Check warning on line 13 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 13 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
});
});
Cypress.Commands.add('step', name => {
Cypress.log({ name: 'group', message: name, groupStart: true, type: 'parent' } as any);

Check warning on line 17 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 17 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
cy.wait(200).then(() => {
//
});
cy.other('step NESTED');
cy.log('hello').then(() => {
Cypress.log({ emitOnly: true, groupEnd: true } as any);

Check warning on line 23 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 23 in integration/e2e/groups/groups.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
});
// cy.pause();
});

it('test', () => {
cy.step('step 1');
cy.other('step Paretn');
// cy.step('step 2');
// cy.step('step 3');
// cy.step('step 4');
// cy.step('step 5');
});
});
17 changes: 9 additions & 8 deletions src/plugins/allure-reporter-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,23 +723,24 @@ export class AllureReporter {
this.globalHooks.processForTest();
}

endTests() {
this.tests.forEach(() => {
this.endTest({ result: UNKNOWN, details: undefined });
});
async endTests() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const _tst of this.tests) {
await this.endTest({ result: UNKNOWN, details: undefined });
}
}

endGroups() {
this.endTests();
async endGroups() {
await this.endTests();
this.groups.forEach(() => {
this.endGroup();
});
}

endAll() {
async endAll() {
this.endAllSteps({ status: UNKNOWN, details: undefined });
this.endHooks(Status.BROKEN);
this.endGroups();
await this.endGroups();
}

addDescriptionHtml(arg: AllureTaskArgs<'addDescriptionHtml'>) {
Expand Down
50 changes: 2 additions & 48 deletions src/plugins/allure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ export const allureTasks = (opts: ReporterOptions): AllureTasks => {
log('testParameter');
},

endAll: () => {
endAll: async () => {
log('endAll started');
allureReporter.endAll();
await allureReporter.endAll();
log('endAll');
},

Expand Down Expand Up @@ -340,12 +340,6 @@ export const allureTasks = (opts: ReporterOptions): AllureTasks => {
log('attachScreenshots');
},

/* attachVideoToTests: async (arg: AllureTaskArgs<'attachVideoToTests'>) => {
log(`attachScreenshots ${JSON.stringify(arg)}`);
await allureReporter.attachVideoToTests(arg);
log('attachVideoToTests');
},*/

async afterSpec(arg: AllureTaskArgs<'afterSpec'>) {
log(`afterSpec ${JSON.stringify(arg)}`);

Expand All @@ -361,45 +355,5 @@ export const allureTasks = (opts: ReporterOptions): AllureTasks => {
await copyResultsToWatchFolder(allureResults, allureResultsWatch);
log('afterSpec');
},

/*flushWatcher: async (_arg: AllureTaskArgs<'flushWatcher'>) => {
const allFiles = sync(`${allureResults}/*`);
debug('FLUSH spec');
let doneFiles = 0;
for (const fl of allFiles) {
if (!existsSync(fl)) {
doneFiles = doneFiles + 1;
return;
}
readFile(fl, (err, content) => {
if (!err) {
writeFile(fl, content, errWrite => {
if (errWrite) {
debug(`Error writing file: ${errWrite.message}`);
} else {
debug('done writing');
doneFiles++;
}
});
} else {
debug(`Error reading file: ${err?.message}`);
}
});
}
const started = Date.now();
const timeout = 10000;
while (doneFiles < allFiles.length) {
if (Date.now() - started >= timeout) {
console.error(`Could not flush all files in ${timeout}ms`);
break;
}
await delay(100);
}
},*/
};
};
5 changes: 3 additions & 2 deletions src/plugins/fs-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { copyFile, existsSync, mkdirSync, rm, writeFile } from 'fs';
import Debug from 'debug';
import { delay, packageLog } from '../common';
import { Attachment } from 'allure-js-commons';
import { basename } from 'path';
import { basename, dirname } from 'path';

const debug = Debug('cypress-allure:fs-tools');

Expand Down Expand Up @@ -58,8 +58,9 @@ export const waitWhileCondition = async (whileCondition: () => boolean) => {
}
};

export const copyAttachments = async (attachments: Attachment[], watchPath: string, allureResults: string) => {
export const copyAttachments = async (attachments: Attachment[], watchPath: string, allureResultFile: string) => {
let attachsDone = 0;
const allureResults = dirname(allureResultFile);

attachments.forEach(attach => {
const attachTo = `${watchPath}/${attach.source}`;
Expand Down

0 comments on commit 117e914

Please sign in to comment.