@isaac.frontend/testcafe-reporter-allure
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -6,2 +6,52 @@ # Changelog | ||
## [0.2.0](https://github.com/isaaceindhoven/testcafe-reporter-allure/compare/v0.1.3...v0.2.0) (2020-06-30) | ||
### ⚠ BREAKING CHANGES | ||
* **README:** Ready for v1.0.0 | ||
### Features | ||
* **concurrency:** adding support for concurrent tests ([4d365f0](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/4d365f0ec6ccfeced2c62014d09942b3745eda31)) | ||
* **jenkins:** adding environment property browser to base runner.js ([289a395](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/289a395718c2ef1597b209e2eeb05339f0697723)) | ||
### Bug Fixes | ||
* **multi-browser:** fixing errors getting duplicated when running multiple browsers ([c8fda56](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/c8fda56f8c91ba89fc13a6243c2efcfaad3ac663)) | ||
* **multi-browser:** fixing steps getting duplicated when running multiple browsers ([2f77a74](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/2f77a7421b0473da25a44a2723ec9bfe25813229)) | ||
* **testing-suite:** re-added removed testing files ([bf79563](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/bf79563c5e2efb30d7d1502d520bea6646a57fd0)) | ||
### Chores | ||
* **chore:** adding environment variable support for the testcafe browsers ([96699b1](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/96699b1220dc95817bfc8e130a922244b73caf1f)) | ||
* **dependencies:** updating dependancies with major releases ([4b00c39](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/4b00c39a3534cc43049bfec0957f58146831b317)) | ||
* **deps:** add renovate.json ([6b646ba](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/6b646ba87f489b4eec9caac32e0d8db4190fd596)) | ||
* **deps:** pin dependencies ([64e1177](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/64e117794777bc4ee03199c2d67e61453d36b695)) | ||
* **deps:** update all non-major dependencies ([616a96f](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/616a96f352802402cbf01bcb07625c07b46a626d)) | ||
* **jenkins:** adding jenkins documentation, cleaning example Jenkinsfile ([16f12aa](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/16f12aae3c86763daae405927952dc1177b70936)) | ||
* **jenkins:** moving the Jenkins file to the example project ([c5f50c4](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/c5f50c4ad432e4de38c561e846cea180ea6765ab)) | ||
* **jenkins:** readding base jenkins file ([ac56ad0](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/ac56ad088a903f5e0ce0039c7eb2a072c1206853)) | ||
* **jenkins:** removing build step, adding browser check ([6eb5fbc](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/6eb5fbcf39ccc545081685d6bd37764e17467e50)) | ||
* **renovate:** adding pattern matching to find sub directory package.json ([5ebeb00](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/5ebeb00ea5398370cc8f01c96d96c7a1efd778e6)) | ||
* **renovate:** configuring renovate and changing default renovate config file ([1fa0581](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/1fa058112bfa3cef0a0b843436aefbb2a73b4f85)) | ||
* **renovate:** moving the config out of the packageRules ([5b233ed](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/5b233ed991cdc86bd9a107a6654fe660215528b5)) | ||
* **renovate:** rename path to paths ([432e3ec](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/432e3ecb1d6e1cf22bca8327f2d35d20e839bb08)) | ||
* **testing-suite:** expanding the allure-reporter testing suite ([17f329d](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/17f329d798383e4197306a585abee40f0672608f)) | ||
### Styles | ||
* **allure-reporter:** re-ordering functions, changing multi-line comment format ([45dbba1](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/45dbba139297c9cf8f63232be5d1dae0c2ede2bc)) | ||
* **README:** Add extra space ([ec635f4](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/ec635f4a7338b3b7f545f6cad2d3d256c8ec083d)) | ||
### Documentation | ||
* **concurrency:** typo fix + adding concurrency in the configuration README ([f910ffd](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/f910ffdf5275445647cd72b852259132fee435e1)) | ||
* **readme:** adding concurrency and multi-browser test-run documentation ([5479923](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/5479923eb1378e49b8d9d1130a33d267d6914b51)) | ||
* **README:** Add shields ([825b9de](https://github.com/isaaceindhoven/testcafe-reporter-allure/commit/825b9decea34ecc31063a10d4fa8f680477140c2)) | ||
### [0.1.3](https://github.com/isaaceindhoven/testcafe-reporter-allure/compare/v0.1.2...v0.1.3) (2020-06-22) | ||
@@ -8,0 +58,0 @@ |
@@ -87,2 +87,3 @@ 'use strict'; | ||
ENABLE_LOGGING: false, | ||
CONCURRENCY: 1, | ||
META: { | ||
@@ -97,3 +98,3 @@ SEVERITY: 'Normal', | ||
SCREENSHOT_ON_FAIL: 'Screenshot taken on fail', | ||
DEFAULT_STEP_NAME: 'Test step', | ||
DEFAULT_STEP_NAME: 'Test Step', | ||
}, | ||
@@ -151,2 +152,50 @@ }; | ||
var reporterConfig = loadReporterConfig(); | ||
var TestStep = /** @class */ (function () { | ||
function TestStep(name, screenshotAmount) { | ||
if (screenshotAmount) { | ||
this.screenshotAmount = screenshotAmount; | ||
} | ||
else { | ||
this.screenshotAmount = 0; | ||
} | ||
if (name) { | ||
this.name = name; | ||
} | ||
else { | ||
this.name = reporterConfig.LABEL.DEFAULT_STEP_NAME; | ||
} | ||
} | ||
TestStep.prototype.registerScreenshot = function () { | ||
this.screenshotAmount += 1; | ||
}; | ||
TestStep.prototype.mergeOnSameName = function (testStep) { | ||
if (this.name === testStep.name) { | ||
if (testStep.screenshotAmount) { | ||
this.screenshotAmount += testStep.screenshotAmount; | ||
} | ||
return true; | ||
} | ||
return false; | ||
}; | ||
TestStep.prototype.addStepToTest = function (test) { | ||
// Steps can be added to the metadata of the test for persistance. | ||
var meta = this.getMeta(test); | ||
if (!meta.steps) { | ||
meta.steps = []; | ||
} | ||
meta.steps.push(this); | ||
}; | ||
// Using the Testcontroller type might cause an error because of a confict with TestCafé's TestController | ||
TestStep.prototype.getMeta = function (testController) { | ||
var meta = testController.testRun.test.meta; | ||
if (!meta) { | ||
meta = {}; | ||
testController.testRun.test.meta = meta; | ||
} | ||
return meta; | ||
}; | ||
return TestStep; | ||
}()); | ||
function addNewLine(text, line) { | ||
@@ -159,3 +208,3 @@ if (text === null) { | ||
var reporterConfig = loadReporterConfig(); | ||
var reporterConfig$1 = loadReporterConfig(); | ||
var Metadata = /** @class */ (function () { | ||
@@ -223,3 +272,3 @@ function Metadata(meta, test) { | ||
// If no severity is given, set the default severity | ||
test.addLabel(allureJsCommons.LabelName.SEVERITY, reporterConfig.META.SEVERITY); | ||
test.addLabel(allureJsCommons.LabelName.SEVERITY, reporterConfig$1.META.SEVERITY); | ||
} | ||
@@ -252,3 +301,3 @@ // Tests can be added to multiple suites at the same time. | ||
if (this.issue) { | ||
test.addLink("" + reporterConfig.META.ISSUE_URL + this.issue, reporterConfig.LABEL.ISSUE + ": " + this.issue, allureJsCommons.LinkType.ISSUE); | ||
test.addLink("" + reporterConfig$1.META.ISSUE_URL + this.issue, reporterConfig$1.LABEL.ISSUE + ": " + this.issue, allureJsCommons.LinkType.ISSUE); | ||
} | ||
@@ -263,3 +312,3 @@ if (this.description) { | ||
// However currenly allure-js-commons does not seem to support flaky tests. | ||
test.addParameter(reporterConfig.LABEL.FLAKY, this.flaky.toString()); | ||
test.addParameter(reporterConfig$1.LABEL.FLAKY, this.flaky.toString()); | ||
} | ||
@@ -337,12 +386,17 @@ Array.from(this.otherMeta.entries()).map(function (entry) { | ||
/* eslint-disable @typescript-eslint/no-unused-vars,class-methods-use-this */ | ||
var reporterConfig$1 = loadReporterConfig(); | ||
var reporterConfig$2 = loadReporterConfig(); | ||
var categoriesConfig = loadCategoriesConfig(); | ||
var AllureReporter = /** @class */ (function () { | ||
function AllureReporter(allureConfig) { | ||
this.groups = []; | ||
this.runningTest = null; | ||
function AllureReporter(allureConfig, userAgents) { | ||
this.runtime = null; | ||
this.userAgents = null; | ||
/* TestCafé does not run the groups concurrently when running the tests concurrently and will end the tests sequentially based on their group/fixture. | ||
This allows for only a single group and group meta to be stored at once. | ||
Saving them in the same way as the tests is also not possible because TestCafé does not call the reporter when a group has ended it is, therefore, not possible to end the groups based on their name. */ | ||
this.group = null; | ||
/* To differentiate between the running tests when running concurrently they are stored using their name as the unique key. */ | ||
this.tests = {}; | ||
var config; | ||
if (!allureConfig) { | ||
config = new allureJsCommons.AllureConfig(reporterConfig$1.RESULT_DIR); | ||
config = new allureJsCommons.AllureConfig(reporterConfig$2.RESULT_DIR); | ||
} | ||
@@ -352,2 +406,3 @@ else { | ||
} | ||
this.userAgents = userAgents; | ||
this.runtime = new allureJsCommons.AllureRuntime(config); | ||
@@ -359,3 +414,5 @@ } | ||
this.runtime.writeCategoriesDefinitions(categoriesConfig); | ||
// this.runtime.writeEnvironmentInfo(); | ||
if (this.userAgents) { | ||
this.runtime.writeEnvironmentInfo({ browsers: this.userAgents.toString() }); | ||
} | ||
}; | ||
@@ -365,14 +422,12 @@ AllureReporter.prototype.startGroup = function (name, meta) { | ||
this.groupMetadata.suite = name; | ||
var suite = this.runtime.startGroup(name); | ||
this.groups.push(suite); | ||
this.group = this.runtime.startGroup(name); | ||
}; | ||
AllureReporter.prototype.endGroup = function () { | ||
var currentGroup = this.getCurrentGroup(); | ||
var currentGroup = this.group; | ||
if (currentGroup !== null) { | ||
currentGroup.endGroup(); | ||
this.groups.pop(); | ||
} | ||
}; | ||
AllureReporter.prototype.startTest = function (name, meta) { | ||
var currentGroup = this.getCurrentGroup(); | ||
var currentGroup = this.group; | ||
if (currentGroup === null) { | ||
@@ -385,10 +440,10 @@ throw new Error('No active suite'); | ||
currentTest.stage = allureJsCommons.Stage.RUNNING; | ||
this.setCurrentTest(currentTest); | ||
this.setCurrentTest(name, currentTest); | ||
}; | ||
AllureReporter.prototype.endTest = function (name, testRunInfo, meta) { | ||
var currentTest = this.getCurrentTest(); | ||
var currentTest = this.getCurrentTest(name); | ||
// If no currentTest exists create a new one | ||
if (currentTest === null) { | ||
this.startTest(name, meta); | ||
currentTest = this.getCurrentTest(); | ||
currentTest = this.getCurrentTest(name); | ||
} | ||
@@ -405,3 +460,4 @@ var hasErrors = !!testRunInfo.errs && !!testRunInfo.errs.length; | ||
currentTest.status = allureJsCommons.Status.FAILED; | ||
testRunInfo.errs.forEach(function (error) { | ||
var mergedErrors = this.mergeErrors(testRunInfo.errs); | ||
mergedErrors.forEach(function (error) { | ||
if (error.errMsg) { | ||
@@ -413,5 +469,2 @@ testMessages = addNewLine(testMessages, error.errMsg); | ||
var callSite = error.callsite; | ||
if (error.userAgent) { | ||
testDetails = addNewLine(testDetails, "User Agent: " + error.userAgent); | ||
} | ||
if (callSite) { | ||
@@ -425,7 +478,5 @@ if (callSite.filename) { | ||
} | ||
// currentTest.detailsTrace = error.callsite; | ||
// error.callsite.stackFrames.forEach(stackFrame => { | ||
// console.log(stackFrame.getFileName()); | ||
// //console.log(stackFrame.toString()); | ||
// }); | ||
if (error.userAgent) { | ||
testDetails = addNewLine(testDetails, "User Agent(s): " + error.userAgent); | ||
} | ||
}); | ||
@@ -446,3 +497,3 @@ } | ||
if (currentMetadata.flaky) { | ||
testMessages = addNewLine(testMessages, reporterConfig$1.LABEL.FLAKY); | ||
testMessages = addNewLine(testMessages, reporterConfig$2.LABEL.FLAKY); | ||
} | ||
@@ -469,7 +520,8 @@ currentMetadata.addMetadataToTest(currentTest, this.groupMetadata); | ||
AllureReporter.prototype.addStepsWithAttachments = function (test, testRunInfo, steps) { | ||
var stepAmount = steps.length; | ||
var mergedSteps = this.mergeSteps(steps); | ||
var stepAmount = mergedSteps.length; | ||
var stepLastIndex = stepAmount - 1; | ||
var screenshotIndex = 0; | ||
for (var i = 0; i < stepAmount; i += 1) { | ||
var testStep = steps[i]; | ||
var testStep = mergedSteps[i]; | ||
var allureStep = test.startStep(testStep.name); | ||
@@ -483,5 +535,5 @@ if (testStep.screenshotAmount && testStep.screenshotAmount > 0) { | ||
} | ||
// Steps do not record the state they finished because this data is not available from TestCafé. | ||
// If a step is not last it can be assumed that the step was successfull because otherwise the test would of stopped earlier. | ||
// If a step is last the status from the test itself should be copied. | ||
/* Steps do not record the state they finished because this data is not available from TestCafé. | ||
If a step is not last it can be assumed that the step was successfull because otherwise the test would of stopped earlier. | ||
If a step is last the status from the test itself should be copied. */ | ||
if (i === stepLastIndex) { | ||
@@ -509,28 +561,70 @@ allureStep.status = test.status; | ||
if (screenshot.takenOnFail) { | ||
screenshotName = reporterConfig$1.LABEL.SCREENSHOT_ON_FAIL; | ||
screenshotName = reporterConfig$2.LABEL.SCREENSHOT_ON_FAIL; | ||
} | ||
else { | ||
screenshotName = reporterConfig$1.LABEL.SCREENSHOT_MANUAL; | ||
screenshotName = reporterConfig$2.LABEL.SCREENSHOT_MANUAL; | ||
} | ||
// Add the useragent data to the screenshots to differentiate between browsers within the tests. | ||
if (this.userAgents && this.userAgents.length > 1 && screenshot.userAgent) { | ||
screenshotName = screenshotName + " - " + screenshot.userAgent; | ||
} | ||
test.addAttachment(screenshotName, allureJsCommons.ContentType.PNG, screenshot.screenshotPath); | ||
} | ||
}; | ||
AllureReporter.prototype.getCurrentGroup = function () { | ||
if (this.groups.length === 0) { | ||
return null; | ||
/* Merge the steps together based on their name. */ | ||
AllureReporter.prototype.mergeSteps = function (steps) { | ||
var mergedSteps = []; | ||
steps.forEach(function (step) { | ||
if (step && step.name) { | ||
var stepExists_1 = false; | ||
mergedSteps.forEach(function (mergedStep) { | ||
stepExists_1 = mergedStep.mergeOnSameName(step); | ||
}); | ||
if (!stepExists_1) { | ||
mergedSteps.push(new TestStep(step.name, step.screenshotAmount)); | ||
} | ||
} | ||
}); | ||
return mergedSteps; | ||
}; | ||
/* Merge the errors together based on their message. */ | ||
AllureReporter.prototype.mergeErrors = function (errors) { | ||
var mergedErrors = []; | ||
errors.forEach(function (error) { | ||
if (error && error.errMsg) { | ||
var errorExists_1 = false; | ||
mergedErrors.forEach(function (mergedError) { | ||
if (error.errMsg === mergedError.errMsg) { | ||
errorExists_1 = true; | ||
if (error.userAgent && mergedError.userAgent !== error.userAgent) { | ||
/* eslint-disable-next-line no-param-reassign */ | ||
mergedError.userAgent = mergedError.userAgent + ", " + error.userAgent; | ||
} | ||
} | ||
}); | ||
if (!errorExists_1) { | ||
mergedErrors.push(error); | ||
} | ||
} | ||
}); | ||
return mergedErrors; | ||
}; | ||
AllureReporter.prototype.getCurrentTest = function (name) { | ||
if (name) { | ||
var allureTest = this.tests[name.toString()]; | ||
if (allureTest) { | ||
return allureTest; | ||
} | ||
} | ||
return this.groups[this.groups.length - 1]; | ||
return null; | ||
}; | ||
AllureReporter.prototype.getCurrentTest = function () { | ||
// TODO: Add parralel testing support | ||
return this.runningTest; | ||
AllureReporter.prototype.setCurrentTest = function (name, test) { | ||
if (name && test) { | ||
this.tests[name] = test; | ||
} | ||
}; | ||
AllureReporter.prototype.setCurrentTest = function (test) { | ||
// TODO: Add parralel testing support | ||
this.runningTest = test; | ||
}; | ||
return AllureReporter; | ||
}()); | ||
var reporterConfig$2 = loadReporterConfig(); | ||
var reporterConfig$3 = loadReporterConfig(); | ||
function deleteFolderContents(dataPath) { | ||
@@ -556,4 +650,4 @@ return __awaiter(this, void 0, void 0, function () { | ||
case 0: | ||
if (!reporterConfig$2.CLEAN_RESULT_DIR) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, deleteFolderContents(path.resolve(process.cwd(), reporterConfig$2.RESULT_DIR))]; | ||
if (!reporterConfig$3.CLEAN_RESULT_DIR) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, deleteFolderContents(path.resolve(process.cwd(), reporterConfig$3.RESULT_DIR))]; | ||
case 1: | ||
@@ -563,4 +657,4 @@ _a.sent(); | ||
case 2: | ||
if (!reporterConfig$2.CLEAN_REPORT_DIR) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, deleteFolderContents(path.resolve(process.cwd(), reporterConfig$2.REPORT_DIR))]; | ||
if (!reporterConfig$3.CLEAN_REPORT_DIR) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, deleteFolderContents(path.resolve(process.cwd(), reporterConfig$3.REPORT_DIR))]; | ||
case 3: | ||
@@ -570,4 +664,4 @@ _a.sent(); | ||
case 4: | ||
if (!reporterConfig$2.CLEAN_SCREENSHOT_DIR) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, deleteFolderContents(path.resolve(process.cwd(), reporterConfig$2.SCREENSHOT_DIR))]; | ||
if (!reporterConfig$3.CLEAN_SCREENSHOT_DIR) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, deleteFolderContents(path.resolve(process.cwd(), reporterConfig$3.SCREENSHOT_DIR))]; | ||
case 5: | ||
@@ -582,5 +676,5 @@ _a.sent(); | ||
var reporterConfig$3 = loadReporterConfig(); | ||
var reporterConfig$4 = loadReporterConfig(); | ||
function log(reporter, text) { | ||
if (reporterConfig$3.ENABLE_LOGGING) { | ||
if (reporterConfig$4.ENABLE_LOGGING) { | ||
reporter.write(text).newline(); | ||
@@ -607,3 +701,3 @@ } | ||
log(this, 'Starting Task'); | ||
this.allureReporter = new AllureReporter(this.allureConfig); | ||
this.allureReporter = new AllureReporter(this.allureConfig, userAgents); | ||
// Clean the previous allure results | ||
@@ -610,0 +704,0 @@ return [4 /*yield*/, cleanAllureFolders()]; |
import { AllureConfig } from 'allure-js-commons'; | ||
import { TestRunInfo } from '../testcafe/models'; | ||
export default class AllureReporter { | ||
private groups; | ||
private runningTest; | ||
private runtime; | ||
private userAgents; | ||
private group; | ||
private groupMetadata; | ||
constructor(allureConfig?: AllureConfig); | ||
private tests; | ||
constructor(allureConfig?: AllureConfig, userAgents?: string[]); | ||
setGlobals(): void; | ||
@@ -17,5 +18,6 @@ startGroup(name: string, meta: object): void; | ||
private addScreenshotAttachment; | ||
private getCurrentGroup; | ||
private mergeSteps; | ||
private mergeErrors; | ||
private getCurrentTest; | ||
private setCurrentTest; | ||
} |
@@ -30,1 +30,10 @@ export {}; | ||
} | ||
export interface ErrorObject { | ||
errMsg?: string; | ||
callsite?: CallSite; | ||
userAgent?: string; | ||
} | ||
export interface CallSite { | ||
filename?: string; | ||
lineNum?: string; | ||
} |
export declare class TestStep { | ||
screenshotAmount: number; | ||
name: string; | ||
constructor(name: string); | ||
constructor(name: string, screenshotAmount?: number); | ||
registerScreenshot(): void; | ||
mergeOnSameName(testStep: TestStep): boolean; | ||
addStepToTest(test: TestController): void; | ||
@@ -7,0 +8,0 @@ private getMeta; |
@@ -74,2 +74,3 @@ 'use strict'; | ||
ENABLE_LOGGING: false, | ||
CONCURRENCY: 1, | ||
META: { | ||
@@ -84,3 +85,3 @@ SEVERITY: 'Normal', | ||
SCREENSHOT_ON_FAIL: 'Screenshot taken on fail', | ||
DEFAULT_STEP_NAME: 'Test step', | ||
DEFAULT_STEP_NAME: 'Test Step', | ||
}, | ||
@@ -133,4 +134,9 @@ }; | ||
var TestStep = /** @class */ (function () { | ||
function TestStep(name) { | ||
this.screenshotAmount = 0; | ||
function TestStep(name, screenshotAmount) { | ||
if (screenshotAmount) { | ||
this.screenshotAmount = screenshotAmount; | ||
} | ||
else { | ||
this.screenshotAmount = 0; | ||
} | ||
if (name) { | ||
@@ -146,2 +152,11 @@ this.name = name; | ||
}; | ||
TestStep.prototype.mergeOnSameName = function (testStep) { | ||
if (this.name === testStep.name) { | ||
if (testStep.screenshotAmount) { | ||
this.screenshotAmount += testStep.screenshotAmount; | ||
} | ||
return true; | ||
} | ||
return false; | ||
}; | ||
TestStep.prototype.addStepToTest = function (test) { | ||
@@ -148,0 +163,0 @@ // Steps can be added to the metadata of the test for persistance. |
{ | ||
"name": "@isaac.frontend/testcafe-reporter-allure", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"author": "ISAAC E-commerce Solutions BV", | ||
@@ -52,35 +52,35 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@rollup/plugin-typescript": "^4.1.2", | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/commit-analyzer": "^8.0.1", | ||
"@semantic-release/git": "^9.0.0", | ||
"@semantic-release/npm": "^7.0.5", | ||
"@semantic-release/release-notes-generator": "^9.0.1", | ||
"@types/jest": "^25.2.1", | ||
"@types/rimraf": "^3.0.0", | ||
"@typescript-eslint/eslint-plugin": "^2.28.0", | ||
"@typescript-eslint/parser": "^2.28.0", | ||
"allure-commandline": "^2.13.0", | ||
"callsite-record": "^4.1.3", | ||
"commitizen": "^4.0.4", | ||
"conventional-changelog-conventionalcommits": "^4.3.0", | ||
"cz-conventional-changelog": "^3.2.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-typescript": "^7.2.1", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-jest": "^23.8.2", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"husky": "^4.2.5", | ||
"jest": "^25.3.0", | ||
"lint-staged": "^10.1.3", | ||
"normalize-newline": "^3.0.0", | ||
"prettier": "^2.0.4", | ||
"rollup": "^2.13.1", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"semantic-release": "^17.0.8", | ||
"testcafe": "^1.8.4", | ||
"ts-jest": "^25.5.1", | ||
"typescript": "^3.9.5" | ||
"@rollup/plugin-typescript": "5.0.1", | ||
"@semantic-release/changelog": "5.0.1", | ||
"@semantic-release/commit-analyzer": "8.0.1", | ||
"@semantic-release/git": "9.0.0", | ||
"@semantic-release/npm": "7.0.5", | ||
"@semantic-release/release-notes-generator": "9.0.1", | ||
"@types/jest": "26.0.3", | ||
"@types/rimraf": "3.0.0", | ||
"@typescript-eslint/eslint-plugin": "3.4.0", | ||
"@typescript-eslint/parser": "3.4.0", | ||
"allure-commandline": "2.13.0", | ||
"callsite-record": "4.1.3", | ||
"commitizen": "4.1.2", | ||
"conventional-changelog-conventionalcommits": "4.3.0", | ||
"cz-conventional-changelog": "3.2.0", | ||
"eslint": "7.3.1", | ||
"eslint-config-airbnb-typescript": "8.0.2", | ||
"eslint-config-prettier": "6.11.0", | ||
"eslint-plugin-import": "2.22.0", | ||
"eslint-plugin-jest": "23.17.1", | ||
"eslint-plugin-prettier": "3.1.4", | ||
"husky": "4.2.5", | ||
"jest": "26.1.0", | ||
"lint-staged": "10.2.11", | ||
"normalize-newline": "3.0.0", | ||
"prettier": "2.0.5", | ||
"rollup": "2.18.1", | ||
"rollup-plugin-typescript2": "0.27.1", | ||
"semantic-release": "17.1.1", | ||
"testcafe": "1.8.7", | ||
"ts-jest": "26.1.1", | ||
"typescript": "3.9.5" | ||
} | ||
} |
@@ -1,7 +0,6 @@ | ||
# testcafe-reporter-allure | ||
# @isaac.frontend/testcafe-reporter-allure | ||
[![NPM downloads per week](https://img.shields.io/npm/dw/@isaac.frontend/testcafe-reporter-allure)](https://www.npmjs.com/package/@isaac.frontend/testcafe-reporter-allure) [![npm (scoped)](https://img.shields.io/npm/v/@isaac.frontend/testcafe-reporter-allure)](https://www.npmjs.com/package/@isaac.frontend/testcafe-reporter-allure) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
This project is an [Allure](https://allure.qatools.ru/) reporter plugin for [TestCafé](https://devexpress.github.io/testcafe/). | ||
This project is an [Allure](http://allure.qatools.ru/) reporter plugin for [TestCafé](https://devexpress.github.io/testcafe/). | ||
The inspiration for this project was its namesake, [testcafe-reporter-allure](https://www.npmjs.com/package/testcafe-reporter-allure), made by azohra-core, making use of the 2.0.0 version of the [allure-js-commons](https://github.com/allure-framework/allure-js/tree/master/packages/allure-js-commons) package. | ||
@@ -15,3 +14,5 @@ | ||
- [Test Steps](#test-steps) | ||
- [Jenkins](#jenkins) | ||
- [Configuration](#configuration) | ||
- [Concurrency and Multi-Browser test-runs](#concurrency-and-multi-browser-test-runs) | ||
- [Contributing](#contributing) | ||
@@ -127,3 +128,17 @@ - [License](#license) | ||
### Jenkins | ||
Because the testcafe-reporter-allure package used Allure to visualize the reports, it is also compatible with the [Allure-Jenkins](https://plugins.jenkins.io/allure-jenkins-plugin/) allowing for the reports to be added to each pipeline run. | ||
An example [Jenkinsfile](https://github.com/isaaceindhoven/testcafe-reporter-allure/blob/master/examples/base-implementation/Jenkinsfile) implementing this can be found in the [examples/base-implementation](https://github.com/isaaceindhoven/testcafe-reporter-allure/tree/master/examples/base-implementation). These pipeline stages can be added to your own projects Jenkinsfile to implement the plugins features. Within the `test:e2e` stage, the environment property `TESTCAFE_BROWSER` can be set to define the browser used within the test run. | ||
Do note that these browsers behave differently because they are running within a docker container. For example, Chrome needs the `--no-sandbox` tag to function properly; otherwise, the following error will occur: `Error: Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.` This issue is further detailed [here](https://github.com/DevExpress/testcafe/issues/1133#issuecomment-350775990). | ||
To avoid running the browsers within the docker container, using a service like [BrowserStack]( https://devexpress.github.io/testcafe/documentation/guides/concepts/browsers.html#browsers-in-cloud-testing-services) is recommended. | ||
Lastly, all browsers have to be run in `:headless` mode, as can be seen within the Jenkinsfile example. | ||
## Configuration | ||
Testcafe-reporter-allure provides a sensible default for the configuration. However, if a different configuration is needed, this default can be overridden by creating the file `allure.config.js` and/or `allure-categories.config.js` in the root of your project. The `allure.config.js` is for the base configuration options, and the `allure-categories.config.js` is specifically for editing the [categories](https://docs.qameta.io/allure/#_categories) config used by the Allure Commandline to sort the tests based on pattern matching. | ||
@@ -145,2 +160,3 @@ | ||
ENABLE_LOGGING: false, | ||
CONCURRENCY: 1, | ||
@@ -190,2 +206,26 @@ META: { | ||
### Concurrency and Multi-Browser test-runs | ||
The testcafe-allure-reporter supports both TestCafé's concurrency and multi-browser test-run features these can both be set using either the runner.js with the TestCafé API or the TestCafé CLI. Also, the concurrency can be set via the `allure.config.js` file, as seen in the previous chapter. | ||
NOTE: Concurrency regards the number of browser instances opened PER browser. For example, if the concurrency is 5, and both Firefox and Chrome are used, TestCafé will open 5 Firefox and 5 Chrome instances. | ||
With the API in the runner.js, multiple browsers can be set by passing them as an array into the `.browsers()` function. Concurrency can be set by passing a number into the `.concurrency()` function. | ||
``` | ||
const allureReporter = require('testcafe-reporter-allure'); | ||
testCafe | ||
.createRunner() | ||
.src(['tests/e2e/*.ts']) | ||
.browsers([firefox:headless, chrome:headless]) <-- | ||
.reporter(allureReporter) | ||
.concurrency(1) <-- | ||
.run(); | ||
``` | ||
With the CLI multiple browsers can be added to the `testcafe` command separated with a comma without a tag. For example: `testcafe chrome,firefox`. Also all local browsers can be run a once by using the `all` alias instead of seperate browsers. | ||
The concurrency can be set within the commandline with the `-c or --concurrency` tag. For example: `testcafe --concurrency 5`. | ||
## Contributing | ||
@@ -199,1 +239,2 @@ | ||
[MIT](https://github.com/isaaceindhoven/testcafe-reporter-allure/blob/master/LICENSE) © ISAAC E-commerce Solutions BV | ||
66989
1038
236