jest-community / vscode-jest

The optimal flow for Jest based testing in VS Code
MIT License
2.82k stars 291 forks source link

[BUG] Crash when running any command from the command palette #1131

Closed jwverzijden closed 3 months ago

jwverzijden commented 3 months ago

Describe the bug I installed the extension, it immediately started testing some tests, not all, this is curious but not really the issue I want to point out. I ran all tests manually, by selecting "run all tests" in the Command Palette, but my user session crashed and I had to log in again, not sure how that happened but it is very consistent. Activating any command related to this extension will crash my user session.

To Reproduce Steps to reproduce the behavior:

  1. ctrl+shift+p
  2. select "run all tests"
  3. screen turns black, comes back on, my user is logged off, log back in and all applications have been closed, not just vscode, everything is closed.

Note: A sample repo will help us identify the bug much faster. 🙏 I made a new project to test if it is the configuration in the big project. I only added jest and 1 test, see codeblock below, click "run all tests" in the command palette, immediate crash. However I can run this test in the terminal with jest no issue.

const { test, describe, expect } = require('@jest/globals');
describe('describe', () => {
    test('test', () => {
        expect(true).toBe(true);
    });
});

Expected behavior I expected

  1. the tests to run
  2. in case of an error or problem that no applications exit, not even vscode
  3. the error/problem is reported. Exiting my user session is not acceptable error handling.

Environment (please complete the following information):

Prerequisite

Additional context I'm not sure how to get more information on the crash, all applications are closed by the time I log back into my account. I don't really understand what happens here, I have never seen an application crash the entire user session like this, for example when my display driver crashes I stay logged in and can see what caused it when the driver restarts.

Maybe I'm just overlooking something but at the moment to me it feels like something is wrong with the extension.

connectdotz commented 3 months ago

@jwverzijden, thank you for bringing this issue to our attention. Although I couldn't replicate the crash (on MacOS), I did notice that the "Jest: Run All Tests" command isn't functioning as expected. Sorry about that, I will patch the command ASAP.

Here are a few observations/suggestions:

  1. It seems you might still be using an older version (v6.2.2). I recommend upgrading to the latest version of vscode-jest, v6.2.3, which resolves a focus issue potentially related to the crash you experienced.
  2. Concerning your startup experience, where "it immediately started testing some tests, not all...,". This behavior is controlled by the extension's jest.runModes setting. By default, it is set to "watch" mode, which launches Jest with the --watch option to automatically run tests related to code changes. If you prefer a more on-demand style experience, you can easily change it through the UI or by updating settings.json.
  3. As you're new to the extension, you might find the Getting Started section helpful. It introduces some common operations and insights on how to tailor the test environment to your preferences.
  4. For running tests, you might prefer the more intuitive approach of using the interactive UI instead of the command palette. For more information, please see the User Interface section.

Please let me know if updating and using the UI to run tests doesn't resolve the issue, or if you need further assistance.

jwverzijden commented 3 months ago

It seems this was the cause of the crash, it is not happening anymore with 6.2.3. Thanks for fixing it so quickly.