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:
Michal Dorner 2022-08-19 21:53:20 +02:00 committed by GitHub
parent 0d00bb14cb
commit 8848447e3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14043 additions and 12 deletions

View file

@ -1,6 +1,7 @@
import * as core from '@actions/core'
import {TestExecutionResult, TestRunResult, TestSuiteResult} from '../test-results'
import {Align, formatTime, Icon, link, table} from '../utils/markdown-utils'
import {DEFAULT_LOCALE} from '../utils/node-utils'
import {getFirstNonEmptyLine} from '../utils/parse-utils'
import {slug} from '../utils/slugger'
@ -79,9 +80,9 @@ function trimReport(lines: string[]): string {
}
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) {
res.suites.sort((a, b) => a.name.localeCompare(b.name))
res.suites.sort((a, b) => a.name.localeCompare(b.name, DEFAULT_LOCALE))
}
}