Closed Sid200026 closed 3 weeks ago
Today, you can have one globalSetup
file that imports all the others:
// project-specific-global-setup.ts
import "./database/global-setup"
import "./base/global-setup"
Does this help solve your pain point? If not, what makes this existing solution suboptimal?
// setup.ts
import setupDatabase from "./database-setup";
import setupBase from "./base-setup";
export default () => {
setupDatabase();
setupBase();
}
This is what users have to do currently, create a single setup file and call the respective setup/teardown methods (these methods can come from any type of file, does not need to be a file with a default export).
This presents another problem during teardown. Suppose I have 4 different teardown methods that does independent cleanups. Now the user is responsible for ensuring that if one of the teardown method fails, the others still continue, by adding try catch blocks. Ideally here, since these are independents, if playwright allows customers to pass multiple files, an end user does not need to worry about handling failures so that other tasks can proceed.
globalTeardown: [
'./database/global-teardown',
'./base/global-teardown',
'./users/global-teardown',
'./infra/global-teardown'
]
Secondly, we want to eliminate the pain of developers having to add base setup/teardown files manually inside the test suite's setup/teardown file and worry about ordering of function calls, error handling, etc.
🚀 Feature Request
Allow globalSetup and globalTeardown properties to take in multiple files as input, thus customers can have multiple global setup and teardown files specified in their playwright configuration.
Example
Motivation