-
Notifications
You must be signed in to change notification settings - Fork 111
Support E2E tests within Cucumber ecosystem #697
Description
Describe the feature
🚀 Why This Feature?
Nuxt Test Utils provides a variety of tools for conducting End-to-End (E2E) tests with playwright and a chosen test runner (currently vitest or jest). While this is a valuable capability, I believe it could be enhanced further by integrating support for Cucumber.
Here's the challenge: to initiate a Nuxt server for E2E tests, you typically invoke the setup() method from the test-utils/e2e Nuxt package, as documented here. In essence, this function determines your test runner and associates specific actions with different hooks (e.g., starting the server in beforeAll, closing the connection in afterAll, etc.).
The issue is that using this method outside of a test runner ecosystem (jest or vitest) is problematic because it cannot locate the necessary hooks to attach the functions to.
🧠 How to Implement It?
I propose exposing the various functions called by setup() and manually invoking them in the framework of your choice, such as Cucumber. For instance, you could do something like this in TypeScript:
// This is the Before hook of Cucumber
Before(async function(this: CustomWorld): Promise<void> {
// Create a Playwright Test Context with desired options
const context = createTestContext({});
await startServer(context);
// Use the Playwright API in Cucumber step definitions
this.page = await createPage("/");
});I'm unsure if this is already achievable. Regardless, I haven't come across any relevant implementations of nuxt3 + playwright + cucumber.
🔍 Reproduction Repository
You can test my setup in my repository by running the npm run test:cucumber command.
I'd be delighted to assist in building this feature. If it's already possible or implemented differently, I'd appreciate the opportunity to document it in the Nuxt documentation.
Additional information
- Would you be willing to help implement this feature?
- Could this feature be implemented as a module?
Final checks
- Read the contribution guide.
- Check existing discussions and issues.