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

tests are broken due to cucumber runner or don't work #974

Open
GalacticHypernova opened this issue Oct 10, 2024 · 2 comments
Open

tests are broken due to cucumber runner or don't work #974

GalacticHypernova opened this issue Oct 10, 2024 · 2 comments

Comments

@GalacticHypernova
Copy link
Contributor

GalacticHypernova commented Oct 10, 2024

Environment


  • Operating System: Linux
  • Node Version: v20.15.1
  • Nuxt Version: 3.13.2
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: - <-- This isn't accurate, I have changed things, unsure if nuxi is just unable to pick it up
  • Runtime Modules: - <-- This isn't accurate, I have modules, unsure if nuxi is just unable to pick it up
  • Build Modules: -

Reproduction

I am unable to provide a reproduction for 2 main reasons:

  1. This is part of a production app, and I am willing to share it happening in real time privately
  2. It's inconsistent, as on Windows it fails completely and on Ubuntu it fails to run the e2e tests, so I can't even confirm it locally with a different configuration (I can provide the error it provides on Windows which causes it to abort even the initial test screen)

I can, however, provide the overall configuration and a sample of the tests:
nuxt.config.ts modules:

modules: ["@nuxt/content","@nuxt/ui", "@pinia/nuxt", "@nuxt/image", '@nuxt/test-utils/module', "@nuxtjs/i18n", "@nuxtjs/seo",
		"@nuxtjs/turnstile", "nuxt-security", "@nuxt/scripts", "@nuxt/fonts"],

vitest.config.mts:

import { defineVitestConfig } from '@nuxt/test-utils/config'
export default defineVitestConfig({
	test:{
		environment:'nuxt',
		hookTimeout:50000
	}
})

Sample of test/e2e/e2e.nuxt.test.ts:

import { expect, describe, it } from "vitest"
import {setup, $fetch, fetch, createPage} from "@nuxt/test-utils/e2e"
describe("app", async () => {
	await setup({
		server:true,
		runner: 'vitest',
		build:true,
		setupTimeout:300000
	}
	)
       describe("images", async () => {
		it("should return correct data for existent images", async () => {
			const {body, status, headers} = await fetch('/images/image.webp')
			expect(status).toBe(200)
			expect(headers.get("Content-Type")).toBe("image/webp")
		})
		it("should return 404 for non-existent images", async () => {
			const {body, status} = await fetch('/images/nonExistent.jpg')
			expect(status).toBe(404)
		})
	})
})

Describe the bug

The cucumber test runner appears to execute the tests despite runner option of the setup of e2e to 'vitest' (or trying to use the default). Maybe because of this and maybe because of a different, unseen cause, it simply breaks all e2e tests with the error I provided in the Logs section.

I believe this is part of a bigger issue which I have not unearthed yet that could also explain the respective failures on both environments

Additional context

Attempting to upgrade/reinstall the project's deps does not appear to help.
Unit tests are not affected by it, it affects only those that depend on the setup from the e2e section.

Logs

TypeError: The "chunk" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
 ❯ _build node_modules/nitropack/dist/nitro.mjs:2658:22
 ❯ node_modules/nuxt/dist/index.mjs:3630:5
 ❯ build node_modules/nuxt/dist/index.mjs:5778:3
 ❯ buildFixture node_modules/@nuxt/test-utils/dist/shared/test-utils.CaqvQLs_.mjs:121:3
    119|   const { After, AfterAll, Before, BeforeAll } = await import('@cucumber/cucumber');
    120|   BeforeAll({ timeout: hooks.ctx.options.setupTimeout }, hooks.setup);
    121|   Before(hooks.beforeEach);
       |   ^
    122|   After(hooks.afterEach);
    123|   AfterAll(hooks.afterAll);
 ❯ setup2 node_modules/@nuxt/test-utils/dist/shared/test-utils.CaqvQLs_.mjs:183:7
@GalacticHypernova GalacticHypernova changed the title cucumber runner interferes with vitest tests and breaks tests tests don't work or are broken Oct 15, 2024
Copy link
Contributor

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/app-vitest
👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/app-jest
👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/module

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@GalacticHypernova GalacticHypernova changed the title tests don't work or are broken tests are broken due to cucumber runner or don't work Oct 27, 2024
@GalacticHypernova
Copy link
Contributor Author

GalacticHypernova commented Oct 31, 2024

Hey @wattanx !

Unfortunately, as I stated in the issue, it is very inconsistent and I can't reliably make a full-fledged minimal reproduction. Would it be of any help if I contact you privately and share the behavior with the non-minimal reproduction, which is where it's observed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants