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

feat(playwright): expose _nuxtHooks fixture setup function #899

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

markbrockhoff
Copy link
Contributor

@markbrockhoff markbrockhoff commented Jul 19, 2024

Hi,

I just setup a mock server to mock third party requests made by my nuxt app while running tests with playwright.
In order to redirect those requests to the mock server I overwrote the _nuxtHooks playwright fixture with my own to modify the nuxt config, injecting the url to my mock server into it.

All of this works great but I'd like to keep using the original _nuxtHooks fixture if possible, just modifying the nuxt config passed to it before the app is built.
That's why I extracted it into an exported function so projects can easily modify the nuxt config used for the test app depending on their custom fixtures.

For example like this:

import { test as base, nuxtHooksFixture } from "@nuxt/test-utils/playwright";

export const test = base.extend({
  _nuxtHooks: [
    async ({ nuxt, otherFixture }, use) => {
        // Just imagine that some custom fixure `otherFixture` needs to define the port the nuxt app needs to use
        // By overwriting the _nuxtHooks fixture this is now easily possible.
        await nuxtHooksFixture({ ...nuxt, port: otherFixture.port });
    },
    { scope: "worker" },
  ],
});

Please let me know what you think :)

@markbrockhoff markbrockhoff requested a review from danielroe as a code owner July 19, 2024 14:45
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. enhancement New feature or request labels Jul 19, 2024
@markbrockhoff
Copy link
Contributor Author

markbrockhoff commented Jul 19, 2024

Btw: I think the CI pipeline might be broken or flaky as I don't really see a reason why the made change would cause that test to fail on windows and it's failing on main as well ^^'

@markbrockhoff markbrockhoff force-pushed the expose-nuxt-hooks-fixture branch 2 times, most recently from f5166fa to 412204b Compare July 29, 2024 06:57
@markbrockhoff markbrockhoff force-pushed the expose-nuxt-hooks-fixture branch from 412204b to 5d42df0 Compare August 14, 2024 07:14
@markbrockhoff markbrockhoff force-pushed the expose-nuxt-hooks-fixture branch from 5d42df0 to d121d42 Compare August 28, 2024 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant