Skip to content

Make tests run #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "20"
node-version: "22"
- run: echo "./node_modules/.bin" >> $GITHUB_PATH
- run: npm run setup
- run: xvfb-run -a npm run test
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ node_modules/
out/
scripts/
src/
text-run/
text-runner/
**/tsconfig.json
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import tsParser from "@typescript-eslint/parser"
export default [
{
files: ["src/*.ts"],
ignores: ["**/node_modules/", ".git/", "dist/", "out/"],
ignores: ["node_modules/", ".vscode-test", ".git/", "dist/", "out/"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
Expand Down
149 changes: 149 additions & 0 deletions package-lock.json

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

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
"build-dev": "esbuild ./src/extension.ts --bundle --outfile=dist/main.js --external:vscode --format=cjs --platform=node --sourcemap",
"clean": "rm -rf out dist",
"compile": "tsc -p .",
"doc": "text-run --format=dot",
"fix": "eslint . --fix --ext .ts && dprint fmt && sort-package-json --quiet",
"lint": "eslint . --ext .ts && sort-package-json --check --quiet && dprint check && git diff --check",
"doc": "text-runner --format=dot",
"fix": "eslint --fix && dprint fmt && sort-package-json --quiet",
"lint": "eslint && sort-package-json --check --quiet && dprint check && git diff --check",
"list-shipped-files": "vsce ls",
"package": "vsce package",
"publish-major": "vsce publish major",
"publish-minor": "vsce publish minor",
"publish-patch": "vsce publish patch",
"setup": "npm install && npm run build",
"test": "npm run build && npm run lint && npm run unit && npm run doc",
"unit": "npm run compile && node out/test/main.js",
"unit": "npm run build && npm run compile && node out/test/main.js",
"update": "npm-check-updates -u && npm install",
"vscode:prepublish": "npm run build",
"watch": "npm run watch"
Expand Down Expand Up @@ -76,6 +76,7 @@
"@types/vscode": "1.98.0",
"@vscode/test-electron": "2.4.1",
"assert-no-diff": "4.1.0",
"dprint": "^0.49.1",
"esbuild": "0.25.2",
"eslint": "9.23.0",
"mocha": "11.1.0",
Expand Down
36 changes: 16 additions & 20 deletions src/test/run_mocha.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import glob from "glob"
import { glob } from "glob"
import Mocha from "mocha"
import * as path from "path"

export function run(): Promise<void> {
export async function run(): Promise<void> {
const mocha = new Mocha({ ui: "tdd", color: true })
const testsRoot = path.resolve(__dirname, "..")
const files = await glob("**/*.test.js", { cwd: testsRoot })
return new Promise((resolve, reject) => {
glob("**/*.test.js", { cwd: testsRoot }, (err, files) => {
if (err) {
return reject(err)
}
files.forEach(file => mocha.addFile(path.resolve(testsRoot, file)))
try {
mocha.run(failures => {
if (failures > 0) {
reject(new Error(`${failures} tests failed`))
} else {
resolve()
}
})
} catch (err) {
console.error(err)
reject(err)
}
})
files.forEach(file => mocha.addFile(path.resolve(testsRoot, file)))
try {
mocha.run(failures => {
if (failures > 0) {
reject(new Error(`${failures} tests failed`))
} else {
resolve()
}
})
} catch (err) {
console.error(err)
reject(err)
}
})
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"module": "commonjs",
"target": "ES2018",
"outDir": "out",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"rootDir": "src",
"esModuleInterop": true
},
"exclude": ["node_modules", ".vscode-test", "text-run"]
"exclude": ["node_modules", ".vscode-test", "text-runner"]
}