Skip to content

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
  })
  // ...
})

@pkg-pr-new
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

@cloudflare-workers-and-pages
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.

4 participants