-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
633 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/**/node_modules/* | ||
node_modules/ | ||
test-results/ | ||
playwright-report | ||
dist/ | ||
|
||
# IDE | ||
.idea | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
{"mode":"full","isActive":false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/stylistic", | ||
"prettier", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
root: true, | ||
plugins: ["@typescript-eslint"], | ||
rules: { | ||
"@typescript-eslint/no-explicit-any": 0, | ||
"no-console": 0, | ||
"no-restricted-syntax": [ | ||
"error", | ||
{ | ||
selector: "CallExpression[calle.property.name='only']", | ||
message: "We don't wan to leave .only on our tests 😱", | ||
}, | ||
{ | ||
selector: "CallExpression[callee.name='validateJsonSchema'][arguments.length!=3]", | ||
message: "We don't want to commit validateJsonSchema(*,*,*,true)😎", | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea | ||
node_modules/ | ||
dist/ | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
package-lock.json | ||
.DS_Store | ||
/test-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Playwright Specific | ||
node_modules/ | ||
test-results/ | ||
playwright-report | ||
dist/ | ||
# IDE - VSCode | ||
.idea | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
{"mode":"full","isActive":false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"semi": true, | ||
"trailingComma": "es5", | ||
"singleQuote": false, | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# indent-list-reporter | ||
Playwright list reporter with colorful terminal and indentation | ||
|
||
Playwright list reporter with colorful terminal and indentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "indent-list-reporter", | ||
"version": "1.0.0", | ||
"description": "Playwright list reporter for terminal with colors and indentation'", | ||
"main": "./dist/src/indent-list-reporter.js", | ||
"type": "module", | ||
"homepage": "https://github.com/syzzana/indent-list-reporter/blob/main/README.md", | ||
"scripts": { | ||
"test": "npx playwright test", | ||
"compile": "tsc", | ||
"lint": "eslint .", | ||
"lint:fix": "eslint . --fix", | ||
"prettier": "prettier . --check", | ||
"prettier:fix": "prettier . --write", | ||
"prepare": "npm run compile", | ||
"pretest": "npm run compile" | ||
}, | ||
"keywords": [ | ||
"reporter" | ||
], | ||
"author": "Syzana Bicaj", | ||
"license": "MIT", | ||
"dependencies": { | ||
"playwright": "^1.39.0", | ||
"@playwright/test": "^1.39.0", | ||
"@types/node": "^20.6.1", | ||
"@typescript-eslint/eslint-plugin": "^6.9.1", | ||
"@typescript-eslint/parser": "^6.9.1", | ||
"chalk": "^5.3.0", | ||
"dotenv": "^16.3.1", | ||
"eslint": "^8.52.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"node-fetch": "^3.3.2", | ||
"prettier": "^3.0.3", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from "@playwright/test"; | ||
|
||
export default defineConfig({ | ||
testDir: "tests", | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: [["./dist/src/indent-list-reporter.js"]], | ||
use: { | ||
ignoreHTTPSErrors: true, | ||
trace: "off", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { TestStatus } from "@playwright/test"; | ||
|
||
export interface TestCaseData { | ||
id: string; | ||
title: string; | ||
status: TestStatus; | ||
line: number; | ||
column: number; | ||
duration: number; | ||
} | ||
|
||
export class SuiteTestCases { | ||
private suiteDescription: string; | ||
tests: TestCaseData[]; | ||
|
||
constructor(suiteDescription: string) { | ||
this.suiteDescription = suiteDescription; | ||
this.tests = []; | ||
} | ||
|
||
getSuiteDescription() { | ||
return this.suiteDescription; | ||
} | ||
|
||
setSuiteDescription(suiteDescription: string) { | ||
this.suiteDescription = suiteDescription; | ||
} | ||
|
||
getTests() { | ||
return this.tests; | ||
} | ||
|
||
setTests(tests: TestCaseData[]) { | ||
this.tests = tests; | ||
} | ||
|
||
addTestCase(test: TestCaseData) { | ||
this.tests.push(test); | ||
} | ||
} | ||
|
||
export class TestsPerSpecFile { | ||
private specName: string; | ||
private suiteTests: SuiteTestCases[]; | ||
|
||
constructor(specName: string) { | ||
this.specName = specName; | ||
this.suiteTests = []; | ||
} | ||
|
||
setTestCases(testCases: SuiteTestCases[]) { | ||
this.suiteTests = testCases; | ||
} | ||
|
||
setSpecName(specName: string) { | ||
this.specName = specName; | ||
} | ||
|
||
getSpecName() { | ||
return this.specName; | ||
} | ||
|
||
getSuiteTests() { | ||
return this.suiteTests; | ||
} | ||
|
||
addTestCases(testCase: SuiteTestCases) { | ||
this.suiteTests.push(testCase); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { TestCase, TestResult, Reporter, FullResult, Suite, FullConfig } from "@playwright/test/reporter"; | ||
import { SuiteTestCases, TestCaseData, TestsPerSpecFile } from "./TestsPerSpecFile"; | ||
import { | ||
filterDuplicateSpecNames, | ||
getFileNameOrParentSuite, | ||
howToReadTestResults, | ||
lineBreak, | ||
log, | ||
logFailedTests, | ||
logSummary, | ||
logTestResults, | ||
StatusCounter, | ||
} from "./testResults"; | ||
import chalk from "chalk"; | ||
import { TestStatus } from "@playwright/test"; | ||
import { TestError } from "playwright/types/testReporter"; | ||
|
||
interface TerminalColors { | ||
specFileName: string; | ||
suiteDescription: string; | ||
} | ||
|
||
interface IndentListReporterOptions { | ||
isDimmed: boolean; | ||
baseColors: TerminalColors; | ||
isJenkins: boolean; //TODO implement colors for jenkins terminal | ||
isGithubActions: boolean; //TODO implement colors for github actions terminal | ||
} | ||
|
||
export type TestCaseError = { | ||
error: TestError; | ||
titlePath: string[]; | ||
} | ||
|
||
class IndentListReporter implements Reporter { | ||
private _options: IndentListReporterOptions; | ||
allTests: TestsPerSpecFile[] = []; | ||
passed = 0; | ||
failed = 0; | ||
skipped = 0; | ||
interrupted = 0; | ||
timedOut = 0; | ||
failedTests: TestCaseError[] = []; | ||
constructor(options: IndentListReporterOptions) { | ||
this._options = options; | ||
} | ||
|
||
printsToStdio() { | ||
return true; | ||
} | ||
|
||
onBegin(config: FullConfig, suite: Suite) { | ||
howToReadTestResults(); | ||
log(`${chalk.cyanBright.bgBlack("TEST RESULTS\n")}`); | ||
const numberOfTests = chalk.whiteBright(suite.allTests().length); | ||
const numberOfWorkers = chalk.whiteBright(config.workers.valueOf()); | ||
const testInfo = `Running ${numberOfTests} tests using ${numberOfWorkers} workers\n`; | ||
console.log(chalk.gray(testInfo)); | ||
} | ||
|
||
onTestEnd(test: TestCase, result: TestResult) { | ||
const currentFileName = getFileNameOrParentSuite(test.titlePath(), false, true); | ||
const currentParentSuite = getFileNameOrParentSuite(test.titlePath(), true, false); | ||
const testCase: TestCaseData = { | ||
id: test.id, | ||
title: test.title, | ||
line: test.location.line, | ||
column: test.location.column, | ||
status: result.status, | ||
duration: result.duration, | ||
}; | ||
const testsPerSpecFile = new TestsPerSpecFile(currentFileName); | ||
const suiteTestCases = new SuiteTestCases(currentParentSuite); | ||
suiteTestCases.addTestCase(testCase); | ||
testsPerSpecFile.addTestCases(suiteTestCases); | ||
this.allTests.push(testsPerSpecFile); | ||
this.increaseTestStatusCounter(result.status); | ||
if (result.status === "failed") { | ||
const testCaseError: TestCaseError = { | ||
error: result.error, | ||
titlePath: test.titlePath(), | ||
} | ||
this.failedTests.push(testCaseError); | ||
} | ||
} | ||
|
||
onEnd(result: FullResult) { | ||
const myTests = filterDuplicateSpecNames(this.allTests); | ||
logTestResults(myTests); | ||
const statusCounter: StatusCounter = { | ||
passed: this.passed, | ||
failed: this.failed, | ||
skipped: this.skipped, | ||
interrupted: this.interrupted, | ||
timedOut: this.timedOut, | ||
}; | ||
if (this.failedTests.length > 0) { | ||
log(chalk.bgBlack.italic.red("FAILED TESTS:")); | ||
logFailedTests(this.failedTests); | ||
} | ||
log(lineBreak); | ||
logSummary(result.duration, statusCounter); | ||
} | ||
|
||
increaseTestStatusCounter(test: TestStatus) { | ||
if (test === "passed") { | ||
this.passed++; | ||
} else if (test === "failed") { | ||
this.failed++; | ||
} else if (test === "timedOut") { | ||
this.timedOut++; | ||
} else if (test === "skipped") { | ||
this.skipped++; | ||
} else if (test === "interrupted") { | ||
this.interrupted++; | ||
} | ||
} | ||
} | ||
|
||
export default IndentListReporter; |
Oops, something went wrong.