From 1763879cec03fc4f062afe0832542ce344d3a7ef Mon Sep 17 00:00:00 2001 From: mmisty Date: Fri, 27 Oct 2023 17:57:50 +0300 Subject: [PATCH 1/2] partially revert back --- CHANGELOG.md | 9 +- README.pack.md | 31 +-- cypress.config.ts | 1 + package.json | 2 +- src/plugins/allure-reporter-plugin.ts | 186 ++++++++++++------ src/plugins/allure.ts | 37 +++- src/plugins/fs-tools.ts | 97 +++++++++ src/plugins/index.ts | 24 +-- tests/cy-helper/utils.ts | 3 +- .../common/reporter-server.test.ts | 1 + tests/test-folder/common/reporter.test.ts | 1 + 11 files changed, 281 insertions(+), 111 deletions(-) create mode 100644 src/plugins/fs-tools.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index a9e8c802..ee074536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,9 @@ ## Change Log -### 1.0.0 - - [TestOps] [BREAKING CHANGE] - videos will be uploaded once for spec and uploaded to an after hook named `video`. -This should keep more storage, since video file is one. It will be available in all tests from the spec.
-If you used env var `allureResultsWatchPath` previously from this version it is removed. -You need to specify only `allureResults` now and tell testops to watch it. +### 0.12.1 +- [TestOps] watcher improvements - realtime results for all tests ### 0.12.0 - - [TestOps] watcher imrovements - realtime results for passed tests + - [TestOps] watcher improvements - realtime results for passed tests ### 0.11.0 - [#35] issue - add possibility to skip hooks by env var `allureSkipSteps` diff --git a/README.pack.md b/README.pack.md index dcddfdb7..030de550 100644 --- a/README.pack.md +++ b/README.pack.md @@ -140,21 +140,22 @@ That's it! :tada: ## Environment variables -| Variable | Description | -|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **allure**
_type: boolean_
_default: false_ | Enables reporting | -| **allureResults**
_type: string_
_default: `allure-results`_ | Path to allure results folder (where json files will be written) | -| **allureLogCyCommands**
_type: boolean_
_default: true_ | log cypress commands, by default will log all
![cy_steps](./docs/cy_steps.jpg) | -| **allureSkipCommands**
_type: string_

ex.: `screenshot,wait` | Cypress commands separated with comma. Will skip only cypress commands used by `cy.` (any child commands will persist)
Will not log specified commands as steps in allure report, by default logs all commands. You can also use asterisk in command name - it will be assumed as any chars
| -| **allureSkipSteps**
_type: string_

ex.: `screenshot,wait`
ex.: `"after each" hook*,"before each" hook*,"before all" hook*` | Any allure steps that were created separated with comma (ex. `cy.allure().startStep('my-step')` - `my-step` can be added into `allureSkipSteps` env var, if you put into `allureSkipCommands` this command will still persist).
Will not log specified steps at all including child steps, by default logs all steps.
To skip before each / before all / after each or after all hooks their names can be added here. You can also use asterisk in step name - it will be assumed as any chars
| -| **allureWrapCustomCommands**
_type: true/false/string_
_default: true_

ex:
- `allureWrapCustomCommands: 'true'`
- `allureWrapCustomCommands:'qaId,login'`
- `allureWrapCustomCommands:'!qaValue'` | will wrap custom commands, so custom command will have child steps in report
When value has string with commands split by comma will wrap only these commands.
To exclude commands specify them starting with `!` - all commands specified in this variable should have either `!` or not have it

For this to work you should register allure plugin in setup files before any new commands are added.

![wrap-cmd](./docs/wrap_cmd.jpg) | -| **allureCleanResults**
_type: boolean_
_default: false_ | Will remove allure results on cypress start (it will be done once, after plugins are loaded) | -| **allureAttachRequests**
_type: boolean_
_default: false_ | Attach request/response body and status as files to request step

Several requests:
![requests](./docs/requests.jpg)
One request:
![request](./docs/request.jpg) | -| **allureCompactAttachments**
*type: boolea*n
_default: true_ | Stringify requests attachments with spaces or not | -| **allureAddVideoOnPass**
_type: boolean_
_default: false_ | When true - will attach video for all tests (including passed), otherwise will attach videos only for failed, broken, unknown | -| **tmsPrefix**
_type: string_

