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

Add helloworld-jest-test-sample #251

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
460 changes: 238 additions & 222 deletions .scripts/samples.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions helloworld-jest-test-sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
out
node_modules
.vscode-test/
*.vsix
90 changes: 90 additions & 0 deletions helloworld-jest-test-sample/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
bmealhouse marked this conversation as resolved.
Show resolved Hide resolved
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--disable-extensions", "--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm: watch"
},
{
"name": "Jest: Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/node_modules/vscode-test/out/jest-runner"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this path doesn't exist

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR needs to be merged and released before the path will exist: microsoft/vscode-test#59

],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm: compile",
"internalConsoleOptions": "openOnSessionStart",
"env": {
"JEST_RUNNER_TEST_REGEX": "",
"JEST_RUNNER_UPDATE_SNAPSHOTS": "false"
}
},
{
"name": "Jest: Current Test File",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/node_modules/vscode-test/out/jest-runner"
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm: compile",
"internalConsoleOptions": "openOnSessionStart",
"env": {
"JEST_RUNNER_TEST_REGEX": "${file}",
"JEST_RUNNER_UPDATE_SNAPSHOTS": "false"
}
},
{
"name": "Jest: Update All Snapshots",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/node_modules/vscode-test/out/jest-runner"
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm: compile",
"internalConsoleOptions": "openOnSessionStart",
"env": {
"JEST_RUNNER_TEST_REGEX": "",
"JEST_RUNNER_UPDATE_SNAPSHOTS": "true"
}
},
{
"name": "Jest: Update Snapshots in Current Test File",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/node_modules/vscode-test/out/jest-runner"
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm: compile",
"internalConsoleOptions": "openOnSessionStart",
"env": {
"JEST_RUNNER_TEST_REGEX": "${file}",
"JEST_RUNNER_UPDATE_SNAPSHOTS": "true"
}
}
]
}
3 changes: 3 additions & 0 deletions helloworld-jest-test-sample/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"debug.node.autoAttach": "on"
}
20 changes: 20 additions & 0 deletions helloworld-jest-test-sample/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
19 changes: 19 additions & 0 deletions helloworld-jest-test-sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Hello World Jest Test Sample

This is the Hello World example with jest integration tests setup.

You can find the accompanying documentation at:

- https://code.visualstudio.com/api/working-with-extensions/testing-extension#testing-extension-with-jest
- https://github.com/microsoft/vscode-test/blob/master/jest-runner

## Demo

![demo](demo.gif)

## Running the Sample

- Run `npm install` in terminal to install dependencies
- Run the `Jest: All tests` target in the Debug View. This will:
- Start a task `npm: compile` to compile the code
- Run the extension integration test in a new VS Code window
Binary file added helloworld-jest-test-sample/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading