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

The "setup" in the tests is very slow for every rerun #314

Open
enkot opened this issue Oct 19, 2022 · 7 comments
Open

The "setup" in the tests is very slow for every rerun #314

enkot opened this issue Oct 19, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@enkot
Copy link
Contributor

enkot commented Oct 19, 2022

Environment

  • Operating System: Linux
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.12
  • Nitro Version: 0.6.0
  • Package Manager: npm@7.17.0
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/nuxt-framework-zehqm6

Describe the bug

The empty await setup({}) in the tests takes ~4 seconds for every rerun in watch mode in the empty project.
Please, check the reproduction, try to run npm test.

Additional context

No response

Logs

No response

@enkot enkot changed the title The "setup" in the tests is very slow The "setup" in the tests in "watch" mode is very slow Oct 19, 2022
@enkot enkot changed the title The "setup" in the tests in "watch" mode is very slow The "setup" in the tests is very slow for every rerun Oct 19, 2022
Copy link
Member

I think @antfu was working on a PR to avoid restarting/rebuilding Nuxt when rerunning tests.

Also relevant: nuxt/framework#4578.

@danielroe danielroe added enhancement New feature or request and removed enhancement New feature or request labels Oct 19, 2022 — with Volta.net
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
@fabis94
Copy link

fabis94 commented Jul 3, 2023

Besides not re-building on every test (re-)run it would be even better if server could be re-built separately if only server-side code changed (e.g. an API) 🙃

@fabis94
Copy link

fabis94 commented Jul 3, 2023

In either case, eagerly awaiting for a change here, cause otherwise running tests is pretty painful atm

@danielroe danielroe transferred this issue from nuxt/nuxt Nov 6, 2023
@danielroe danielroe transferred this issue from nuxt/test-utils Dec 2, 2023
@KarelVendla
Copy link

KarelVendla commented Mar 7, 2024

@danielroe Is it possible to have a dev. instance running & to use that as the "server" for the e2e tests? I don't really care about building all the time as the built version will run in the pipeline anyway . It would be nice to skip "building" and just to use the "npm run dev" server I have running.

@nWacky
Copy link

nWacky commented Apr 1, 2024

Is it possible to have a dev. instance running & to use that as the "server" for the e2e tests?

I managed to avoid rebuilding every time by building into .output/output

npm run build
mv .output .output1 && mkdir .output && mv .output1 .output/output

And then setting output directory to .output

// playwright.config.ts
export default defineConfig<ConfigOptions>({
  use: {
    nuxt: {
      build: false,
      buildDir: ".output",
      rootDir: fileURLToPath(new URL(".", import.meta.url)),
    },
  },
})

For now nuxt always sets nitro.output.dir to buildDir/output and starts a server from buildDir/output

npx playwright test is using an existing build after this

@linspw
Copy link

linspw commented Apr 9, 2024

You are amazing @nWacky !
I only adjusted to doesn't need mv command:

export default defineConfig<ConfigOptions>({
  use: {
    nuxt: {
      build: false,
      buildDir: '.output',
      nuxtConfig: {
        nitro: {
          output: {
            dir: '.output',
          },
        },
      },
      rootDir: fileURLToPath(new URL('.', import.meta.url)),
    },
})

@linspw
Copy link

linspw commented Apr 10, 2024

Wrapping nuxt setup:
Be Happy

OBS: The test now takes 5 seconds, previously it took around 50 seconds

import { setup } from '@nuxt/test-utils/e2e'
import type { TestOptions } from '@nuxt/test-utils/e2e'

export const setupNuxt = (options?: Partial<TestOptions>) => {
  return setup({
    build: false,
    buildDir: '.output',
    nuxtConfig: {
      nitro: {
        output: {
          dir: '.output',
        },
      },
    },
    ...options
  })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants