Skip to content

Commit

Permalink
Merge 97df410 into b257c32
Browse files Browse the repository at this point in the history
  • Loading branch information
connectdotz committed Jul 2, 2023
2 parents b257c32 + 97df410 commit 04ea92b
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Expand Up @@ -14,5 +14,8 @@
"eslint.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
},
"cSpell.words": [
"unmock"
],
}
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -254,6 +254,7 @@ Users can use the following settings to tailor the extension for their environme
|setting|description|default|example/notes|
|---|---|---|---|
|**Process**|
|enable|Enable/disable jest extension for the given workspace folder/virtual-folder|true|`"jest.enable": false`|
|[jestCommandLine](#jestCommandLine)|The command line to start jest tests|undefined|`"jest.jestCommandLine": "npm test --"` or `"jest.jestCommandLine": "yarn test"` or `"jest.jestCommandLine": "node_modules/.bin/jest --config custom-config.js"`|
|nodeEnv|Add additional env variables to spawned jest process|null|`"jest.nodeEnv": {"PORT": "9800", "BAR":"true"}` |
|[shell](#shell)|shell (path or LoginShell) for executing jest|null|`"jest.shell": "/bin/bash"` or `"jest.shell": "powershell"` or `"jest.shell": {"path": "/bin/bash"; args: ["--login"]}` |
Expand All @@ -270,7 +271,6 @@ useDashedArgs| Determine if to use dashed arguments for jest processes |undefine
|[coverageFormatter](#coverageFormatter)|Determine the coverage overlay style|"DefaultFormatter"|`"jest.coverageFormatter": "GutterFormatter"`|
|[coverageColors](#coverageColors)|Coverage indicator color override|undefined|`"jest.coverageColors": { "uncovered": "rgba(255,99,71, 0.2)", "partially-covered": "rgba(255,215,0, 0.2)"}`|
|**Misc**|
|enable|Enable/disable jest extension for the given workspace folder|true|`"jest.enable": false`|
|debugMode|Enable debug mode to diagnose plugin issues. (see developer console)|false|`"jest.debugMode": true`|
|disabledWorkspaceFolders 💼|Disabled workspace folders names in multi-root environment|[]|`"jest.disabledWorkspaceFolders": ["package-a", "package-b"]`|
|[autoRevealOutput](#autoRevealOutput)|Determine when to show test output|"on-run"|`"jest.autoRevealOutput": "on-exec-error"`|
Expand Down
108 changes: 108 additions & 0 deletions release-notes/release-note-v6.md
@@ -0,0 +1,108 @@
# vscode-jest v6.x Releases <!-- omit in toc -->

Release Notes
---
- [Release Notes](#release-notes)
- [v6.0.0 (pre-release)](#v600-pre-release)
- [Main Features](#main-features)
- [1. Virtual Folders](#1-virtual-folders)
- [2. Support spawning jest with dashed arguments](#2-support-spawning-jest-with-dashed-arguments)
- [3. control extension activation within each folder](#3-control-extension-activation-within-each-folder)
- [4. Auto clear output upon test run](#4-auto-clear-output-upon-test-run)
- [Fixes](#fixes)
- [CHANGELOG](#changelog)

---

## v6.0.0 (pre-release)

This major release introduces the 'Virtual Folders' feature. Much like a VSCode workspace folder, a 'Virtual Folder' allows you to manage a custom Jest runtime environment, each configurable with its own resource-level settings. This is particularly useful for projects with multiple Jest configurations or monorepo structures. While we've ensured backward compatibility, the introduction of 'Virtual Folders' involved significant internal changes that prompted a major version bump.

### Main Features
#### 1. Virtual Folders

Supporting multiple jest configs is a common use cases for monorepo projects and projects with multiple test environments, such as unit and integration tests. We introduced monorepo support with vscode multi-root workspaces a few years ago. While it works well for most use cases, it fell short for multi-test-environment that share the same code base (folder). This version will close this gap with the [Virtual Folders](README.md#virtualfolders).

For example, the unit vs. integration tests can now be set up as the following:
```json
// <project>/.vscode/settings.json
{
"jest.virtualFolders": [
{
"name": "unit-tests",
"jestCommandLine": "--config=jest.unit.config.js",
"autoRun": "watch"
},
{
"name": "integration-tests",
"jestCommandLine": "--config=jest.integration.config.js",
"autoRun": "off"
}
]
}
```

And yes you can indeed use virtual folders with monorepo projects. For example, the following configuration will run tests for each package in a monorepo project:
```json
// <project>/.vscode/settings.json
{
"jest.virtualFolders": [
{"name": "package1", "rootPath": "packages/package1"},
{"name": "package2", "rootPath": "packages/package2"}
]
}
```

So when to use multi-root workspaces vs. virtual folders? In short, if you created a multi-root workspace simply for running different jest config - you could probably just use `"jest.virtualFolders"` instead. If you do require different non-jest vscode settings for each folder, continue to use multi-root workspace. More details in [Virtual Folders](README.md#virtualfolders).


- [#1035](https://github.com/jest-community/vscode-jest/pull/1035) - @connectdotz

#### 2. Support spawning jest with dashed arguments

In light of Angular's decision to drop support for CamelCase arguments, we've been hearing a lot of you asking for a switch to dashed-arguments when running Jest commands. Therefore, a new optional setting `"jest.useDashedArgs"` is introduced.

However, bear in mind that you might encounter compatibility issue with other tools/systems. For instance, we've identified an issue in react-script where `"watch-all"=false` (an argument the extension appended) isn't recognized (see facebook/react-script#12801 for more details). Please report them if you encounter any.

See [Customization](README.md#customization) for more details.


<!-- cSpell:ignore mjamin -->
- [jest-community/jest-editor-support#103](https://github.com/jest-community/jest-editor-support/pull/103) - @mjamin
- [#1034](https://github.com/jest-community/vscode-jest/pull/1034) - @connectdotz

#### 3. control extension activation within each folder
A new setting`"jest.enable"` is added as a quick way to turn off the extension feature for the given folder/virtual-folder without uninstall/disable completely in vscode.

This is indeed similar to `"jest.disabledWorkspaceFolders"`, which is a "window" level setting (on the root of the workspace). Given the target is the folder itself, we believe it makes more sense to put the control `"jest.enable"` in folder level instead. It could also provide better extensibility down the road, such as "deferred-activation". We hope `"jest.enable"` will eventually replace `"jest.disabledWorkspaceFolders"`.

See [Customization](README.md#customization) for more details.

- [#1009](https://github.com/jest-community/vscode-jest/pull/1009) - @connectdotz

#### 4. Auto clear output upon test run

Introduced a new setting - `"jest.autoClearOutput"` - to clear the output terminal before each test run. Default is false for backward compatibility. This is useful when you want to see only the last run output.

See [Customization](README.md#customization) for more details.

<!-- cSpell:ignore jgillick -->
- [#1014](https://github.com/jest-community/vscode-jest/pull/1014) - @jgillick

### Fixes
<!-- cSpell:ignore adrianisk Jazzkid0 ykray -->
- Fixed v2 debug config variable substitution for multi-variable in a given argument. ([#1040](https://github.com/jest-community/vscode-jest/pull/1040) - @adrianisk)
- Fixed a source code parsing error for nonLiteralName. ([#1024](https://github.com/jest-community/vscode-jest/pull/1024) - @connectdotz)
- Various documentation fixes
- [#1016](https://github.com/jest-community/vscode-jest/pull/1016) - @Jazzkid0
- [#1023](https://github.com/jest-community/vscode-jest/pull/1023) - @connectdotz
- [#1032](https://github.com/jest-community/vscode-jest/pull/1032) - @Ryan-Dia
- [#1038](https://github.com/jest-community/vscode-jest/pull/1038) - @ykray (epic work!)
- Address security vulnerability with dependencies. ([#1011](https://github.com/jest-community/vscode-jest/pull/1011))

### CHANGELOG
- [v6.0.0](https://github.com/jest-community/vscode-jest/releases/tag/v6.0.0)

---


1 change: 1 addition & 0 deletions release-notes/release-notes.md
@@ -1,3 +1,4 @@
# vscode-jest Release Notes
- [v6](release-note-v6.md)
- [v5](release-note-v5.x.md)
- [v4](release-note-v4.md)
1 change: 1 addition & 0 deletions src/extension-manager.ts
Expand Up @@ -485,6 +485,7 @@ export class ExtensionManager {

const ReleaseNoteBase = 'https://github.com/jest-community/vscode-jest/blob/master/release-notes';
const ReleaseNotes: Record<string, string> = {
'6.0.0': `${ReleaseNoteBase}/release-note-v6.md#v600-pre-release`,
'5.2.3': `${ReleaseNoteBase}/release-note-v5.x.md#v523`,
'5.2.2': `${ReleaseNoteBase}/release-note-v5.x.md#v522`,
'5.2.1': `${ReleaseNoteBase}/release-note-v5.x.md#v521-pre-release`,
Expand Down
13 changes: 7 additions & 6 deletions tests/extension-manager.test.ts
Expand Up @@ -1223,12 +1223,13 @@ describe('ExtensionManager', () => {
expect(ext2.onDidChangeActiveTextEditor).not.toHaveBeenCalled();
});
it.each`
case | version | showChoice | choice | showRN
${1} | ${'4.6'} | ${false} | ${undefined} | ${false}
${2} | ${'5.0.0'} | ${true} | ${undefined} | ${false}
${3} | ${'5.0.0'} | ${true} | ${'See What Is Changed'} | ${true}
${4} | ${'5.0.1'} | ${true} | ${undefined} | ${false}
${5} | ${'6.0.0'} | ${false} | ${undefined} | ${false}
case | version | showChoice | choice | showRN
${1} | ${'4.6'} | ${false} | ${undefined} | ${false}
${2} | ${'5.0.0'} | ${true} | ${undefined} | ${false}
${3} | ${'5.0.0'} | ${true} | ${'See What Is Changed'} | ${true}
${4} | ${'5.0.1'} | ${true} | ${undefined} | ${false}
${5} | ${'6.0.0'} | ${true} | ${undefined} | ${false}
${6} | ${'99.0.0'} | ${false} | ${undefined} | ${false}
`(
'show release note once for specific version: case $case',
async ({ version, showChoice, choice, showRN }) => {
Expand Down
1 change: 1 addition & 0 deletions tests/test-provider/test-item-data.test.ts
Expand Up @@ -1165,6 +1165,7 @@ describe('test-item-data', () => {
expect(listener.dispose).toHaveBeenCalled();
});
it('can adapt raw output to terminal output', () => {
// cSpell: ignore myarn
const coloredText = '[2Kyarn run v1.22.5\n';
jestRun.write(coloredText);
expect(jestRun.vscodeRun.appendOutput).toHaveBeenCalledWith(
Expand Down

0 comments on commit 04ea92b

Please sign in to comment.