Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] Error in terminal when running tests #160

Closed
Aroot42 opened this issue Nov 7, 2024 · 7 comments
Closed

[Help] Error in terminal when running tests #160

Aroot42 opened this issue Nov 7, 2024 · 7 comments

Comments

@Aroot42
Copy link

Aroot42 commented Nov 7, 2024

Hi, I can have Cenfun.

I ran into a problem when I run tests, and there is already data in the reports folder.
image
-When I run through Test Explorer, I see an error in the console and the tests hang indefinitely. Need to restart IDE.
-When I run using the script, I see an error in the console, and the script launch is interrupted.

I tried version 2.8.4 and above and completely reinstalled all node modules.

Is there anything you can recommend solving this problem?

My Report config

            'monocart-reporter',
            {
                name: 'My Test Report',
                outputFile: './MonocartReport/Report.html',
                traceViewerUrl: 'https://trace.playwright.dev/?trace={traceUrl}',
                columns: (defaultColumns: any[]) => {
                    defaultColumns.splice(3, 0, {
                        id: 'azure',
                        name: 'Azure link',
                        width: 100,
                        searchable: true,
                        align: 'center',
                        styleMap: 'font-weight:normal;background:#f8f8f8;',
                        formatter: (v: any, rowItem: { [x: string]: any }, columnItem: { id: string | number }) => {
                            if (rowItem.type !== 'case') return '';

                            if (v) {
                                return v
                                    .split(',')
                                    .map(
                                        (key: any) =>
                                            `<a href="XXXX/_workitems/edit/${key}" target="_blank">${key}</a>`
                                    )
                                    .join(', ');
                            }
                            const key = rowItem[columnItem.id];
                            return `<XXXX/_workitems/edit/${key}" target="_blank">${v}</a>`;
                        },
                    });
                },

                visitor: (data: { azure: any }, metadata: { title: string; annotations: any[] }) => {
                    // [123] collect data from title
                    const matches = [...metadata.title.matchAll(/\[(\d+)]/g)].map((array) => array[1]);
                    if (matches.length > 0) data.azure = matches.join(',');
                },
                trend: () =>
                    new Promise<void>((resolve) => {
                        const fs = require('node:fs');
                        fs.readFile('./MonocartReport/Report.json', (error: any, data: string) => {
                            if (error) {
                                console.log(error);
                                resolve();
                                return;
                            }
                            const json = JSON.parse(data);
                            resolve(json);
                        });
                    }),
                tags: {
                    smoke: {
                        background: 'greey',
                    },
                    failed: {
                        background: '#d00',
                    },
                    flaky: {
                        background: 'orange',
                    },
                },
            },
        ],
@cenfun
Copy link
Owner

cenfun commented Nov 7, 2024

Could you please try latest version 2.9.8?
I can't figure out what the problem is base on the message and config you provided.
Guess that the problem is Monocart outputDir ./MonocartReport can not be removed.

  • try disable trend option
  • try use another directory: outputFile: './MonocartReport-new/Report.html'

@Aroot42
Copy link
Author

Aroot42 commented Nov 7, 2024

Already use 2.9.8.
The trend option is definitely the problem!!

  1. I tried to remove trend from the config and everything goes well
  2. I tried to add an intermediate folder for the trend in the path "./MonocartReport/Trend/Report.json" and it also helped. But the file with the trend still appeared in the "MonocartReport" folder.

@cenfun
Copy link
Owner

cenfun commented Nov 7, 2024

you forgot return in trend, try

trend: () => {
              return new Promise<void>((resolve) => {
                        
              }),
}

Or

trend: async () => {
              await new Promise<void>((resolve) => {
                        
              }),
}

@Aroot42
Copy link
Author

Aroot42 commented Nov 7, 2024

add async/await construction

trend: async () =>
                    await new Promise<void>((resolve) => {
                        const fs = require('node:fs');
                        fs.readFile('./MonocartReport/Report.json', (error: any, data: string) => {
                            if (error) {
                                console.log(error);
                                resolve();
                                return;
                            }
                            const json = JSON.parse(data);
                            resolve(json);
                        });
                    }),

it not helped

@cenfun
Copy link
Owner

cenfun commented Nov 7, 2024

Never mind, I made a mistake, your way of trend is correct, let me think about it

cenfun added a commit that referenced this issue Nov 7, 2024
@cenfun
Copy link
Owner

cenfun commented Nov 7, 2024

Could you please try monocart-reporter@2.9.9

@Aroot42
Copy link
Author

Aroot42 commented Nov 7, 2024

Everything seems to be working fine. I'll check it out for a couple more days.

@Aroot42 Aroot42 closed this as completed Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants