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

Unhandled error when configure setupFiles #1346

Closed
6 tasks done
sabertazimi opened this issue May 21, 2022 · 4 comments · Fixed by #1347
Closed
6 tasks done

Unhandled error when configure setupFiles #1346

sabertazimi opened this issue May 21, 2022 · 4 comments · Fixed by #1347

Comments

@sabertazimi
Copy link
Contributor

Describe the bug

With vitest.config.ts:

import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    globals: true,
    setupFiles: 'setupTests.ts',
  },
});

get unhandled error:

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: Cannot read properties of undefined (reading 'length')
    at normalize (file:///home/sabertaz/git/OJs/node_modules/vitest/dist/chunk-utils-global.2fab7e5c.js:79:13)
    at file:///home/sabertaz/git/OJs/node_modules/vitest/dist/chunk-vite-node-externalize.fc385bba.js:10032:74
    at Array.map (<anonymous>)
    at resolveConfig (file:///home/sabertaz/git/OJs/node_modules/vitest/dist/chunk-vite-node-externalize.fc385bba.js:10032:60)
    at Vitest.setServer (file:///home/sabertaz/git/OJs/node_modules/vitest/dist/chunk-vite-node-externalize.fc385bba.js:10315:22)
    at Object.configureServer (file:///home/sabertaz/git/OJs/node_modules/vitest/dist/chunk-vite-node-externalize.fc385bba.js:10958:19)
    at createServer (/home/sabertaz/git/OJs/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:59950:41)
    at async createVitest (file:///home/sabertaz/git/OJs/node_modules/vitest/dist/chunk-vite-node-externalize.fc385bba.js:10984:18)
    at async startVitest (file:///home/sabertaz/git/OJs/node_modules/vitest/dist/chunk-vite-node-externalize.fc385bba.js:11071:15)
    at async start (file:///home/sabertaz/git/OJs/node_modules/vitest/dist/cli.js:665:9)

When change setupTests.ts to ./setupTests.ts, it works correctly.

Reproduction

System Info

System:
    OS: Linux 5.13 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 2.71 GB / 7.65 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    Yarn: 3.2.1 - ~/.nvm/versions/node/v16.15.0/bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
  Browsers:
    Firefox: 100.0
  npmPackages:
    vitest: ^0.12.8 => 0.12.8

Used Package Manager

yarn

Validations

@sheremet-va
Copy link
Member

@nieyuyao maybe we should check that it resolved correctly and show an error, if file not found?

@sheremet-va
Copy link
Member

Not sure setupTests.ts should be allowed. I would prefer throwing an error with a hint on how to fix it, if file is not found. Because you might mistyped it, and you will have a rough evening debugging it :P

@sheremet-va
Copy link
Member

You know, I remembered that it will actually fail when importing, so we don't need to throw error here. I think we can actually merge your PR.

@nieyuyao
Copy link
Contributor

nieyuyao commented May 21, 2022

@sheremet-va I think it needs to be fixed because it was supported before 1312. 🤔 so this pr looks good.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 17, 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.

3 participants