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

Can not test the import hook of nodejs #7078

Closed
6 tasks done
snowyu opened this issue Dec 13, 2024 · 1 comment
Closed
6 tasks done

Can not test the import hook of nodejs #7078

snowyu opened this issue Dec 13, 2024 · 1 comment

Comments

@snowyu
Copy link

snowyu commented Dec 13, 2024

Describe the bug

https://nodejs.org/api/module.html#customization-hooks

the vitest transform the import and raise error.

/* @vite-ignore */ can not work.

Error: Failed to parse source for import analysis because the content contains invalid JS syntax. You may need to install appropriate plugins to handle the .zip file format, or if it's an asset, add "**/*.zip" to `assetsInclude` in your configuration.
  Plugin: vite:import-analysis

I have to use the pure js to test

node --import ./dist/index.js test/loader.test.js

Reproduction

https://github.com/isdk/node-zip-loader.js/

System Info

System:
    OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 113.44 GB / 125.70 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
    pnpm: 9.13.2 - ~/.local/share/pnpm/pnpm
  Browsers:
    Chrome: 131.0.6778.108
  npmPackages:
    vite: ^5.4.9 => 5.4.9 
    vitest: ^2.1.3 => 2.1.3

Used Package Manager

npm

Validations

@hi-ogawa
Copy link
Contributor

I don't think this can be supported in any intuitive way. Probably you can try execArgv https://vitest.dev/config/#pooloptions-forks-execargv to pass custom loader and external, but I don't think it can give effective testing for custom loader.

I would suggest using a different approach for custom loader testing.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants