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

defineConfig doesn't work properly #764

Closed
6 tasks done
pd4d10 opened this issue Feb 16, 2022 · 1 comment · Fixed by #765
Closed
6 tasks done

defineConfig doesn't work properly #764

pd4d10 opened this issue Feb 16, 2022 · 1 comment · Fixed by #765

Comments

@pd4d10
Copy link
Contributor

pd4d10 commented Feb 16, 2022

Describe the bug

Although defineConfig has been implemented by #749, it doesn't seem to work properly because of runtime limitations.

import { defineConfig } from 'vitest' would throw an error as follows:

      throw new Error("Vitest was initialized with native Node instead of Vite Node");
            ^

Error: Vitest was initialized with native Node instead of Vite Node

Perhaps we could change the API to

- import { defineConfig } from 'vitest'
+ import { defineConfig } from 'vitest/node'

and leave vitest as the entry point for testing runtime purposes.

Reproduction

Set vitest.config.mjs as this doc describes

System Info

System:
    OS: macOS 12.2.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 238.73 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nn/current/bin/node
    Yarn: 1.22.17 - ~/.nn/current/bin/yarn
    npm: 8.1.0 - ~/.nn/current/bin/npm
  Browsers:
    Chrome: 98.0.4758.102
    Firefox: 90.0.2
    Safari: 15.3
  npmPackages:
    @vitejs/plugin-legacy: ^1.6.4 => 1.7.1
    @vitejs/plugin-react: ^1.2.0 => 1.2.0
    vitest: ^0.3.5 => 0.3.5

Used Package Manager

pnpm

Validations

@antfu
Copy link
Member

antfu commented Feb 16, 2022

vitest/node looks good to me. PR welcome!

pd4d10 added a commit to pd4d10/vitest that referenced this issue Feb 16, 2022
chaii3 pushed a commit to chaii3/vitest that referenced this issue May 13, 2022
Co-authored-by: webfansplz <>
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants