Skip to content
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

Support accessing other fixtures in the fixture function when using test.extend #3626

Closed
4 tasks done
fenghan34 opened this issue Jun 20, 2023 · 1 comment · Fixed by #3651
Closed
4 tasks done

Support accessing other fixtures in the fixture function when using test.extend #3626

fenghan34 opened this issue Jun 20, 2023 · 1 comment · Fixed by #3651
Labels
enhancement New feature or request pr welcome

Comments

@fenghan34
Copy link
Contributor

Clear and concise description of the problem

This idea comes from the question by @outerlook.

When setting up fixtures in test.extend, we may dependent on other fixtures. Would be very useful to have this feature.

export const newTest = test.extend({
  server: async (use) => {
    const server = await startServer();
    await use(server);

    await server.destroy();
  },
  // client depends on server
  client: async (use, { server }) => {
    const client = await new Client({ apiUrl: server.apiUrl });
    await use(client);

    await client.destroy();
  }
});

Suggested solution

Make other fixtures accessible as the second argument of each fixture function.

Alternative

No response

Additional context

No response

Validations

@sheremet-va sheremet-va added enhancement New feature or request pr welcome labels Jun 20, 2023
@fenghan34
Copy link
Contributor Author

I'll submit a PR for this.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants