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: add hub test env as well as supporting nuxt test option #429

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

atinux
Copy link
Contributor

@atinux atinux commented Jan 21, 2025

This will help when working with tests so NuxtHub will use another dataset, useful to avoid writing on the development database.

Options to enable the hub test env:

  • NUXT_HUB_ENV=test
  • nuxi dev --hub-env test
  • Running the dev server within Vitest with:
// basic.test.ts
import { fileURLToPath } from 'node:url'
import { describe } from 'vitest'
import { setup, $fetch } from '@nuxt/test-utils/e2e'

describe('test env', async () => {
  await setup({
    rootDir: fileURLToPath(new URL('..', import.meta.url)),
    dev: true
  })
  // ...
})

Copy link

pkg-pr-new bot commented Jan 21, 2025

Open in Stackblitz

npm i https://pkg.pr.new/nuxt-hub/core/@nuxthub/core@429

commit: 1b1906e

Copy link

Deploying playground with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1b1906e
Status: ✅  Deploy successful!
Preview URL: https://c0239c12.playground-bhb.pages.dev
Branch Preview URL: https://feat-test-env.playground-bhb.pages.dev

View logs

@acidjazz
Copy link

Open in Stackblitz

npm i https://pkg.pr.new/nuxt-hub/core/@nuxthub/core@429

commit: 1b1906e

tested locally and working amazingly

@atinux atinux merged commit 2097df2 into main Jan 22, 2025
9 checks passed
@atinux atinux deleted the feat/test-env branch January 22, 2025 10:01
@marcmascarell
Copy link

Hello! This change/addition "broke" my dev env.

In my .env I have:
NUXT_HUB_ENV=development

In my package.json scripts:
"postinstall": "nuxt prepare"

Previous to this change, I could do npm install. After this change I see the error: Invalid hub environment, should be test, preview or production

My question now is if this is expected and if it is, what is the recommended way to fix it since does not seem like I can do the postinstall anymore with development env.

What I would expect is to keep being able to install npm dependencies having development as env.

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

Successfully merging this pull request may close these issues.

3 participants