ex: `http://jira.com` or `http://jira.com/PROJECT-1/*/browse` | You can specify prefix to tms using this. It will be concatenated with value when using cypress interface like `cy.allure().tms('PROJ-01')`.
Also link can be specified with `*` - it will be replaced with id.

Difference between tms and issue - will have different icons:

![links](./docs/links.jpg) | -| **issuePrefix**
_type: string_

ex: `http://jira.com` or `http://jira.com/PROJECT-1/*/browse` | The same as tmsPrefix - for issue `cy.allure().issue('PROJ-02')` | -| **allureShowDuplicateWarn**
_type: boolean_
_default: false_ | Show console warnings about test duplicates. | +| Variable | Description | +|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **allure**
_type: boolean_
_default: false_ | Enables reporting | +| **allureResults**
_type: string_
_default: `allure-results`_ | Path to allure results folder (where json files will be written) | +| **allureResultsWatchPath**
_type: string_
_default: `allure-results`_ | This is needed when using Allure TestOps:
path to folder where results will be moved after finishing.
This path is what you need to watch when using Allure TestOps, but default this is not specified. When you use this path test results will start to appear in Allure TestOps, video will appear only after spec is finished.
If do not use this with Allure TestOps some videos may not be uploaded - videos will be uploaded only for 1 test from spec file. | +| **allureLogCyCommands**
_type: boolean_
_default: true_ | log cypress commands, by default will log all
![cy_steps](./docs/cy_steps.jpg) | +| **allureSkipCommands**
_type: string_

ex.: `screenshot,wait` | Cypress commands separated with comma. Will skip only cypress commands used by `cy.` (any child commands will persist)
Will not log specified commands as steps in allure report, by default logs all commands. You can also use asterisk in command name - it will be assumed as any chars
| +| **allureSkipSteps**
_type: string_

ex.: `screenshot,wait`
ex.: `"after each" hook*,"before each" hook*,"before all" hook*` | Any allure steps that were created separated with comma (ex. `cy.allure().startStep('my-step')` - `my-step` can be added into `allureSkipSteps` env var, if you put into `allureSkipCommands` this command will still persist).
Will not log specified steps at all including child steps, by default logs all steps.
To skip before each / before all / after each or after all hooks their names can be added here. You can also use asterisk in step name - it will be assumed as any chars
| +| **allureWrapCustomCommands**
_type: true/false/string_
_default: true_

ex:
- `allureWrapCustomCommands: 'true'`
- `allureWrapCustomCommands:'qaId,login'`
- `allureWrapCustomCommands:'!qaValue'` | will wrap custom commands, so custom command will have child steps in report
When value has string with commands split by comma will wrap only these commands.
To exclude commands specify them starting with `!` - all commands specified in this variable should have either `!` or not have it

For this to work you should register allure plugin in setup files before any new commands are added.

![wrap-cmd](./docs/wrap_cmd.jpg) | +| **allureCleanResults**
_type: boolean_
_default: false_ | Will remove allure results on cypress start (it will be done once, after plugins are loaded) | +| **allureAttachRequests**
_type: boolean_
_default: false_ | Attach request/response body and status as files to request step

Several requests:
![requests](./docs/requests.jpg)
One request:
![request](./docs/request.jpg) | +| **allureCompactAttachments**
*type: boolea*n
_default: true_ | Stringify requests attachments with spaces or not | +| **allureAddVideoOnPass**
_type: boolean_
_default: false_ | When true - will attach video for all tests (including passed), otherwise will attach videos only for failed, broken, unknown | +| **tmsPrefix**
_type: string_

ex: `http://jira.com` or `http://jira.com/PROJECT-1/*/browse` | You can specify prefix to tms using this. It will be concatenated with value when using cypress interface like `cy.allure().tms('PROJ-01')`.
Also link can be specified with `*` - it will be replaced with id.

Difference between tms and issue - will have different icons:

![links](./docs/links.jpg) | +| **issuePrefix**
_type: string_

ex: `http://jira.com` or `http://jira.com/PROJECT-1/*/browse` | The same as tmsPrefix - for issue `cy.allure().issue('PROJ-02')` | +| **allureShowDuplicateWarn**
_type: boolean_
_default: false_ | Show console warnings about test duplicates. | ### tmsPrefix and issuePrefix diff --git a/cypress.config.ts b/cypress.config.ts index 90837bc9..c22aa869 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -26,6 +26,7 @@ export default defineConfig({ allureAttachRequests: true, allureCompactAttachments: 'false', allureResults: 'allure-results', // for test results to write + allureResultsWatchPath: 'allure-results/watch', allureSkipCommands: '', // separated comma // allureSkipSteps: '"after each" hook*,"before each" hook*,"before all" hook', // separated comma allureAddVideoOnPass: 'true', diff --git a/package.json b/package.json index f3b02d7f..c30a7516 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "publish:patch": "export ver=$(semver $(npm show . version) --increment -i patch) && npm run publishPack && npm run postpublish", "publish:minor": "export ver=$(semver $(npm show . version) --increment -i minor) && npm run publishPack && npm run postpublish", "publish:major": "export ver=$(semver $(npm show . version) --increment -i major) && npm run publishPack && npm run postpublish", - "publish:pack": "export ver=\"0.0.2-alpha-2\" && npm run publishPack && npm run postpublish", + "publish:pack": "export ver=\"1.0.1\" && npm run publishPack && npm run postpublish", "postpublish": "git tag v$ver" }, "overrides": { diff --git a/src/plugins/allure-reporter-plugin.ts b/src/plugins/allure-reporter-plugin.ts index 4aeb4ffd..b31944f8 100644 --- a/src/plugins/allure-reporter-plugin.ts +++ b/src/plugins/allure-reporter-plugin.ts @@ -3,25 +3,35 @@ import { AllureRuntime, AllureStep, AllureTest, + Attachment, ExecutableItem, ExecutableItemWrapper, FixtureResult, + Status, StatusDetails, TestResult, } from 'allure-js-commons'; import getUuid from 'uuid-by-string'; import getUuidByString from 'uuid-by-string'; import { parseAllure } from 'allure-js-parser'; -import { copyFile, copyFileSync, existsSync, mkdirSync, readFile, readFileSync, writeFile, writeFileSync } from 'fs'; +import { copyFileSync, existsSync, mkdirSync, readFile, readFileSync, writeFileSync } from 'fs'; import path, { basename } from 'path'; import glob from 'fast-glob'; import { ReporterOptions } from './allure'; import Debug from 'debug'; import { GlobalHooks } from './allure-global-hook'; -import { AllureTaskArgs, LabelName, Stage, Status, StatusType, UNKNOWN } from './allure-types'; -import { delay, extname, packageLog } from '../common'; +import { AllureTaskArgs, LabelName, Stage, StatusType, UNKNOWN } from './allure-types'; +import { extname, packageLog } from '../common'; import type { ContentType } from '../common/types'; import { randomUUID } from 'crypto'; +import { + copyAttachments, + copyFileCp, + copyTest, + mkdirSyncWithTry, + waitWhileCondition, + writeResultFile, +} from './fs-tools'; const beforeEachHookName = '"before each" hook'; const beforeAllHookName = '"before all" hook'; @@ -37,17 +47,85 @@ const log = (...args: unknown[]) => { debug(args); }; -const writeTestFile = (testFile: string, content: string, callBack: () => void) => { - writeFile(testFile, content, errWrite => { - if (errWrite) { - log(`error test file ${errWrite.message} `); +const createNewContentForContainer = (nameAttAhc: string, existingContents: Buffer, ext: string, specname: string) => { + const containerJSON = JSON.parse(existingContents.toString()); + + const after: ExecutableItem = { + name: 'video', + attachments: [ + { + name: `${specname}${ext}`, + type: 'video/mp4', + source: nameAttAhc, + }, + ], + parameters: [], + start: Date.now(), + stop: Date.now(), + status: Status.PASSED, + statusDetails: {}, + stage: Stage.FINISHED, + steps: [], + }; + + if (!containerJSON.afters) { + containerJSON.afters = []; + } + + containerJSON.afters.push(after); + + return containerJSON; +}; - return; +/** + * Will copy test results and all attachments to watch folder + * for results to appear in TestOps + * @param input + * @param allureResultsWatch + */ +const copyFileToWatch = async ( + input: { test: string; attachments: { name: string; type: string; source: string }[] }, + allureResultsWatch: string, +) => { + const { test: allureResultFile, attachments } = input; + const allureResults = path.dirname(allureResultFile); + + if (allureResults === allureResultsWatch) { + log(`afterSpec allureResultsWatch the same as allureResults ${allureResults}, will not copy`); + + return; + } + mkdirSyncWithTry(allureResultsWatch); + + log(`allureResults: ${allureResults}`); + log(`allureResultsWatch: ${allureResultsWatch}`); + log(`attachments: ${JSON.stringify(attachments)}`); + + await copyAttachments(attachments, allureResultsWatch, allureResultFile); + await copyTest(allureResultFile, allureResultsWatch); +}; + +/** + * Get all attachments for test to move them to watch folder + * @param item test item + */ +const getAllAttachments = (item: ExecutableItem) => { + const attachmentsResult: Attachment[] = []; + + const inner = (steps: ExecutableItem[], accumulatedRes: Attachment[]): Attachment[] => { + if (steps.length === 0) { + return accumulatedRes; } - log(`write test file done ${testFile} `); - callBack(); - }); + + const [first, ...rest] = steps; + const newRes = [...accumulatedRes, ...first.attachments]; + + return inner(rest, newRes); + }; + + return inner(item.steps, attachmentsResult); }; + // all tests for session const allTests: { specRelative: string | undefined; fullTitle: string; uuid: string; mochaId: string }[] = []; @@ -55,6 +133,7 @@ export class AllureReporter { // todo config private showDuplicateWarn: boolean; private allureResults: string; + private allureResultsWatch: string; private allureAddVideoOnPass: boolean; private allureSkipSteps: RegExp[]; private videos: string; @@ -78,6 +157,7 @@ export class AllureReporter { constructor(opts: ReporterOptions) { this.showDuplicateWarn = opts.showDuplicateWarn; this.allureResults = opts.allureResults; + this.allureResultsWatch = opts.techAllureResults; this.allureAddVideoOnPass = opts.allureAddVideoOnPass; this.videos = opts.videos; this.screenshots = opts.screenshots; @@ -408,14 +488,14 @@ export class AllureReporter { * @param arg {path: string} */ async attachVideoToContainers(arg: { path: string }) { - // this happens after test has already finished + // this happens after test and suites have already finished const { path: videoPath } = arg; log(`attachVideoToTests: ${videoPath}`); const ext = '.mp4'; const specname = basename(videoPath, ext); log(specname); - // when video uploads everything is uploaded already(TestOps) except containers + // when video uploads everything is uploaded already (TestOps) except containers const res = parseAllure(this.allureResults); const tests = res @@ -431,7 +511,7 @@ export class AllureReporter { let doneFiles = 0; - readFile(videoPath, (errVideo, _contentVideo) => { + readFile(videoPath, errVideo => { if (errVideo) { console.error(`Could not read video: ${errVideo}`); @@ -439,7 +519,12 @@ export class AllureReporter { } testsAttach.forEach(test => { - const containerFile = `${this.allureResults}/${test.parent?.uuid}-container.json`; + if (!test.parent) { + console.error(`not writing videos since test has no parent suite: ${test.fullName}`); + + return; + } + const containerFile = `${this.allureResults}/${test.parent.uuid}-container.json`; log(`ATTACHING to container: ${containerFile}`); readFile(containerFile, (err, contents) => { @@ -448,71 +533,34 @@ export class AllureReporter { return; } - const testCon = JSON.parse(contents.toString()); const uuid = randomUUID(); - const nameAttAhc = `${uuid}-attachment${ext}`; const newPath = path.join(this.allureResults, nameAttAhc); + const newContentJson = createNewContentForContainer(nameAttAhc, contents, ext, specname); + const newContent = JSON.stringify(newContentJson); - const after = { - name: 'video', - attachments: [ - { - name: `${specname}${ext}`, - type: 'video/mp4', - source: nameAttAhc, - }, - ], - parameters: [], - start: Date.now(), - stop: Date.now(), - status: 'passed', - statusDetails: {}, - stage: 'finished', - steps: [], + const writeContainer = () => { + log(`write result file ${containerFile} `); + writeResultFile(containerFile, newContent, () => { + doneFiles = doneFiles + 1; + }); }; - if (!testCon.afters) { - testCon.afters = [after]; - } else { - testCon.afters.push(after); - } - if (existsSync(newPath)) { - log(`not writing! video file ${newPath} `); - - writeTestFile(containerFile, JSON.stringify(testCon), () => { - doneFiles = doneFiles + 1; - }); + log(`not writing video, file already exist in path ${newPath} `); + writeContainer(); return; } - log(`write video file ${newPath} `); - copyFile(videoPath, newPath, errCopy => { - if (errCopy) { - log(`error copy file ${errCopy.message} `); - - return; - } - log(`write test file ${containerFile} `); - writeTestFile(containerFile, JSON.stringify(testCon), () => { - doneFiles = doneFiles + 1; - }); + copyFileCp(videoPath, newPath, false, () => { + writeContainer(); }); }); }); }); - const started = Date.now(); - const timeout = 10000; - while (doneFiles < testsAttach.length) { - if (Date.now() - started >= timeout) { - console.error(`Could not write all video attachments in ${timeout}ms`); - break; - } - await delay(100); - } + await waitWhileCondition(() => doneFiles < testsAttach.length); } endGroup() { @@ -752,7 +800,7 @@ export class AllureReporter { } } - endTest(arg: AllureTaskArgs<'testEnded'>): void { + async endTest(arg: AllureTaskArgs<'testEnded'>): Promise { const { result, details } = arg; const storedStatus = this.testStatusStored; const storedDetails = this.testDetailsStored; @@ -788,6 +836,9 @@ export class AllureReporter { this.applyGroupLabels(); const uid = this.currentTest.uuid; + + //const resAtt: Attachment[] = [...this.currentTest.wrappedItem.attachments]; + const attachments = getAllAttachments(this.currentTest.wrappedItem); this.currentTest.endTest(); this.tests.pop(); this.descriptionHtml = []; @@ -807,6 +858,11 @@ export class AllureReporter { } }; waitResultWritten(this.allureResults, `${this.allureResults}/${uid}-result.json`); + + // move to watch + + log('testEnded: will move result to watch folder'); + await copyFileToWatch({ test: `${this.allureResults}/${uid}-result.json`, attachments }, this.allureResultsWatch); } startStep(arg: AllureTaskArgs<'stepStarted'>) { diff --git a/src/plugins/allure.ts b/src/plugins/allure.ts index 5370c4da..3e6a0e4f 100644 --- a/src/plugins/allure.ts +++ b/src/plugins/allure.ts @@ -3,7 +3,9 @@ import { AllureReporter } from './allure-reporter-plugin'; import { AllureTaskArgs, AllureTasks, Status } from './allure-types'; import { appendFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs'; import { packageLog } from '../common'; -import { dirname } from 'path'; +import { basename, dirname } from 'path'; +import glob from 'fast-glob'; +import { copyFileCp, mkdirSyncWithTry, waitWhileCondition } from './fs-tools'; const debug = Debug('cypress-allure:proxy'); @@ -14,6 +16,7 @@ const log = (...args: unknown[]) => { export type ReporterOptions = { allureAddVideoOnPass: boolean; allureResults: string; + techAllureResults: string; videos: string; screenshots: string; showDuplicateWarn: boolean; @@ -22,10 +25,36 @@ export type ReporterOptions = { isTest: boolean; }; +const copyResultsToWatchFolder = async (allureResults: string, allureResultsWatch: string) => { + if (allureResults === allureResultsWatch) { + log(`afterSpec allureResultsWatch the same as allureResults ${allureResults}, will not copy`); + + return; + } + + const results = glob.sync(`${allureResults}/*.*`); + + mkdirSyncWithTry(allureResultsWatch); + + log(`allureResults: ${allureResults}`); + log(`allureResultsWatch: ${allureResultsWatch}`); + + let doneFiles = 0; + + results.forEach(res => { + const to = `${allureResultsWatch}/${basename(res)}`; + copyFileCp(res, to, true, () => { + doneFiles = doneFiles + 1; + }); + }); + await waitWhileCondition(() => doneFiles < results.length); +}; + export const allureTasks = (opts: ReporterOptions): AllureTasks => { // todo config let allureReporter = new AllureReporter(opts); const allureResults = opts.allureResults; + const allureResultsWatch = opts.techAllureResults; return { specStarted: (arg: AllureTaskArgs<'specStarted'>) => { @@ -185,7 +214,9 @@ export const allureTasks = (opts: ReporterOptions): AllureTasks => { testEnded: async (arg: AllureTaskArgs<'testEnded'>) => { log(`testEnded ${JSON.stringify(arg)}`); - allureReporter.endTest(arg); + + await allureReporter.endTest(arg); + log('testEnded'); }, @@ -327,7 +358,7 @@ export const allureTasks = (opts: ReporterOptions): AllureTasks => { console.error(`${packageLog} No video path in afterSpec result`); } - // await copyResultsToWatchFolder(allureResults, allureResultsWatch); + await copyResultsToWatchFolder(allureResults, allureResultsWatch); log('afterSpec'); }, diff --git a/src/plugins/fs-tools.ts b/src/plugins/fs-tools.ts new file mode 100644 index 00000000..c8b0b5fe --- /dev/null +++ b/src/plugins/fs-tools.ts @@ -0,0 +1,97 @@ +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'; + +const debug = Debug('cypress-allure:fs-tools'); + +const log = (...args: unknown[]) => { + debug(args); +}; + +export const mkdirSyncWithTry = (dir: string) => { + if (!existsSync(dir)) { + for (let i = 0; i < 5; i++) { + try { + mkdirSync(dir); + + return; + } catch (err) { + // ignore + log(`Could not create dir: ${(err as Error).message}`); + } + } + } +}; + +export const copyFileCp = (from: string, to: string, isRemoveSource: boolean, callback: () => void) => { + log(`copy file ${from} to ${to}`); + + copyFile(from, to, err => { + if (err) { + log(`Error copying file: ${err.message}`); + + return; + } + + if (isRemoveSource) { + rm(from, () => { + // ignore + }); + } + + callback(); + }); +}; + +export const waitWhileCondition = async (whileCondition: () => boolean) => { + const started = Date.now(); + const timeout = 10000; + + while (whileCondition()) { + if (Date.now() - started >= timeout) { + console.error(`${packageLog} Could not write all attachments in ${timeout}ms`); + break; + } + await delay(100); + } +}; + +export const copyAttachments = async (attachments: Attachment[], watchPath: string, allureResults: string) => { + let attachsDone = 0; + + attachments.forEach(attach => { + const attachTo = `${watchPath}/${attach.source}`; + const attachFrom = `${allureResults}/${attach.source}`; + copyFileCp(attachFrom, attachTo, true, () => { + attachsDone = attachsDone + 1; + }); + }); + + await waitWhileCondition(() => attachsDone < attachments.length); +}; + +export const copyTest = async (testFile: string, watchPath: string) => { + let testsDone = 0; + const to = `${watchPath}/${basename(testFile)}`; + + // do not remove for understanding how containers connected to tests + copyFileCp(testFile, to, false, () => { + testsDone = testsDone + 1; + }); + + await waitWhileCondition(() => testsDone < 1); +}; + +export const writeResultFile = (resultContainer: string, content: string, callBack: () => void) => { + writeFile(resultContainer, content, errWrite => { + if (errWrite) { + log(`error test file ${errWrite.message} `); + + return; + } + log(`write test file done ${resultContainer} `); + callBack(); + }); +}; diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 31202319..4fb8161f 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -33,6 +33,7 @@ export const configureAllureAdapterPlugins = ( debug('Register plugin'); const results = config.env['allureResults'] ?? 'allure-results'; + const watchResultsPath = config.env['allureResultsWatchPath']; const allureAddVideoOnPass = config.env['allureAddVideoOnPass'] === true || config.env['allureAddVideoOnPass'] === 'true'; @@ -45,6 +46,7 @@ export const configureAllureAdapterPlugins = ( showDuplicateWarn, allureAddVideoOnPass, allureResults: results, + techAllureResults: watchResultsPath ?? results, allureSkipSteps: config.env['allureSkipSteps'] ?? '', screenshots: config.screenshotsFolder || 'no', // todo when false videos: config.videosFolder, @@ -72,9 +74,11 @@ export const configureAllureAdapterPlugins = ( }; cleanDir(options.allureResults); + cleanDir(options.techAllureResults); try { mkdirSync(options.allureResults, { recursive: true }); + mkdirSync(options.techAllureResults, { recursive: true }); } catch (err) { debug(`Error creating allure-results: ${(err as Error).message}`); } @@ -92,26 +96,6 @@ export const configureAllureAdapterPlugins = ( url: config.reporterUrl, }; - // process.on('message', (message: any) => { - // const [event, , args] = message.args; - // /*console.log('message'); - // console.log(message); - // console.log(message.args);*/ - // - // if (message.event !== 'preprocessor:close') { - // return; - // } - // console.log(message); - // const [spec] = message.args; - // console.log(spec); - // //const [spec, results] = args; - // reporter.suiteStarted({ fullTitle: 'd', title: 'video' }); - // reporter.testStarted({ fullTitle: spec, title: spec, id: spec }); - // reporter.video({ path: 'd' }); - // reporter.testEnded({ result: 'passed' }); - // reporter.suiteEnded({}); - // }); - on('after:spec', async (spec, results) => { await reporter.afterSpec({ results }); }); diff --git a/tests/cy-helper/utils.ts b/tests/cy-helper/utils.ts index 0e84341a..a7ef9842 100644 --- a/tests/cy-helper/utils.ts +++ b/tests/cy-helper/utils.ts @@ -290,6 +290,7 @@ export const createResTest2 = ( const env = { allure: 'true', allureResults: storeResDir, + allureResultsWatchPath: `${storeResDir}/watch`, allureCleanResults: 'true', allureSkipCommands: 'intercept', COVERAGE: `${process.env.COVERAGE === 'true'}`, @@ -327,7 +328,7 @@ export const createResTest2 = ( }); return { - watch: env.allureResults, + watch: env.allureResultsWatchPath, specs: specPaths.map( t => `${process.cwd()}/reports/test-events/${basename(t)}.log`, ), diff --git a/tests/test-folder/common/reporter-server.test.ts b/tests/test-folder/common/reporter-server.test.ts index 1c2c66b3..6c0918cc 100644 --- a/tests/test-folder/common/reporter-server.test.ts +++ b/tests/test-folder/common/reporter-server.test.ts @@ -23,6 +23,7 @@ describe.skip('startReporterServer', () => { const reporter = allureTasks({ allureAddVideoOnPass: true, allureResults: results, + techAllureResults: `${results}/watch`, videos: 'reports/screens', screenshots: 'reports/screens', showDuplicateWarn: true, diff --git a/tests/test-folder/common/reporter.test.ts b/tests/test-folder/common/reporter.test.ts index 3b28b8ad..05a60e61 100644 --- a/tests/test-folder/common/reporter.test.ts +++ b/tests/test-folder/common/reporter.test.ts @@ -22,6 +22,7 @@ describe('reporter', () => { allureAddVideoOnPass: false, allureSkipSteps: '', allureResults: resultsPath, + techAllureResults: `${resultsPath}/watch`, videos: 'vid', screenshots: 'scr', showDuplicateWarn: false, From 3a8e59684aab2c7de338b417a5ecc534100a83bd Mon Sep 17 00:00:00 2001 From: mmisty Date: Fri, 27 Oct 2023 18:36:25 +0300 Subject: [PATCH 2/2] attempt to fix dowloading node --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18976d3f..8a236744 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: '18.x' + node-version: '18.12.0' registry-url: 'https://registry.npmjs.org' - uses: volta-cli/action@v4