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

Regression: getViteConfig doesn't work after 4.9.3 release #11221

Closed
vchirikov opened this issue Jun 9, 2024 · 7 comments · Fixed by #11231
Closed

Regression: getViteConfig doesn't work after 4.9.3 release #11221

vchirikov opened this issue Jun 9, 2024 · 7 comments · Fixed by #11231
Assignees
Labels
- P2: has workaround Bug, but has workaround (priority) regression

Comments

@vchirikov
Copy link

vchirikov commented Jun 9, 2024

Astro Info

4.9.2 - works
4.9.3+ (tested on 4.10.1) doesn't

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Regression: getViteConfig is broken after 4.9.3+ (including the latest 4.10.1) and doesn't return the correct config to vitest.

In the gif I showed that the regression:

getViteConfig works fine (it returns correct environment to vitest) and doesn't work at 4.10.1
(ReferenceError: document is not defined shows us that vitest's environment is not defined, I also re-checked this with // @vitest-environment happy-dom)

bug

the vitest.config.ts:

/// <reference types="vitest" />

import { getViteConfig } from 'astro/config';

export default getViteConfig({
  test: {
    testTimeout: 10_000,
    css: false,
    globals: false,
    environment: 'happy-dom',
    include: ['./tests/**/*.test.{ts,tsx}'],
    setupFiles: [
      '@testing-library/react/dont-cleanup-after-each',
      './tests/vitest.setup.ts'
    ],
    pool: 'threads',
    poolOptions: {
      threads: {
        isolate: false,
        minThreads: 4,
      }
    },
    isolate: false,
    typecheck: {
      enabled: true,
      tsconfig: 'tsconfig.json',
    }
  },
}, {
  site: 'http://localhost:3000/base',
},
);

Repro

https://github.com/vchirikov/astro_issue_11221

What's the expected result?

getViteConfig returns the correct config with defined environment

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jun 9, 2024
@vchirikov
Copy link
Author

Related issues & PRs:

#11175
#11194

@ematipico ematipico added the needs repro Issue needs a reproduction label Jun 10, 2024
Copy link
Contributor

Hello @vchirikov. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Jun 10, 2024
vchirikov added a commit to vchirikov/astro_issue_11221 that referenced this issue Jun 10, 2024
@vchirikov
Copy link
Author

@ematipico added repository with repro - https://github.com/vchirikov/astro_issue_11221

@ematipico ematipico added - P3: minor bug An edge case that only affects very specific usage (priority) regression and removed needs repro Issue needs a reproduction labels Jun 10, 2024
@ematipico ematipico self-assigned this Jun 10, 2024
@Baztoune
Copy link

I'm not 100% sure the issue I encountered is the exact same, but it looks related. The vite config seems ignored, at least the include and exclude properties.
I started a minimal reproduction from the officiel with-vitest example on stackblitz

For this purpose, I defined a include config with specific **/*.omg.ts glob pattern and renamed the test file as basic.omg.ts.
npm install && npm run test runs tests in 4.9.3 ✅ , but ignores it in 4.10.1 ❌ . Could it be linked to #11194 ?

Please tell me if you need more info, or if I missed something.

@Baztoune
Copy link

Baztoune commented Jun 10, 2024

As a side note, passing my config as the 2nd arg gives me the expected result, but I don't think this is intended. According to #11194 only inlineConfig.root is used, so other properties might just be ignored ?

// this actually uses the test config
export default getViteConfig(
  {},
  {
    vite: {
      test: {
        include: ['**/*.omg.ts'],
      },
    },
  }
);

@vchirikov
Copy link
Author

Yep, but according the docs we should use the first arg. For now I use the same workaround:

import { getViteConfig, type ViteUserConfig } from 'astro/config';

// ...
const config = {
  test: { /* the actual vitest config*/} 
} satisfies { test: ViteUserConfig['test']; };

export default getViteConfig(
  { ...config },
  { vite: { ...config }},
);

@ematipico ematipico added - P2: has workaround Bug, but has workaround (priority) and removed - P3: minor bug An edge case that only affects very specific usage (priority) labels Jun 10, 2024
@Baztoune
Copy link

Baztoune commented Jun 11, 2024

Yep, but according the docs we should use the first arg.

Absolutely, I just wanted to emphase that the 2 args got mixed up in the quoted PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants