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

update templates to use new test-cli package #434

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions generators/app/dependencyVersions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"glob": "^10.3.10",
"mocha": "^10.2.0",
"typescript": "^5.2.2",
"@vscode/test-cli": "^0.0.4",
"@vscode/test-electron": "^2.3.6",
"@vscode/test-web": "^0.0.48",
"@types/webpack-env": "^1.18.3",
Expand Down
1 change: 1 addition & 0 deletions generators/app/generate-command-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default {

generator.fs.copyTpl(generator.templatePath('extension.js'), generator.destinationPath('extension.js'), extensionConfig);
generator.fs.copyTpl(generator.templatePath('package.json'), generator.destinationPath('package.json'), extensionConfig);
generator.fs.copy(generator.templatePath('.vscode-test.mjs'), generator.destinationPath('.vscode-test.mjs'));
generator.fs.copyTpl(generator.templatePath('.eslintrc.json'), generator.destinationPath('.eslintrc.json'), extensionConfig);

if (extensionConfig.pkgManager === 'yarn') {
Expand Down
1 change: 1 addition & 0 deletions generators/app/generate-command-ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default {
generator.fs.copyTpl(generator.templatePath('CHANGELOG.md'), generator.destinationPath('CHANGELOG.md'), extensionConfig);
generator.fs.copyTpl(generator.templatePath('src/extension.ts'), generator.destinationPath('src/extension.ts'), extensionConfig);
generator.fs.copy(generator.templatePath('src/test'), generator.destinationPath('src/test'));
generator.fs.copy(generator.templatePath('.vscode-test.mjs'), generator.destinationPath('.vscode-test.mjs'));
generator.fs.copy(generator.templatePath('.eslintrc.json'), generator.destinationPath('.eslintrc.json'));

if (extensionConfig.pkgManager === 'yarn') {
Expand Down
1 change: 1 addition & 0 deletions generators/app/generate-notebook-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default {
generator.fs.copy(generator.templatePath('.vscodeignore'), generator.destinationPath('.vscodeignore'));
generator.fs.copy(generator.templatePath('webpack.config.js'), generator.destinationPath('webpack.config.js'));
generator.fs.copy(generator.templatePath('.eslintrc.json'), generator.destinationPath('.eslintrc.json'));
generator.fs.copy(generator.templatePath('.vscode-test.mjs'), generator.destinationPath('.vscode-test.mjs'));

generator.fs.copyTpl(generator.templatePath('package.json'), generator.destinationPath('package.json'), extensionConfig);
generator.fs.copyTpl(generator.templatePath('README.md'), generator.destinationPath('README.md'), extensionConfig);
Expand Down
5 changes: 5 additions & 0 deletions generators/app/templates/ext-command-js/.vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
files: 'test/**/*.test.js',
});
1 change: 1 addition & 0 deletions generators/app/templates/ext-command-js/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ vsc-extension-quickstart.md
**/jsconfig.json
**/*.map
**/.eslintrc.json
**/.vscode-test.*
5 changes: 2 additions & 3 deletions generators/app/templates/ext-command-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
"scripts": {
"lint": "eslint .",
"pretest": "<%= pkgManager %> run lint",
"test": "node ./test/runTest.js"
"test": "vscode-test"
},
"devDependencies": {
<%- dep("@types/vscode") %>,
<%- dep("@types/mocha") %>,
<%- dep("@types/node") %>,
<%- dep("eslint") %>,
<%- dep("glob") %>,
<%- dep("mocha") %>,
<%- dep("typescript") %>,
<%- dep("@vscode/test-cli") %>,
<%- dep("@vscode/test-electron") %>
}
}
23 changes: 0 additions & 23 deletions generators/app/templates/ext-command-js/test/runTest.js

This file was deleted.

36 changes: 0 additions & 36 deletions generators/app/templates/ext-command-js/test/suite/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

## Run tests

* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`.
* Press `F5` to run the tests in a new window with your extension loaded.
* See the output of the test result in the debug console.
* Make changes to `src/test/suite/extension.test.js` or create new test files inside the `test/suite` folder.
* The provided test runner will only consider files matching the name pattern `**.test.ts`.
* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A`
* See the output of the test result in the Test Results view.
* Make changes to `test/extension.test.js` or create new test files inside the `test` folder.
* The provided test runner will only consider files matching the name pattern `**.test.js`.
* You can create folders inside the `test` folder to structure your tests any way you want.

## Go further
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
"dbaeumer.vscode-eslint",
"ms-vscode.extension-test-runner"
]
}
}
9 changes: 0 additions & 9 deletions generators/app/templates/ext-command-js/vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/test/suite/index"
]
}
]
}
5 changes: 5 additions & 0 deletions generators/app/templates/ext-command-ts/.vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
files: 'out/test/**/*.test.js',
});
1 change: 1 addition & 0 deletions generators/app/templates/ext-command-ts/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ vsc-extension-quickstart.md
**/.eslintrc.json
**/*.map
**/*.ts
**/.vscode-test.*
5 changes: 2 additions & 3 deletions generators/app/templates/ext-command-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"watch": "tsc -watch -p ./",
"pretest": "<%= pkgManager %> run compile && <%= pkgManager %> run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"<% if (insiders) { %>,
"test": "vscode-test"<% if (insiders) { %>,
"update-proposed-api": "vscode-dts dev"<% } %>
},
"devDependencies": {
Expand All @@ -36,9 +36,8 @@
<%- dep("@typescript-eslint/eslint-plugin") %>,
<%- dep("@typescript-eslint/parser") %>,
<%- dep("eslint") %>,
<%- dep("glob") %>,
<%- dep("mocha") %>,
<%- dep("typescript") %>,
<%- dep("@vscode/test-cli") %>,
<%- dep("@vscode/test-electron") %><% if (insiders) { %>,
<%- dep("vscode-dts") %><% } %>
}
Expand Down
23 changes: 0 additions & 23 deletions generators/app/templates/ext-command-ts/src/test/runTest.ts

