diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..847688ff5 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,54 @@ +name: 📊 Code Coverage + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +jobs: + coverage: + runs-on: ubuntu-latest + + env: + CODE_TYPE: stable + CODE_VERSION: max + TEST_RESOURCES: test-resources + + steps: + - name: 👷🏻 Checkout Repository + uses: actions/checkout@v4 + + - name: ⚙️ Setup NodeJS + uses: actions/setup-node@v4 + with: + node-version: 18.x + cache: npm + + - name: 🔧 Install + run: npm ci + + - name: 🔧 Build + run: npm run build + + - name: 🔧 Install - Test Project + run: npm install --workspace=extester-test + + - name: 📊 Run Tests with Coverage enabled + # 'set +e' and 'exit 0' - that means the workflow will not fail even the test failures are present. The failing tests are not directive for the code coverage reports itself + run: | + set +e + xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm run test:coverage + exit 0 + + - name: 💾 Upload Coverage + uses: actions/upload-artifact@v4 + if: always() + with: + name: coverage + path: ${{ github.workspace }}/tests/**/coverage diff --git a/package.json b/package.json index b1aa777b8..d2ad25de7 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "build": "lerna run build", "build:changed": "lerna run build --since main", "test": "npm run ui-test --workspace=extester-test", - "test:coverage": "npm run test -- -- --coverage", + "test:coverage": "npm run ui-test:coverage --workspace=extester-test", "test:build": "npm run build:changed && npm install --workspace=extester-test && npm test" }, "workspaces": [ diff --git a/tests/test-project/package.json b/tests/test-project/package.json index 978ce381f..3e79081c8 100644 --- a/tests/test-project/package.json +++ b/tests/test-project/package.json @@ -192,7 +192,8 @@ "compile": "tsc -p ./ && npm run lint", "lint": "eslint src --ext .ts", "cb-init": "echo hello_ExTester | clipboard", - "ui-test": "npm run cb-init && extest setup-and-run './out/test/cli/order-3.test.js' './out/test/cli/order-2.test.js' './out/test/cli/order-1.test.js' './out/test/**/*.test.js' './out/test/system/clipboard.test.js' -u -i -r . -e ./test-extensions" + "ui-test": "npm run cb-init && extest setup-and-run './out/test/cli/order-3.test.js' './out/test/cli/order-2.test.js' './out/test/cli/order-1.test.js' './out/test/**/*.test.js' './out/test/system/clipboard.test.js' -u -i -r . -e ./test-extensions", + "ui-test:coverage": "MOCHA_GREP='order|clipboard|ExtensionsView|TitleBar' MOCHA_INVERT=true extest setup-and-run './out/test/**/*.test.js' -i -r . -e ./test-extensions --coverage" }, "devDependencies": { "@types/chai": "^4.3.14", diff --git a/tests/test-project/src/test/debug/debug.test.ts b/tests/test-project/src/test/debug/debug.test.ts index 5237b0aa4..ab859f0d2 100644 --- a/tests/test-project/src/test/debug/debug.test.ts +++ b/tests/test-project/src/test/debug/debug.test.ts @@ -1,4 +1,4 @@ -import { ActivityBar, BottomBarPanel, Breakpoint, BreakpointSectionItem, DebugConsoleView, DebugToolbar, DebugView, EditorView, error, Key, TextEditor, TitleBar, until, VSBrowser, WebDriver, Workbench } from 'vscode-extension-tester'; +import { ActivityBar, BottomBarPanel, Breakpoint, BreakpointSectionItem, DebugConsoleView, DebugToolbar, DebugView, EditorView, error, Key, TextEditor, until, VSBrowser, WebDriver, Workbench } from 'vscode-extension-tester'; import * as path from 'path'; import { expect } from "chai"; @@ -28,7 +28,7 @@ describe('Debugging', function () { await (await new ActivityBar().getViewControl('Run and Debug'))?.closeView(); await new BottomBarPanel().toggle(false); - await new TitleBar().select('File', 'Close Folder'); + await new Workbench().executeCommand('Workspaces: Close Workspace'); await new Promise(res => setTimeout(res, 5000)); });