mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Fix tests on non us-EN local env (#185)
* Fix tests on non us-EN local env Different locale might result in different alphabetical order of tests in report. Tests using snapshot comparison then fails * Fix code style
This commit is contained in:
parent
0d00bb14cb
commit
8848447e3f
4 changed files with 14043 additions and 12 deletions
14040
package-lock.json
generated
14040
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,7 @@
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {TestExecutionResult, TestRunResult, TestSuiteResult} from '../test-results'
|
import {TestExecutionResult, TestRunResult, TestSuiteResult} from '../test-results'
|
||||||
import {Align, formatTime, Icon, link, table} from '../utils/markdown-utils'
|
import {Align, formatTime, Icon, link, table} from '../utils/markdown-utils'
|
||||||
|
import {DEFAULT_LOCALE} from '../utils/node-utils'
|
||||||
import {getFirstNonEmptyLine} from '../utils/parse-utils'
|
import {getFirstNonEmptyLine} from '../utils/parse-utils'
|
||||||
import {slug} from '../utils/slugger'
|
import {slug} from '../utils/slugger'
|
||||||
|
|
||||||
|
|
@ -79,9 +80,9 @@ function trimReport(lines: string[]): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
function applySort(results: TestRunResult[]): void {
|
function applySort(results: TestRunResult[]): void {
|
||||||
results.sort((a, b) => a.path.localeCompare(b.path))
|
results.sort((a, b) => a.path.localeCompare(b.path, DEFAULT_LOCALE))
|
||||||
for (const res of results) {
|
for (const res of results) {
|
||||||
res.suites.sort((a, b) => a.name.localeCompare(b.name))
|
res.suites.sort((a, b) => a.name.localeCompare(b.name, DEFAULT_LOCALE))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {DEFAULT_LOCALE} from './utils/node-utils'
|
||||||
|
|
||||||
export class TestRunResult {
|
export class TestRunResult {
|
||||||
constructor(readonly path: string, readonly suites: TestSuiteResult[], private totalTime?: number) {}
|
constructor(readonly path: string, readonly suites: TestSuiteResult[], private totalTime?: number) {}
|
||||||
|
|
||||||
|
|
@ -28,7 +30,7 @@ export class TestRunResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(deep: boolean): void {
|
sort(deep: boolean): void {
|
||||||
this.suites.sort((a, b) => a.name.localeCompare(b.name))
|
this.suites.sort((a, b) => a.name.localeCompare(b.name, DEFAULT_LOCALE))
|
||||||
if (deep) {
|
if (deep) {
|
||||||
for (const suite of this.suites) {
|
for (const suite of this.suites) {
|
||||||
suite.sort(deep)
|
suite.sort(deep)
|
||||||
|
|
@ -66,7 +68,7 @@ export class TestSuiteResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(deep: boolean): void {
|
sort(deep: boolean): void {
|
||||||
this.groups.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? ''))
|
this.groups.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? '', DEFAULT_LOCALE))
|
||||||
if (deep) {
|
if (deep) {
|
||||||
for (const grp of this.groups) {
|
for (const grp of this.groups) {
|
||||||
grp.sort()
|
grp.sort()
|
||||||
|
|
@ -100,7 +102,7 @@ export class TestGroupResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(): void {
|
sort(): void {
|
||||||
this.tests.sort((a, b) => a.name.localeCompare(b.name))
|
this.tests.sort((a, b) => a.name.localeCompare(b.name, DEFAULT_LOCALE))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import {normalizeFilePath} from './path-utils'
|
import {normalizeFilePath} from './path-utils'
|
||||||
|
|
||||||
|
export const DEFAULT_LOCALE = 'en-US'
|
||||||
|
|
||||||
export function getExceptionSource(
|
export function getExceptionSource(
|
||||||
stackTrace: string,
|
stackTrace: string,
|
||||||
trackedFiles: string[],
|
trackedFiles: string[],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue