Skip to content

Commit

Permalink
Run mode (#1078)
Browse files Browse the repository at this point in the history
* replace legacy settings with runMode

* implement deferred mode, enhance runMode config interface

* implemented save runMode, refactor terminal revealOutput logic

* fix runMode override previous setting bug

* 1. refactor exec-error notification
2. add defer to quick-fix options
3. ensure one error report per process

* adding runMode json schema

* rename "manual" to "on-demand"; catch and notify when jest process failed to start

* refactor quick-fix to use a quickPick instead

* fix tests

* adding compare-coverage script and instructions

* adding missing tests

* update README and remove inline menu icon

* clean up and adding missing tests

* rm orphan images

* address coverage and cleanup

* undo the accidental change in settings.json
  • Loading branch information
connectdotz authored Oct 10, 2023
1 parent 8a1b362 commit 10414ab
Show file tree
Hide file tree
Showing 75 changed files with 3,876 additions and 1,301 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
_jest-editor/
.vscode/symbols.json
/coverage/
/coverage*/
node_modules/
out/
generated-icons/

**/.DS_Store
*.vsix
*.zip
coverage_comparison_report.html
4 changes: 4 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ generated-icons/
release-notes/
setup-wizard.md
*.zip
coverage*/
scripts/**
coverage_comparison_report.html

16 changes: 15 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,24 @@ There are two debugging launch configurations defined in `.vscode/launch.json`:

To debug the extension, [change the launch configuration](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) to **Launch Extension** and start debugging.

**3. eat our own dog food**
**3. check test coverage**

Make sure your changes are covered by unit tests and that you did not lose coverage compared to the master branch. While compared to master branch is part of PR workflow validation, it is always a good practice to check it locally before submitting the PR. The following is the step to do it:
1. go back to master branch (`git checkout master`), run all tests with coverage, which should produce a "coverage" folder under the project root. Rename it to something like "coverage-master" to keep it for later comparison.
2. switch back to your branch (`git checkout your-branch`), run all tests with coverage, which should produce a "coverage" folder under the project root.
3. run compare-coverage script with the master and the current coverage folders, such as `yarn compare-coverage coverage-master coverage`. It will produce a report `coverage_comparison_report.html` under the project root.
4. examine `coverage_comparison_report.html` to make sure your changes are fully tested therefore did not reduce coverage compared to master branch.

**4. eat our own dog food**

The ultimate test is to actually use it in our real day-to-day working environment for a while. There are multiple ways to do this:

The most accurate way is to install the extension locally and use it in your real project. You can do this by:
- building a local installable package with command: `vsce package`. This will produce a `vscode-jest-xxx.vsix` file, where "xxx" is the version number in `package.json`.
- install this file by using vscode command palette `Extensions: Install from VSIX...`.
- after test, you can restore the official version from the vscode's extensions panel.

If you don't have vsce installed, you can try these methods instead:
- by command line: `code --extensionDevelopmentPath=your-local-vscode-jest`
- by environment variable: `CODE_EXTENSIONS_PATH`
- by symlink:
Expand Down
418 changes: 280 additions & 138 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions icons/coverage-on-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/pause-on-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/debug-screen-shot.png
Binary file not shown.
Binary file removed images/jest-env-error.jpg
Binary file not shown.
Binary file removed images/pre-release.png
Binary file not shown.
Binary file added images/quick-fix-chooser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/runmode-chooser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/runmode-tradeoff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/status-bar-manual.png
Binary file not shown.
Binary file added images/status-bar-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/status-bar-save-all.png
Binary file not shown.
Binary file removed images/status-bar-save-test-unsync.png
Binary file not shown.
Binary file removed images/status-bar-save-test.png
Binary file not shown.
Binary file removed images/status-bar-watch-coverage.png
Binary file not shown.
Binary file removed images/status-bar-watch.png
Binary file not shown.
Binary file removed images/testExplorer-5.1.1.png
Binary file not shown.
Binary file added images/testExplorer-6.0.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/testExplorer.png
Binary file not shown.
176 changes: 118 additions & 58 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-jest",
"displayName": "Jest",
"description": "Use Facebook's Jest With Pleasure.",
"version": "6.0.1",
"version": "6.0.2",
"publisher": "Orta",
"engines": {
"vscode": "^1.68.1"
Expand Down Expand Up @@ -108,7 +108,9 @@
"description": "Show code coverage when extension starts (if collected)",
"type": "boolean",
"default": false,
"scope": "resource"
"scope": "resource",
"markdownDeprecationMessage": "**Deprecated**: Please use [runMode](https://github.com/jest-community/vscode-jest/blob/master/README.md#runmode) instead.",
"deprecationMessage": "Deprecated: Please use jest.runMode instead."
},
"jest.coverageFormatter": {
"description": "Coverage formatter to use",
Expand Down Expand Up @@ -140,13 +142,15 @@
"scope": "window"
},
"jest.autoRun": {
"markdownDescription": "Control when jest should run (changed) tests. It supports multiple models, such as fully automated, fully manual and onSave... See [AutoRun](https://github.com/jest-community/vscode-jest/blob/master/README.md#how-to-trigger-the-test-run) for details and examples",
"markdownDescription": "Control when jest should run (changed) tests. It supports multiple models, such as fully automated, onSave, and on-demand... See [AutoRun](https://github.com/jest-community/vscode-jest/blob/master/README.md#how-to-trigger-the-test-run) for details and examples",
"type": [
"object",
"string"
],
"default": null,
"scope": "resource"
"scope": "resource",
"markdownDeprecationMessage": "**Deprecated**: Please use [runMode](https://github.com/jest-community/vscode-jest/blob/master/README.md#runmode) instead.",
"deprecationMessage": "Deprecated: Please use jest.runMode instead."
},
"jest.testExplorer": {
"markdownDescription": "Configure jest TestExplorer. See valid [formats](https://github.com/jest-community/vscode-jest/blob/master/README.md#testexplorer) or [how to use test explorer](https://github.com/jest-community/vscode-jest/blob/master/README.md#how-to-use-the-test-explorer) for more details",
Expand Down Expand Up @@ -177,7 +181,9 @@
"auto show test output when execution error occurred",
"disable auto show test output"
],
"scope": "resource"
"scope": "resource",
"markdownDeprecationMessage": "**Deprecated**: Please use [runMode](https://github.com/jest-community/vscode-jest/blob/master/README.md#runmode) instead.",
"deprecationMessage": "Deprecated: Please use jest.runMode instead."
},
"jest.parserPluginOptions": {
"markdownDescription": "Configure babel parser plugins. See valid [format](https://github.com/jest-community/vscode-jest/blob/master/README.md#parserpluginoptions)",
Expand All @@ -192,9 +198,97 @@
"scope": "resource"
},
"jest.virtualFolders": {
"markdownDescription": "Allows multiple jest run config for a given (physical) folder. See valid [format](TODO)",
"type": "array",
"default": null
"markdownDescription": "Allows multiple jest run config for a given (physical) folder. See valid [format](https://github.com/jest-community/vscode-jest#virtualfolders)",
"type": [
"array",
"null"
],
"default": null,
"items": {
"type": "object"
}
},
"jest.runMode": {
"markdownDescription": "Control when to run jest tests and present the results. See details in [runMode](https://github.com/jest-community/vscode-jest#runmode)",
"default": null,
"scope": "resource",
"oneOf": [
{
"type": "string",
"enum": [
"watch",
"on-demand",
"on-save",
"deferred"
],
"markdownDescription": "A predefined Jest run mode. See details in [runMode](https://github.com/jest-community/vscode-jest#runmode)"
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"watch",
"on-demand",
"on-save"
],
"description": "Specifies the jest run mode type."
},
"runAllTestsOnStartup": {
"type": "boolean",
"description": "Specifies whether to run all tests on startup."
},
"coverage": {
"type": "boolean",
"description": "Specifies whether to collect and report coverage information."
},
"revealOutput": {
"type": "string",
"enum": [
"on-run",
"on-exec-error",
"on-demand"
],
"description": "Determines when to reveal the test run output."
},
"deferred": {
"type": "boolean",
"description": "Specifies whether the run mode is deferred."
}
},
"required": [
"type"
],
"additionalProperties": true,
"if": {
"properties": {
"type": {
"const": "on-save"
}
}
},
"then": {
"properties": {
"testFileOnly": {
"type": "boolean",
"description": "if true, will run tests only when saving test files."
}
},
"additionalProperties": true
},
"else": {
"not": {
"required": [
"testFileOnly"
]
},
"errorMessage": "The property 'testFileOnly' should only be present when 'type' is 'on-save'.",
"additionalProperties": true
},
"markdownDescription": "A detailed runMode configuration. See details in [runMode](https://github.com/jest-community/vscode-jest#runmode)"
}
]
}
}
},
Expand Down Expand Up @@ -227,6 +321,10 @@
"command": "io.orta.jest.workspace.run-all-tests",
"title": "Jest: Run All Tests (Select Workspace)"
},
{
"command": "io.orta.jest.workspace.save-run-mode",
"title": "Jest: Save Current RunMode"
},
{
"command": "io.orta.jest.run-all-tests",
"title": "Jest: Run All Tests"
Expand All @@ -248,24 +346,9 @@
"title": "Jest: Setup Extension"
},
{
"command": "io.orta.jest.test-item.auto-run.toggle-on",
"title": "Toggle AutoRun On",
"icon": "$(sync)"
},
{
"command": "io.orta.jest.test-item.auto-run.toggle-off",
"title": "Toggle AutoRun Off",
"icon": "$(sync-ignored)"
},
{
"command": "io.orta.jest.test-item.coverage.toggle-off",
"title": "Toggle Coverage Off",
"icon": "$(circle-slash)"
},
{
"command": "io.orta.jest.test-item.coverage.toggle-on",
"title": "Toggle Coverage On",
"icon": "$(color-mode)"
"command": "io.orta.jest.test-item.run-mode.change",
"title": "Change RunMode",
"icon": "$(gear)"
},
{
"command": "io.orta.jest.test-item.reveal-output",
Expand Down Expand Up @@ -314,19 +397,7 @@
"when": "jest.never"
},
{
"command": "io.orta.jest.test-item.auto-run.toggle-on",
"when": "jest.never"
},
{
"command": "io.orta.jest.test-item.auto-run.toggle-off",
"when": "jest.never"
},
{
"command": "io.orta.jest.test-item.coverage.toggle-on",
"when": "jest.never"
},
{
"command": "io.orta.jest.test-item.coverage.toggle-off",
"command": "io.orta.jest.test-item.run-mode.change",
"when": "jest.never"
},
{
Expand All @@ -351,28 +422,13 @@
],
"testing/item/context": [
{
"command": "io.orta.jest.test-item.auto-run.toggle-off",
"group": "inline@1",
"when": "testId in jest.autoRun.on"
},
{
"command": "io.orta.jest.test-item.auto-run.toggle-on",
"command": "io.orta.jest.test-item.run-mode.change",
"group": "inline@1",
"when": "testId in jest.autoRun.off"
},
{
"command": "io.orta.jest.test-item.coverage.toggle-off",
"group": "inline@2",
"when": "testId in jest.coverage.on"
},
{
"command": "io.orta.jest.test-item.coverage.toggle-on",
"group": "inline@2",
"when": "testId in jest.coverage.off"
"when": "testId in jest.runMode"
},
{
"command": "io.orta.jest.test-item.reveal-output",
"group": "inline@3",
"group": "inline@2",
"when": "testId in jest.workspaceRoot"
},
{
Expand Down Expand Up @@ -520,14 +576,16 @@
"test": "jest",
"watch-test": "yarn test -- --watch",
"tsc": "tsc --noEmit",
"update-vscode-type": "npx vscode-dts main; mv ./vscode.d.ts ./typings"
"update-vscode-type": "npx vscode-dts main; mv ./vscode.d.ts ./typings",
"compare-coverage": "ts-node scripts/compare-coverage.ts "
},
"dependencies": {
"istanbul-lib-coverage": "^3.2.0",
"istanbul-lib-source-maps": "^4.0.1",
"jest-editor-support": "^31.1.1"
},
"devDependencies": {
"@types/fs-extra": "^11.0.2",
"@types/istanbul-lib-coverage": "^2.0.4",
"@types/istanbul-lib-source-maps": "^4.0.1",
"@types/jest": "^29.2.5",
Expand All @@ -541,13 +599,15 @@
"eslint-plugin-jsdoc": "^39.6.4",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^4.2.1",
"fs-extra": "^11.1.1",
"jest": "^29.3.1",
"jest-snapshot": "^27.2.0",
"prettier": "^2.8.2",
"raw-loader": "^4.0.1",
"rimraf": "^3.0.2",
"ts-jest": "^29.0.3",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
Expand Down
Loading

0 comments on commit 10414ab

Please sign in to comment.