<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] ## 概述 [官方示例](https://github.com/microsoft/vscode-test/blob/main/sample/src/test/runTest.ts) 可以方便的對 vscode 的接口進行測試 ## 示例 測試目錄 ``` src └── test ├── runTest.ts └── suite1 ├── extension.test.ts └── index.ts ``` <details> <summary>runTest.ts</summary> ``` import * as path from "path"; import { runTests } from '@vscode/test-electron'; async function main() { try { const extensionDevelopmentPath = path.resolve(__dirname, '../../'); const extensionTestsPath = path.resolve(__dirname, './suite1/'); // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath }); // 存在多個時,在運行 runTest // const extensionTestsPath2 = path.resolve(__dirname, './suite2/'); // // Download VS Code, unzip it and run the integration test // await runTests({ // extensionDevelopmentPath, // extensionTestsPath2 }); } catch (err) { console.error("Failed to run tests"); process.exit(1); } } main(); ``` </details> <details> <summary>index.ts</summary> ``` import * as path from 'path'; import * as Mocha from 'mocha'; import { glob } from 'glob'; export function run(): Promise<void> { // Create the mocha test const mocha = new Mocha({ ui: 'tdd' }); const testsRoot = path.resolve(__dirname, '..'); return new Promise((c, e) => { glob('**/**.test.js', { cwd: testsRoot }).then((files) => { console.log("===========files =============",files); // 使用 glob.glob 返回 Promise files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); mocha.run(failures => { if (failures > 0) { e(new Error(`${failures} tests failed.`)); } else { c(); } }); }).catch(err => { return e(err); }); }); } ``` </details> <details> <summary>extension.test.ts</summary> ``` import * as assert from 'assert'; import { before, describe, it } from 'mocha'; import * as vscode from 'vscode'; describe('Extension Test Suite', () => { before(() => { vscode.window.showInformationMessage('開始運行測試!'); }); it('示例測試用例', () => { assert.strictEqual(-1, [1, 2, 3].indexOf(5)); assert.strictEqual(-1, [1, 2, 3].indexOf(0)); }); }); ``` </details> <details> <summary>package.json</summary> ``` "scripts": { "test": "node ./out/test/runTest.js" }, "devDependencies": { "@eslint/js": "^9.13.0", "@stylistic/eslint-plugin": "^2.9.0", "@types/glob": "^7.1.1", "@types/mocha": "^10.0.1", "@types/node": "^20", "@types/vscode": "^1.73.0", "@vscode/test-electron": "^2.3.9", "eslint": "^9.13.0", "glob": "^7.1.4", "mocha": "^10.2.0", "source-map-support": "^0.5.12", "typescript": "^5.7.2", "typescript-eslint": "^8.16.0" } ``` </details> <br/> **運行** ``` pnpm run test ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看