From 316dcb19f5323f0c70176eb9e8a5e195c9f3c2ef Mon Sep 17 00:00:00 2001 From: ChristinaRaether Date: Thu, 4 Jan 2024 15:33:54 -0800 Subject: [PATCH 1/4] testing first pass --- .gitignore | 3 ++- .vscode/launch.json | 5 ++++- package-lock.json | 17 +++++++++++++++++ package.json | 4 +++- test/runTest.js => src/test/runTest.ts | 6 +++--- .../test/suite/extension.test.ts | 7 ++++--- test/suite/index.js => src/test/suite/index.ts | 13 +++++-------- tsconfig.json | 2 +- 8 files changed, 39 insertions(+), 18 deletions(-) rename test/runTest.js => src/test/runTest.ts (77%) rename test/suite/extension.test.js => src/test/suite/extension.test.ts (65%) rename test/suite/index.js => src/test/suite/index.ts (75%) diff --git a/.gitignore b/.gitignore index 05d2dd7..6563919 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules /build -/package-lock.json \ No newline at end of file +/package-lock.json +/.vscode-test/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index c774552..f3c3931 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,6 +5,7 @@ { "version": "0.2.0", "configurations": [ + { "name": "Run Extension", "type": "extensionHost", @@ -20,7 +21,9 @@ "args": [ "--extensionDevelopmentPath=${workspaceFolder}", "--extensionTestsPath=${workspaceFolder}/test/suite/index" - ] + ], + "outFiles": ["${workspaceFolder}/build/*.js"], + "preLaunchTask": "npm: test-compile" } ] } diff --git a/package-lock.json b/package-lock.json index 2fe2a0b..98c03bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "webpack": "^5.89.0" }, "devDependencies": { + "@types/glob": "^8.1.0", "@types/mocha": "^10.0.3", "@types/node": "18.x", "@types/react": "^18.2.45", @@ -3417,11 +3418,27 @@ "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.13.tgz", "integrity": "sha512-bmrNrgKMOhM3WsafmbGmC+6dsF2Z308vLFsQ3a/bT8X8Sv5clVYpPars/UPq+sAaJP+5OoLAYgwbkS5QEJdLUQ==" }, + "node_modules/@types/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", + "dev": true, + "dependencies": { + "@types/minimatch": "^5.1.2", + "@types/node": "*" + } + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==" }, + "node_modules/@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", + "dev": true + }, "node_modules/@types/mocha": { "version": "10.0.4", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.4.tgz", diff --git a/package.json b/package.json index fbf98dd..11e1b6a 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "pricing": "Free", "activationEvents": [], "main": "./build/extension.js", + "type": "module", "contributes": { "commands": [ { @@ -70,11 +71,12 @@ "scripts": { "lint": "eslint .", "pretest": "npm run lint", - "test": "node ./test/runTest.js", + "test": "node ./src/test/runTest.ts", "dev": "webpack --watch", "webpack": "webpack" }, "devDependencies": { + "@types/glob": "^8.1.0", "@types/mocha": "^10.0.3", "@types/node": "18.x", "@types/react": "^18.2.45", diff --git a/test/runTest.js b/src/test/runTest.ts similarity index 77% rename from test/runTest.js rename to src/test/runTest.ts index 570e697..6f1b600 100644 --- a/test/runTest.js +++ b/src/test/runTest.ts @@ -1,12 +1,12 @@ -const path = require('path'); +import * as path from 'path'; -const { runTests } = require('@vscode/test-electron'); +import { runTests } from '@vscode/test-electron'; async function main() { try { // The folder containing the Extension Manifest package.json // Passed to `--extensionDevelopmentPath` - const extensionDevelopmentPath = path.resolve(__dirname, '../'); + const extensionDevelopmentPath = path.resolve(__dirname, '../../'); // The path to the extension test script // Passed to --extensionTestsPath diff --git a/test/suite/extension.test.js b/src/test/suite/extension.test.ts similarity index 65% rename from test/suite/extension.test.js rename to src/test/suite/extension.test.ts index 69ead83..fc20674 100644 --- a/test/suite/extension.test.js +++ b/src/test/suite/extension.test.ts @@ -1,15 +1,16 @@ -const assert = require('assert'); +import * as assert from 'assert' // You can import and use all API from the 'vscode' module // as well as import your extension to test it -const vscode = require('vscode'); +import * as vscode from 'vscode' // const myExtension = require('../extension'); suite('Extension Test Suite', () => { vscode.window.showInformationMessage('Start all tests.'); test('Sample test', () => { - assert.strictEqual(-1, [1, 2, 3].indexOf(5)); + assert.strictEqual(-1, [1, 2, 3].indexOf(5)); // false assert.strictEqual(-1, [1, 2, 3].indexOf(0)); + assert.strictEqual(0, [1, 2, 3].indexOf(1)); // true }); }); diff --git a/test/suite/index.js b/src/test/suite/index.ts similarity index 75% rename from test/suite/index.js rename to src/test/suite/index.ts index 757fe1a..da70745 100644 --- a/test/suite/index.js +++ b/src/test/suite/index.ts @@ -1,10 +1,10 @@ -const path = require('path'); -const Mocha = require('mocha'); -const glob = require('glob'); +import * as path from 'path'; +import * as Mocha from 'mocha'; +import { glob } from 'glob'; -async function run() { +export async function run(): Promise { // Create the mocha test - const mocha = new Mocha({ + const mocha = new Mocha.default({ ui: 'tdd', color: true }); @@ -31,6 +31,3 @@ async function run() { } } -module.exports = { - run -}; diff --git a/tsconfig.json b/tsconfig.json index d381c8c..5d6a22e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,7 @@ "strict": false, }, // "include": ["src", "src/types/index.d.ts"], - "include": ["src/**/*.ts", "src/**/*.tsx"], + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/**/*.tsx", "src/**/**/*.ts"], "exclude": [ "node_modules", ".vscode-test", From 8a4efe2f133deb52c40e9c86f713fdc13feb145c Mon Sep 17 00:00:00 2001 From: ChristinaRaether Date: Thu, 4 Jan 2024 19:34:14 -0800 Subject: [PATCH 2/4] testing day 2 --- .vscode-test.js | 9 +++ .vscode/settings.json | 3 + .vscodeignore | 1 + package-lock.json | 141 ++++++++++++++++++++++++++++++++++++++++-- package.json | 7 ++- src/test/runTest.ts | 6 ++ tsconfig.json | 4 +- 7 files changed, 163 insertions(+), 8 deletions(-) create mode 100644 .vscode-test.js create mode 100644 .vscode/settings.json diff --git a/.vscode-test.js b/.vscode-test.js new file mode 100644 index 0000000..ecde832 --- /dev/null +++ b/.vscode-test.js @@ -0,0 +1,9 @@ +// .vscode-test.js +const { defineConfig } = require('@vscode/test-cli'); + +module.exports = defineConfig([ + { + label: 'unitTests', + files: 'build/src/test/**/*.test.js', + } +]); \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cad7657 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.configureOnOpen": false +} \ No newline at end of file diff --git a/.vscodeignore b/.vscodeignore index a775644..a5b7de8 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -7,3 +7,4 @@ vsc-extension-quickstart.md **/jsconfig.json **/*.map **/.eslintrc.json +**/*.js.map diff --git a/package-lock.json b/package-lock.json index 98c03bf..6be480f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,8 @@ "@types/react": "^18.2.45", "@types/react-dom": "^18.2.18", "@types/vscode": "^1.84.0", - "@vscode/test-electron": "^2.3.6", + "@vscode/test-cli": "^0.0.4", + "@vscode/test-electron": "^2.3.8", "eslint": "^8.54.0", "glob": "^10.3.10", "mocha": "^10.2.0", @@ -3497,10 +3498,142 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "dev": true }, + "node_modules/@vscode/test-cli": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@vscode/test-cli/-/test-cli-0.0.4.tgz", + "integrity": "sha512-Tx0tfbxeSb2Xlo+jpd+GJrNLgKQHobhRHrYvOipZRZQYWZ82sKiK02VY09UjU1Czc/YnZnqyAnjUfaVGl3h09w==", + "dev": true, + "dependencies": { + "@types/mocha": "^10.0.2", + "chokidar": "^3.5.3", + "glob": "^10.3.10", + "minimatch": "^9.0.3", + "mocha": "^10.2.0", + "supports-color": "^9.4.0", + "yargs": "^17.7.2" + }, + "bin": { + "vscode-test": "out/bin.mjs" + } + }, + "node_modules/@vscode/test-cli/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@vscode/test-cli/node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@vscode/test-cli/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/@vscode/test-cli/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@vscode/test-cli/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@vscode/test-cli/node_modules/supports-color": { + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.4.0.tgz", + "integrity": "sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/@vscode/test-cli/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/@vscode/test-cli/node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@vscode/test-cli/node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/@vscode/test-electron": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.6.tgz", - "integrity": "sha512-M31xGH0RgqNU6CZ4/9g39oUMJ99nLzfjA+4UbtIQ6TcXQ6+2qkjOOxedmPBDDCg26/3Al5ubjY80hIoaMwKYSw==", + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.8.tgz", + "integrity": "sha512-b4aZZsBKtMGdDljAsOPObnAi7+VWIaYl3ylCz1jTs+oV6BZ4TNHcVNC3xUn0azPeszBmwSBDQYfFESIaUQnrOg==", "dev": true, "dependencies": { "http-proxy-agent": "^4.0.1", diff --git a/package.json b/package.json index 11e1b6a..dc44640 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "pricing": "Free", "activationEvents": [], "main": "./build/extension.js", - "type": "module", "contributes": { "commands": [ { @@ -71,7 +70,8 @@ "scripts": { "lint": "eslint .", "pretest": "npm run lint", - "test": "node ./src/test/runTest.ts", + "test": "node ./build/src/test/runTest.js", + "test1": "vscode-test", "dev": "webpack --watch", "webpack": "webpack" }, @@ -82,7 +82,8 @@ "@types/react": "^18.2.45", "@types/react-dom": "^18.2.18", "@types/vscode": "^1.84.0", - "@vscode/test-electron": "^2.3.6", + "@vscode/test-cli": "^0.0.4", + "@vscode/test-electron": "^2.3.8", "eslint": "^8.54.0", "glob": "^10.3.10", "mocha": "^10.2.0", diff --git a/src/test/runTest.ts b/src/test/runTest.ts index 6f1b600..d673170 100644 --- a/src/test/runTest.ts +++ b/src/test/runTest.ts @@ -3,15 +3,21 @@ import * as path from 'path'; import { runTests } from '@vscode/test-electron'; async function main() { + console.log('made it through the line before try block'); try { + console.log('inside try block'); // The folder containing the Extension Manifest package.json // Passed to `--extensionDevelopmentPath` const extensionDevelopmentPath = path.resolve(__dirname, '../../'); + console.log('inside try block after first var declare'); + // The path to the extension test script // Passed to --extensionTestsPath const extensionTestsPath = path.resolve(__dirname, './suite/index'); + console.log('inside try block after second var declare'); + // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath }); } catch (err) { diff --git a/tsconfig.json b/tsconfig.json index 5d6a22e..6c608c6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,9 @@ "allowJs": true, "strict": false, }, - // "include": ["src", "src/types/index.d.ts"], + "tsnode": { + "esm": true + }, "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/**/*.tsx", "src/**/**/*.ts"], "exclude": [ "node_modules", From ba200666439f64d372c61c33de5ee4b8a25e3eb9 Mon Sep 17 00:00:00 2001 From: ChristinaRaether Date: Sat, 6 Jan 2024 11:13:49 -0800 Subject: [PATCH 3/4] updating version --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6be480f..c299a70 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3487,9 +3487,9 @@ "devOptional": true }, "node_modules/@types/vscode": { - "version": "1.84.1", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.84.1.tgz", - "integrity": "sha512-DB10vBRLEPA/us7p3gQilU2Tq5HDu6JWTyCpD9qtb7MKWIvJS5In9HU3YgVGCXf/miwHJiY62aXwjtUSMpT8HA==", + "version": "1.85.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.85.0.tgz", + "integrity": "sha512-CF/RBon/GXwdfmnjZj0WTUMZN5H6YITOfBCP4iEZlOtVQXuzw6t7Le7+cR+7JzdMrnlm7Mfp49Oj2TuSXIWo3g==", "dev": true }, "node_modules/@ungap/structured-clone": { diff --git a/package.json b/package.json index dc44640..bd36d90 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "@types/node": "18.x", "@types/react": "^18.2.45", "@types/react-dom": "^18.2.18", - "@types/vscode": "^1.84.0", + "@types/vscode": "^1.85.1", "@vscode/test-cli": "^0.0.4", "@vscode/test-electron": "^2.3.8", "eslint": "^8.54.0", From 9ec967c0c58692909e90192a04eb4e4d801ab23f Mon Sep 17 00:00:00 2001 From: ChristinaRaether Date: Sat, 6 Jan 2024 11:40:04 -0800 Subject: [PATCH 4/4] working test --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c299a70..ae58973 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "@types/node": "18.x", "@types/react": "^18.2.45", "@types/react-dom": "^18.2.18", - "@types/vscode": "^1.84.0", + "@types/vscode": "^1.85.1", "@vscode/test-cli": "^0.0.4", "@vscode/test-electron": "^2.3.8", "eslint": "^8.54.0", @@ -43,7 +43,7 @@ "webpack-cli": "^5.1.4" }, "engines": { - "vscode": "^1.84.0" + "vscode": "^1.85.1" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index bd36d90..f30dd08 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "version": "0.0.1", "publisher": "ReactLabyrinthDev", "engines": { - "vscode": "^1.84.0" + "vscode": "^1.85.1" }, "repository": { "type": "git",