Skip to content

Commit

Permalink
[Fix] Re-enable tests (KreativJos#73)
Browse files Browse the repository at this point in the history
* Migrated tests to @vscode/test-electron KreativJos#26

From: https://github.com/microsoft/vscode-docs/blob/vnext/api/working-with-extensions/testing-extension.md#migrating-from-vscode

* Fixed test classes and added more test cases KreativJos#52

* Added pipeline tests

Co-authored-by: Sante Barbuto <[email protected]>
  • Loading branch information
bard83 and Sante Barbuto authored Mar 31, 2022
1 parent 7fb9947 commit 6349893
Show file tree
Hide file tree
Showing 11 changed files with 367 additions and 134 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

name: Unit tests

on:
push:
branches:
- master
pull_request:
types:
- "opened"
- "synchronize"
- "reopened"
env:
NODE_VERSION: '16'

jobs:
test:
name: Test
strategy:
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- run: yarn install
- run: xvfb-run -a yarn test
if: runner.os == 'Linux'
- run: yarn test
if: runner.os != 'Linux'

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@
"compile": "tsc -p ./ && yarn run lint",
"compileDev": "tsc -p ./ && yarn run lint && webpack --mode development",
"watch": "tsc -watch -p ./",
"lint": "eslint src --ext ts"
"lint": "eslint src --ext ts",
"pretest": "tsc -p ./",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.1.3",
Expand All @@ -186,12 +188,13 @@
"@types/xml2js": "^0.4.9",
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.28.5",
"@vscode/test-electron": "^2.1.3",
"eslint": "^7.19.0",
"glob": "^7.1.6",
"mocha": "^8.2.1",
"ts-loader": "^9.2.6",
"tsc": "^2.0.4",
"typescript": "^4.1.3",
"typescript": "^4.6.3",
"vsce": "^2.6.3",
"vscode-test": "^1.5.0",
"webpack": "^5.58.2",
Expand Down
65 changes: 0 additions & 65 deletions test/csprojReader.test.ts

This file was deleted.

22 changes: 0 additions & 22 deletions test/index.ts

This file was deleted.

40 changes: 0 additions & 40 deletions test/projectJsonReader.test.ts

This file was deleted.

24 changes: 24 additions & 0 deletions test/runTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as path from 'path';

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, '../../');

// The path to the extension test runner script
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');

// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error(err);
console.error('Failed to run tests');
process.exit(1);
}
}

main();
Loading

0 comments on commit 6349893

Please sign in to comment.