vitest-github-actions-reporter
Advanced tools
Comparing version 0.9.0 to 0.10.0
import { Reporter, Vitest, File } from 'vitest'; | ||
declare type GitHubActionsReporterOptions = { | ||
type GitHubActionsReporterOptions = { | ||
/** | ||
@@ -5,0 +5,0 @@ * @default true |
@@ -9,5 +9,11 @@ // src/index.ts | ||
// src/stacktrace/parse.ts | ||
import path from "node:path"; | ||
var stackIgnorePatterns = [ | ||
"node:internal", | ||
/\/packages\/\w+\/dist\//, | ||
/\/@vitest\/\w+\/dist\//, | ||
"/vitest/dist/", | ||
"/vitest/src/", | ||
"/vite-node/dist/", | ||
"/vite-node/src/", | ||
"/node_modules/chai/", | ||
@@ -18,2 +24,3 @@ "/node_modules/tinypool/", | ||
var slash = (str) => str.replace(/\\/g, "/"); | ||
var resolve = (str) => slash(path.resolve(str)); | ||
function notNullish(v) { | ||
@@ -31,29 +38,34 @@ return v != null; | ||
} | ||
function parseSingleStack(raw) { | ||
let line = raw.trim(); | ||
if (line.includes("(eval ")) | ||
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""); | ||
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""); | ||
const location = sanitizedLine.match(/ (\(.+\)$)/); | ||
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine; | ||
const [url, lineNumber, columnNumber] = extractLocation( | ||
location ? location[1] : sanitizedLine | ||
); | ||
let method = location && sanitizedLine || ""; | ||
let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url; | ||
if (!file || !lineNumber || !columnNumber) | ||
return null; | ||
if (method.startsWith("async ")) | ||
method = method.slice(6); | ||
if (file.startsWith("file://")) | ||
file = file.slice(7); | ||
file = resolve(file); | ||
return { | ||
method, | ||
file, | ||
line: parseInt(lineNumber), | ||
column: parseInt(columnNumber) | ||
}; | ||
} | ||
var parseStacktrace = (stackStr, full = false) => { | ||
const stackFrames = stackStr.split("\n").map((raw) => { | ||
let line = raw.trim(); | ||
if (line.includes("(eval ")) | ||
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""); | ||
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""); | ||
const location = sanitizedLine.match(/ (\(.+\)$)/); | ||
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine; | ||
const [url, lineNumber, columnNumber] = extractLocation( | ||
location ? location[1] : sanitizedLine | ||
); | ||
let method = location && sanitizedLine || ""; | ||
let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url; | ||
if (!file || !lineNumber || !columnNumber) | ||
const stack = parseSingleStack(raw); | ||
if (!stack || !full && stackIgnorePatterns.some((p) => stack.file.match(p))) | ||
return null; | ||
if (method.startsWith("async ")) | ||
method = method.slice(6); | ||
if (file.startsWith("file://")) | ||
file = file.slice(7); | ||
if (!full && stackIgnorePatterns.some((p) => file && file.includes(p))) | ||
return null; | ||
return { | ||
method, | ||
file: slash(file), | ||
line: parseInt(lineNumber), | ||
column: parseInt(columnNumber) | ||
}; | ||
return stack; | ||
}).filter(notNullish); | ||
@@ -129,3 +141,3 @@ return stackFrames; | ||
this.reportTest(filename, task); | ||
} else if (task.type === "benchmark") { | ||
} else if (task.type === "custom") { | ||
} else { | ||
@@ -132,0 +144,0 @@ checkNever(task); |
{ | ||
"name": "vitest-github-actions-reporter", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "Vitest reporter to create annotations when running tests in GitHub Actions", | ||
@@ -19,9 +19,2 @@ "type": "module", | ||
], | ||
"scripts": { | ||
"build": "tsup", | ||
"test": "vitest", | ||
"lint": "eslint --cache .", | ||
"format": "prettier --write --cache .", | ||
"type-check": "tsc --noEmit" | ||
}, | ||
"engines": { | ||
@@ -45,19 +38,28 @@ "node": ">=14.16.0" | ||
"peerDependencies": { | ||
"vitest": ">=0.16.0" | ||
"vitest": ">=0.28.5" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16.11.58", | ||
"@typescript-eslint/eslint-plugin": "^5.41.0", | ||
"@typescript-eslint/parser": "^5.41.0", | ||
"eslint": "^8.26.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"execa": "^6.1.0", | ||
"prettier": "^2.7.1", | ||
"tsup": "^6.3.0", | ||
"typescript": "^4.8.4", | ||
"vitest": "^0.24.3" | ||
"@types/node": "^18.14.1", | ||
"@typescript-eslint/eslint-plugin": "^5.53.0", | ||
"@typescript-eslint/parser": "^5.53.0", | ||
"eslint": "^8.35.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
"execa": "^7.0.0", | ||
"prettier": "^2.8.4", | ||
"tsup": "^6.6.3", | ||
"typescript": "^4.9.5", | ||
"vite": "^4.1.4", | ||
"vitest": "^0.29.1" | ||
}, | ||
"dependencies": { | ||
"@actions/core": "^1.10.0" | ||
}, | ||
"packageManager": "pnpm@7.28.0", | ||
"scripts": { | ||
"build": "tsup", | ||
"test": "vitest", | ||
"lint": "eslint --cache .", | ||
"format": "prettier --write --cache .", | ||
"type-check": "tsc --noEmit" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49890
9
658
11
3