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

feat: support playwright in gui mode #571

Merged
merged 1 commit into from
Jul 11, 2024
Merged

Conversation

DudaGod
Copy link
Member

@DudaGod DudaGod commented Jul 9, 2024

What is done

  • write adapters for playwright tool in order to support gui mode

}

export const DEFAULT_BROWSER_ID = 'chromium';
const DEFAULT_SNAPSHOT_PATH_TEMPLATE = '{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}{-snapshotSuffix}{ext}';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default value I get from pwt source code. And it is not exported outside.


constructor(config: PwtConfig) {
this._config = config;
this._browserIds = _.isEmpty(this._config.projects) ? [DEFAULT_BROWSER_ID] : this._config.projects.map(prj => prj.name).filter(Boolean);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the user does not specify the browser in the projects section then chromium will be used by default. So I support this behaviour.

}

get tolerance(): number {
return 2.3;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default value in order to use in looks-same (when click on Find same diffs in UI)

}

get antialiasingTolerance(): number {
return 4;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same as above

lib/adapters/config/playwright.ts Show resolved Hide resolved
lib/adapters/tool/playwright/index.ts Show resolved Hide resolved
return new Promise((resolve, reject) => {
const args = ([] as string[]).concat(prepareRunArgs(tests, this._configPath, this._haveProjectsInConfig), runArgs);
const child = spawn(this._pwtBinaryPath, args, {
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ipc in order to communicate between special reporter which is started inside pwt and html-reporter process.

browserNames.add(browserName);
}

const args = ['test', '--reporter', path.resolve(__dirname, './reporter'), '--config', configPath];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use my custom reporter to handle results from pwt.

titlePath: string[];
};

export default class MyReporter implements Reporter {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reporter which is used to get info about test results

@@ -0,0 +1,36 @@
import stringify from 'json-stringify-safe';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data from pwt has circular links which I can't pass between processes

Copy link
Member

@shadowusr shadowusr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! Can't imagine what you had to go through to make this work, respect =)

⚠️ I see that E2E workflow is skipped once again in this PR. Please run it locally.

Ideally, it would be really nice and I think logical to turn on the same GUI tests that we have for testplane for playwright also: https://github.com/gemini-testing/html-reporter/tree/master/test/func/tests/common-gui

test/unit/lib/adapters/config/playwright.ts Show resolved Hide resolved
lib/cli/commands/remove-unused-screens/index.js Outdated Show resolved Hide resolved
lib/cli/commands/merge-reports.js Outdated Show resolved Hide resolved
lib/adapters/tool/playwright/index.ts Show resolved Hide resolved
lib/adapters/tool/playwright/index.ts Show resolved Hide resolved
const args = ['test', '--reporter', path.resolve(__dirname, './reporter'), '--config', configPath];

if (testNames.size > 0) {
args.push('--grep', Array.from(testNames).join('|'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work fine if test name contains brackets, etc or do we need additional escaping?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I forgot to check it. I will fix it.

lib/adapters/tool/playwright/index.ts Outdated Show resolved Hide resolved
lib/adapters/tool/playwright/index.ts Outdated Show resolved Hide resolved
lib/adapters/tool/playwright/ipc.ts Show resolved Hide resolved
lib/adapters/config/playwright.ts Show resolved Hide resolved
@DudaGod DudaGod force-pushed the TESTPLANE-56.pwt_support_gui branch from d3afe96 to 882ad47 Compare July 11, 2024 20:45
@DudaGod DudaGod merged commit c721955 into master Jul 11, 2024
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants