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,3 +1,5 @@
import {DEFAULT_LOCALE} from './utils/node-utils'
export class TestRunResult {
constructor(readonly path: string, readonly suites: TestSuiteResult[], private totalTime?: number) {}
@ -28,7 +30,7 @@ export class TestRunResult {
}
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) {
for (const suite of this.suites) {
suite.sort(deep)
@ -66,7 +68,7 @@ export class TestSuiteResult {
}
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) {
for (const grp of this.groups) {
grp.sort()
@ -100,7 +102,7 @@ export class TestGroupResult {
}
sort(): void {
this.tests.sort((a, b) => a.name.localeCompare(b.name))
this.tests.sort((a, b) => a.name.localeCompare(b.name, DEFAULT_LOCALE))
}
}