-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[Feature] Smarter spec files sharding / orchestration #10200
Comments
Any orchestrations are already possible in the user land. Say, for example, you have a set of spec files:
you can create a smart shard like this: // shard.spec.ts
// get a list of specs for the shard - fetch from server or any other way; read config from process.env...
const filenames = ['./a.spec.ts', 'd.spec.ts'];
for (const filename of filenames)
require(filename); This already looks pretty flexible to setup any kind of smart configuration! |
Thanks for your prompt response @aslushnikov! That's quite a flexible and creative approach - never realized it was possible! I've had a chance to play more with the concept and here are some questions / notes.
For example: function* getFilenames() {
yield './a.spec.ts';
yield './b.spec.ts';
}
async function main() {
for await (const filename of getFilenames()) {
require(filename);
}
}
main().catch(console.error); That's because when There are several workarounds I thought of:
Ideally, one could just
The suggested approach assumes invoking the next CLI command, if I got it right: npx playwright test ./tests/shard.spec.ts It's still tricky to explore all the spec files - i.e. they should be either explicitly listed or Also, how one can combine test filters with the suggested approach? I am imagining some kind of hook / plugins system that provides an execution context with:
and "feeds" the list of spec file to test runner, based on response from a remote service (any async operation, basically). P.S. Some approaches assume known # of machines, however often the amount of machines isn't deterministic - e.g. in CI environment that runs 100s of containers it's common to have several failed containers that never get to running actual tests. |
Yes, I'd suggest have a separate node script to generate shard and then run playwright test against that shard.
The following should give you a list of all the tests: npx playwright test --list --reporter=json |
👋🏻
Given a considerably large suite of tests, the aspect of efficient and consistent parallelization / sharding becomes important. In CI environment with multiple machines, an external service can provide an optimally sorted list of spec files for each CI agent - based on historical data, for example.
The proposal /request is to "democratize" the way test runner picks spec files, ideally incorporating some kind of plugins architecture, where one can implement different solutions for defining test suites selection and explicitly request the batch of next spec files to run.
I imagine that the agent-level implementation of parallelization can stay intact - i.e. each individual runner can keep its current behaviour.
Yes, I think the whole ecosystem would benefit from this feature, especially organizations with larger tests suites. As a disclaimer, my particular interest is caused based on involvement with sorry-cypress community. Organizations / communities would be able to implement custom plugins that use historical data to improve the overall duration, easily adopt playwright for larger scale projects.
The text was updated successfully, but these errors were encountered: