Skip to content

Commit

Permalink
updated default outputFile to ./monocart-report/index.html from `…
Browse files Browse the repository at this point in the history
…./test-results/report.html`
  • Loading branch information
cenfun committed Sep 2, 2024
1 parent e53057c commit 194d625
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 47 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

* 2.8.0
- (New Feature) added new merge command for CLI: `npx monocart merge path-to/*/*.json` (#142)
- added new option `copyAttachments` (#143)
- better support for playwright multiple reports generation:
- added new option `copyAttachments` to copy attachments for reporter (#143)
- updated default `outputFile` to `./monocart-report/index.html` from `./test-results/report.html`

* 2.7.1
- fixed custom raw dir for merging coverage
Expand Down
65 changes: 24 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
['list'],
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html'
outputFile: './monocart-report/index.html'
}]
]
};
Expand All @@ -89,26 +89,9 @@ Playwright Docs [https://playwright.dev/docs/test-reporters](https://playwright.
## Output
- path-to/your-filename.html
Single HTML file (data compressed), easy to transfer/deploy or open directly anywhere
> Note: Test attachments (screenshots images/videos) are not included but linked with relative path in report. All attachments will be found in [playwrightConfig.outputDir](https://playwright.dev/docs/api/class-testconfig#test-config-output-dir)
```js
// playwright.config.js
// attachments outputDir and report outputFile used same folder
const date = new Date().toISOString().slice(0, 10); //2022-10-10
const outputDir = `./test-results/${date}`;
module.exports = {
outputDir: outputDir,
reporter: [
['monocart-reporter', {
name: `My Test Report ${date}`,
outputFile: `${outputDir}/index.html`
}]
]
};
// deploy the folder to your report site and easy checking online
// http://your.report.site/test-results/2022-10-10
```
> Note: All attachments (screenshots images/videos) will be linked with relative path in report.
- path-to/your-filename.json
Separated metadata file (Already included in the above HTML and compressed, it can be deleted). Can be used for debugging or custom data collection.
Separated data file which can be used for debugging or data provider (It's included in the above HTML and compressed).

## Reporter Options
```js
Expand All @@ -117,7 +100,7 @@ Separated metadata file (Already included in the above HTML and compressed, it c
name: '',

// the output file path (relative process.cwd)
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',

// attachment path handler
attachmentPath: null,
Expand All @@ -140,7 +123,7 @@ Separated metadata file (Already included in the above HTML and compressed, it c

// trend data handler
trend: null,
// trend: () => './test-results/report.json',
// trend: () => './monocart-report/index.json',

// custom tags style
tags: null,
Expand Down Expand Up @@ -185,15 +168,15 @@ The server add the http header `Access-Control-Allow-Origin: *` to [allow reques
```sh
npx monocart show-report <path-to-report> --ssl <path-to-key,path-to-cert>
```
For example: `npx monocart show-report test-results/index.html --ssl ssl/key.pem,ssl/cert.pem`
For example: `npx monocart show-report monocart-report/index.html --ssl ssl/key.pem,ssl/cert.pem`

You can create and install local CA with [mkcert](https://mkcert.dev)
- Using your own trace viewer url with option `traceViewerUrl`:
```js
// reporter options
{
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
// defaults to 'https://trace.playwright.dev/?trace={traceUrl}'
traceViewerUrl: 'https://your-own-trace-viewer-url/?trace={traceUrl}'
}
Expand Down Expand Up @@ -228,7 +211,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',

// custom columns
columns: (defaultColumns) => {
Expand Down Expand Up @@ -270,7 +253,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
columns: (defaultColumns) => {

// duration formatter
Expand Down Expand Up @@ -308,7 +291,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
columns: (defaultColumns) => {
const locationColumn = defaultColumns.find((column) => column.id === 'location');
locationColumn.searchable = true;
Expand Down Expand Up @@ -413,7 +396,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
mermaid: {
// mermaid script url, using mermaid CDN: https://www.jsdelivr.com/package/npm/mermaid
scriptSrc: 'https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js',
Expand Down Expand Up @@ -494,7 +477,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
visitor: (data, metadata) => {
// [MCR-123] collect data from the title
const matchResult = metadata.title.match(/\[(.+)\]/);
Expand Down Expand Up @@ -524,7 +507,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
visitor: (data, metadata) => {
// collect data from the annotations
if (metadata.annotations) {
Expand All @@ -547,7 +530,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
visitor: (data, metadata) => {
const mySecrets = [process.env.PASSWORD, process.env.TOKEN];
mySecrets.forEach((secret) => {
Expand Down Expand Up @@ -588,7 +571,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
tags: {
smoke: {
style: {
Expand All @@ -612,7 +595,7 @@ module.exports = {
['list'],
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
tags: {
// ...
},
Expand Down Expand Up @@ -656,7 +639,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html'
outputFile: './monocart-report/index.html'
}]
]
};
Expand Down Expand Up @@ -723,9 +706,9 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
// connect previous report data for trend chart
trend: './test-results/report.json'
trend: './monocart-report/index.json'
}]
]
};
Expand All @@ -741,7 +724,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
// connect previous report data for trend chart
trend: async () => {
const previousReportData = await readDataFromSomeWhere("path-to/report.json");
Expand Down Expand Up @@ -778,7 +761,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
// global coverage report options
coverage: {
entryFilter: (entry) => true,
Expand Down Expand Up @@ -992,7 +975,7 @@ module.exports = {
['list'],
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
state: {
data: {
count: 0
Expand Down Expand Up @@ -1060,7 +1043,7 @@ module.exports = {
['list'],
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
state: {
onReceive: function(message) {
const test = this.getTest(message.testId);
Expand Down Expand Up @@ -1149,7 +1132,7 @@ module.exports = {
reporter: [
['monocart-reporter', {
name: "My Test Report",
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',
// async hook after report data generated
onEnd: async (reportData, helper) => {
// console.log(reportData.summary);
Expand Down
4 changes: 2 additions & 2 deletions lib/default/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = () => ({
name: '',

// the output html file path (relative process.cwd)
outputFile: './test-results/report.html',
outputFile: './monocart-report/index.html',

// whether to copy attachments to the reporter output dir, defaults to true
// it is useful when there are multiple html reports being output.
Expand Down Expand Up @@ -34,7 +34,7 @@ module.exports = () => ({

// trend data handler
trend: null,
// trend: () => './test-results/report.json',
// trend: () => './monocart-report/index.json',

// custom tags style
tags: null,
Expand Down
2 changes: 1 addition & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export type MonocartReporterOptions = {

/** trend data handler: https://github.com/cenfun/monocart-reporter?#trend-chart
* ```js
* trend: () => './test-results/report.json'
* trend: () => './monocart-report/index.json'
* ```
*/
trend?: string | (() => Promise<string | any>);
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Util = {

// end with html
if (!outputFile.endsWith('.html')) {
outputFile = path.join(outputFile, 'report.html');
outputFile = path.join(outputFile, 'index.html');
}

return path.resolve(outputFile);
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ module.exports = {
}],
['html', {
outputFolder: '../.temp/html',
outputFile: 'results.html',
open: 'never'
}],
['junit', {
outputFile: '../.temp/junit/results.xml'
}],

// ['monocart-reporter']
['monocart-reporter', {
name: 'My Test Report',
Expand Down

0 comments on commit 194d625

Please sign in to comment.