This file was deleted.

32 changes: 0 additions & 32 deletions generators/app/templates/ext-command-ts/src/test/suite/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@

## Run tests

* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`.
* Press `F5` to run the tests in a new window with your extension loaded.
* See the output of the test result in the debug console.
* Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder.
* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
* Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered.
* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A`
* See the output of the test result in the Test Results view.
* Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder.
* The provided test runner will only consider files matching the name pattern `**.test.ts`.
* You can create folders inside the `test` folder to structure your tests any way you want.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ vsc-extension-quickstart.md
**/.eslintrc.json
**/*.map
**/*.ts
**/.vscode-test.*
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "<%= pkgManager %> run compile-tests && <%= pkgManager %> run compile && <%= pkgManager %> run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"<% if (insiders) { %>,
"test": "vscode-test"<% if (insiders) { %>,
"update-proposed-api": "vscode-dts dev"<% } %>
},
"devDependencies": {
Expand All @@ -39,12 +39,11 @@
<%- dep("@typescript-eslint/eslint-plugin") %>,
<%- dep("@typescript-eslint/parser") %>,
<%- dep("eslint") %>,
<%- dep("glob") %>,
<%- dep("mocha") %>,
<%- dep("typescript") %>,
<%- dep("ts-loader") %>,
<%- dep("webpack") %>,
<%- dep("webpack-cli") %>,
<%- dep("@vscode/test-cli") %>,
<%- dep("@vscode/test-electron") %><% if (insiders) { %>,
<%- dep("vscode-dts") %><% } %>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

## Setup

* install the recommended extensions (amodio.tsl-problem-matcher and dbaeumer.vscode-eslint)
* install the recommended extensions (amodio.tsl-problem-matcher, ms-vscode.extension-test-runner, and dbaeumer.vscode-eslint)


## Get up and running straight away
Expand All @@ -33,10 +33,11 @@

## Run tests

* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`.
* Press `F5` to run the tests in a new window with your extension loaded.
* See the output of the test result in the debug console.
* Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder.
* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
* Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered.
* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A`
* See the output of the test result in the Test Results view.
* Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder.
* The provided test runner will only consider files matching the name pattern `**.test.ts`.
* You can create folders inside the `test` folder to structure your tests any way you want.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher"]
"recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher", "ms-vscode.extension-test-runner"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "tasks: watch-tests"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
"dbaeumer.vscode-eslint",
"ms-vscode.extension-test-runner"
]
}
13 changes: 0 additions & 13 deletions generators/app/templates/ext-command-ts/vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
1 change: 1 addition & 0 deletions generators/app/templates/ext-command-web/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ webpack.config.js
**/.eslintrc.json
**/*.map
**/*.ts
**/.vscode-test.*
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Setup

* install the recommended extensions (amodio.tsl-problem-matcher and dbaeumer.vscode-eslint)
* install the recommended extensions (amodio.tsl-problem-matcher, ms-vscode.extension-test-runner, and dbaeumer.vscode-eslint)

## Get up and running the Web Extension

Expand Down