Open
Description
🚀 Feature Request
The removal of mount()
inside test.beforeEach()
and test.afterAll()
Example
This pattern:
const test = baseTest.extend({
mount({ mount }, use) {
return use((props) => mount(<Context><Button title="default_title" {...props} /></Context>));
}
});
test('ok', async ({ mount }) => {
const component = await mount({ title: 'override_title' });
await expect(component).toContainText('override_title');
});
Results in a way simpler testbase compared to:
let component;
let props = {};
test.beforeEach(async ({ mount }) => {
component = await mount(<Context><Button title="default_title" {...props} /></Context>);
props = {};
});
test('bad', async () => {
props = { title: 'override_title' };
await expect(component).toContainText('override_title');
});
Motivation
I've often seen that the use of test.beforeEach
and test.afterEach
in component testing creates an unmaintainable mess. Kent C. Dodds also discussed this in a blog post and introduced an ESLint rule to address this issue.
One of the great advantages of Playwright fixtures is how they can prevent this issue, so there is no need for an ESLint rule.