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

process.chdir is not available in workers #566

Closed
NullVoxPopuli opened this issue Jan 17, 2022 · 5 comments
Closed

process.chdir is not available in workers #566

NullVoxPopuli opened this issue Jan 17, 2022 · 5 comments

Comments

@NullVoxPopuli
Copy link

Describe the bug

if you're testing node utilities, maybe ones that help interact with the file system, and you need to call chdir, there is no way to test that behavior because all tests run in node workers, which aren't allowed to call process.chdir

Reproduction

it('repro', () => {
  process.chdir('anywhere')
}

raises:

TypeError: process.chdir() is not supported in workers

Is there a way to opt certain tests to not run in a worker?
otherwise I'd need to test anything that uses chdir, in mocha or something.

System Info

System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (6) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Memory: 7.69 GB / 16.18 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 16.13.2 - ~/.volta/tools/image/node/16.13.2/bin/node
    Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
    npm: 7.24.2 - ~/Development/NullVoxPopuli/ember-apply/node_modules/.bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Firefox: 96.0


### Used Package Manager

yarn

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitest-dev/vitest/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitest.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitest-dev/vitest/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions) or join our [Discord Chat Server](https://chat.vitest.dev).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
@antfu
Copy link
Member

antfu commented Jan 18, 2022

Then you might want to mock it, or use --threads to disable workers.

@Demivan
Copy link
Member

Demivan commented Jan 27, 2022

@antfu Would it be a good idea to have a comment that disables workers just for one file?

@NullVoxPopuli
Copy link
Author

mocking isn't really an option because I need to do more file operations (not in my repo, but in external monorepos).

I'll have to tried --threads 🤔

@Demivan
Copy link
Member

Demivan commented Jan 27, 2022

It is --threads=false or --no-threads

@NullVoxPopuli
Copy link
Author

aight, I'm happy with that -- things seem to be moving along now :D

chaii3 pushed a commit to chaii3/vitest that referenced this issue May 13, 2022
…r`. (vitest-dev#567)

Adds a few feature to allow users to configure error handling if they so choose. Without this feature, any error from the source observable would be treated as "unhandled" by RxJS, and thrown in a new call stack.

Resolves vitest-dev#566
@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

No branches or pull requests

4 participants