Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
Trying to get test coverage setup
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpowell committed Jun 28, 2019
1 parent 3971fc6 commit 8da9c84
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ out
node_modules
.vscode-test/
*.vsix
.ionide
.ionide
test-output.xml
155 changes: 137 additions & 18 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,144 @@
trigger:
branches:
include:
- master
pr:
- master

pool:
vmImage: 'ubuntu-latest'
jobs:
- job: Linux
pool:
name: ubuntu-latest
demands: npm
strategy:
matrix:
node_10_x:
node_version: 10.x
node_12_x:
node_version: 12.x
steps:
- task: NodeTool@0
displayName: 'Use $(node_version)'
inputs:
versionSpec: $(node_version)

steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@1
displayName: 'Install dependencies'
inputs:
verbose: false
command: install

- script: |
npm install
npm run compile
displayName: 'npm install and build'
- task: Npm@1
displayName: 'Compile Extension'
inputs:
command: custom
verbose: false
customCommand: 'run compile'

- script: |
npm run package -- -o release.vsix
displayName: 'create vsix'
# starts a process that allows the vscode test environment to run
- script: |
set -e
/usr/bin/Xvfb :10 -ac >> /tmp/Xvfb.out 2>&1 &
disown -ar
displayName: 'Start xvfb'
- task: PublishPipelineArtifact@0
displayName: 'Publish Pipeline Artifact'
inputs:
targetPath: release.vsix
- task: Npm@1
displayName: 'Run tests via npm script'
inputs:
command: custom
verbose: false
customCommand: 'run test:ci'
env:
DISPLAY: :10

- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFiles: '*-results.xml'
testRunTitle: '$(Agent.OS)'
condition: succeededOrFailed()

- script: |
npx vsce package -o release.vsix
displayName: 'create vsix'
- task: PublishPipelineArtifact@0
displayName: 'Publish Pipeline Artifact'
inputs:
targetPath: release.vsix

- job: Windows
pool:
name: Hosted VS2017
demands: npm
steps:
- task: NodeTool@0
displayName: 'Use Node 10.x'
inputs:
versionSpec: 10.x

- task: Npm@1
displayName: 'Install dependencies'
inputs:
verbose: false
command: install

- task: Npm@1
displayName: 'Compile Extension'
inputs:
command: custom
verbose: false
customCommand: 'run compile'

- task: Npm@1
displayName: 'Run tests via npm script'
inputs:
command: custom
verbose: false
customCommand: 'run test:ci'
env:
DISPLAY: :10

- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFiles: '*-results.xml'
testRunTitle: '$(Agent.OS)'
condition: succeededOrFailed()

- job: macOS
pool:
name: Hosted macOS
demands: npm
steps:
- task: NodeTool@0
displayName: 'Use Node 10.x'
inputs:
versionSpec: 10.x

- task: Npm@1
displayName: 'Install dependencies'
inputs:
verbose: false
command: install

- task: Npm@1
displayName: 'Compile Extension'
inputs:
command: custom
verbose: false
customCommand: 'run compile'

- task: Npm@1
displayName: 'Run tests via npm script'
inputs:
command: custom
verbose: false
customCommand: 'run test:ci'

- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFiles: '*-results.xml'
testRunTitle: '$(Agent.OS)'
condition: succeededOrFailed()
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"watch": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "npm run compile && node ./node_modules/vscode/bin/test",
"test:ci": "node ./node_modules/vscode/bin/test",
"package": "npx vsce package",
"publish": "npx vsce publish",
"lint": "tslint --project tsconfig.json -e src/*.d.ts -t verbose"
Expand All @@ -93,6 +94,7 @@
"@types/mocha": "^2.2.42",
"@types/node": "^11.13.0",
"chai": "^4.2.0",
"mocha-multi-reporters": "^1.1.7",
"tslint": "^5.12.1",
"typescript": "^3.3.1",
"vscode": "^1.1.28"
Expand Down
10 changes: 9 additions & 1 deletion src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@
// a possible error to the callback or null if none.

import * as testRunner from "vscode/lib/testrunner";
import * as path from "path";

// You can directly control Mocha options by configuring the test runner below
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
// for more info
testRunner.configure({
ui: "tdd", // the TDD UI is being used in extension.test.ts (suite, test, etc.)
useColors: true, // colored output from test results,
timeout: 7500
timeout: 7500,
reporter: "mocha-multi-reporters",
reporterOptions: {
reporterEnabled: "spec, xunit",
xunitReporterOptions: {
output: path.join(__dirname, "..", "..", "test-results.xml")
}
}
});

module.exports = testRunner;

0 comments on commit 8da9c84

Please # to comment.