mirror of
https://github.com/dorny/test-reporter.git
synced 2026-02-01 02:45:22 -08:00
Use String.substring() function instead of the deprecated String.substr()
This commit is contained in:
@@ -242,13 +242,13 @@ export class DartJsonParser implements TestParser {
|
|||||||
private getRelativePath(path: string): string {
|
private getRelativePath(path: string): string {
|
||||||
const prefix = 'file://'
|
const prefix = 'file://'
|
||||||
if (path.startsWith(prefix)) {
|
if (path.startsWith(prefix)) {
|
||||||
path = path.substr(prefix.length)
|
path = path.substring(prefix.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
path = normalizeFilePath(path)
|
path = normalizeFilePath(path)
|
||||||
const workDir = this.getWorkDir(path)
|
const workDir = this.getWorkDir(path)
|
||||||
if (workDir !== undefined && path.startsWith(workDir)) {
|
if (workDir !== undefined && path.startsWith(workDir)) {
|
||||||
path = path.substr(workDir.length)
|
path = path.substring(workDir.length)
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ export class DotnetNunitParser implements TestParser {
|
|||||||
path = normalizeFilePath(path)
|
path = normalizeFilePath(path)
|
||||||
const workDir = this.getWorkDir(path)
|
const workDir = this.getWorkDir(path)
|
||||||
if (workDir !== undefined && path.startsWith(workDir)) {
|
if (workDir !== undefined && path.startsWith(workDir)) {
|
||||||
path = path.substr(workDir.length)
|
path = path.substring(workDir.length)
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export class DotnetTrxParser implements TestParser {
|
|||||||
const resultTestName = r.result.$.testName
|
const resultTestName = r.result.$.testName
|
||||||
const testName =
|
const testName =
|
||||||
resultTestName.startsWith(className) && resultTestName[className.length] === '.'
|
resultTestName.startsWith(className) && resultTestName[className.length] === '.'
|
||||||
? resultTestName.substr(className.length + 1)
|
? resultTestName.substring(className.length + 1)
|
||||||
: resultTestName
|
: resultTestName
|
||||||
|
|
||||||
const test = new Test(testName, r.result.$.outcome, duration, error)
|
const test = new Test(testName, r.result.$.outcome, duration, error)
|
||||||
@@ -177,7 +177,7 @@ export class DotnetTrxParser implements TestParser {
|
|||||||
const filePath = normalizeFilePath(fileStr)
|
const filePath = normalizeFilePath(fileStr)
|
||||||
const workDir = this.getWorkDir(filePath)
|
const workDir = this.getWorkDir(filePath)
|
||||||
if (workDir) {
|
if (workDir) {
|
||||||
const file = filePath.substr(workDir.length)
|
const file = filePath.substring(workDir.length)
|
||||||
if (trackedFiles.includes(file)) {
|
if (trackedFiles.includes(file)) {
|
||||||
const line = parseInt(lineStr)
|
const line = parseInt(lineStr)
|
||||||
return {path: file, line}
|
return {path: file, line}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export class JestJunitParser implements TestParser {
|
|||||||
path = normalizeFilePath(path)
|
path = normalizeFilePath(path)
|
||||||
const workDir = this.getWorkDir(path)
|
const workDir = this.getWorkDir(path)
|
||||||
if (workDir !== undefined && path.startsWith(workDir)) {
|
if (workDir !== undefined && path.startsWith(workDir)) {
|
||||||
path = path.substr(workDir.length)
|
path = path.substring(workDir.length)
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export class MochaJsonParser implements TestParser {
|
|||||||
private processTest(suite: TestSuiteResult, test: MochaJsonTest, result: TestExecutionResult): void {
|
private processTest(suite: TestSuiteResult, test: MochaJsonTest, result: TestExecutionResult): void {
|
||||||
const groupName =
|
const groupName =
|
||||||
test.fullTitle !== test.title
|
test.fullTitle !== test.title
|
||||||
? test.fullTitle.substr(0, test.fullTitle.length - test.title.length).trimEnd()
|
? test.fullTitle.substring(0, test.fullTitle.length - test.title.length).trimEnd()
|
||||||
: null
|
: null
|
||||||
|
|
||||||
let group = suite.groups.find(grp => grp.name === groupName)
|
let group = suite.groups.find(grp => grp.name === groupName)
|
||||||
@@ -103,7 +103,7 @@ export class MochaJsonParser implements TestParser {
|
|||||||
path = normalizeFilePath(path)
|
path = normalizeFilePath(path)
|
||||||
const workDir = this.getWorkDir(path)
|
const workDir = this.getWorkDir(path)
|
||||||
if (workDir !== undefined && path.startsWith(workDir)) {
|
if (workDir !== undefined && path.startsWith(workDir)) {
|
||||||
path = path.substr(workDir.length)
|
path = path.substring(workDir.length)
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ export class PhpunitJunitParser implements TestParser {
|
|||||||
path = normalizeFilePath(path)
|
path = normalizeFilePath(path)
|
||||||
const workDir = this.getWorkDir(path)
|
const workDir = this.getWorkDir(path)
|
||||||
if (workDir !== undefined && path.startsWith(workDir)) {
|
if (workDir !== undefined && path.startsWith(workDir)) {
|
||||||
path = path.substr(workDir.length)
|
path = path.substring(workDir.length)
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export class RspecJsonParser implements TestParser {
|
|||||||
private processTest(suite: TestSuiteResult, test: RspecExample, result: TestExecutionResult): void {
|
private processTest(suite: TestSuiteResult, test: RspecExample, result: TestExecutionResult): void {
|
||||||
const groupName =
|
const groupName =
|
||||||
test.full_description !== test.description
|
test.full_description !== test.description
|
||||||
? test.full_description.substr(0, test.full_description.length - test.description.length).trimEnd()
|
? test.full_description.substring(0, test.full_description.length - test.description.length).trimEnd()
|
||||||
: null
|
: null
|
||||||
|
|
||||||
let group = suite.groups.find(grp => grp.name === groupName)
|
let group = suite.groups.find(grp => grp.name === groupName)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export function ellipsis(text: string, maxLength: number): string {
|
|||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
return text.substr(0, maxLength - 3) + '...'
|
return text.substring(0, maxLength - 3) + '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatTime(ms: number): string {
|
export function formatTime(ms: number): string {
|
||||||
|
|||||||
@@ -34,6 +34,6 @@ export function getBasePath(path: string, trackedFiles: string[]): string | unde
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const base = path.substr(0, path.length - max.length)
|
const base = path.substring(0, path.length - max.length)
|
||||||
return base
|
return base
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user