Skip to content

Support E2E tests within Cucumber ecosystem #697

@antoinezanardi

Description

@antoinezanardi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions