Fix test flake.
This commit is contained in:
parent
9df9f2bac7
commit
110de112c4
|
@ -26,7 +26,7 @@ export function csv(
|
|||
headers.map(header => {
|
||||
const val = row[header]
|
||||
if (typeof val === "object" && !(val instanceof Date)) {
|
||||
return `"${JSON.stringify(val).replace(/"/g, "'")}"`
|
||||
return `"${escapeCsvString(JSON.stringify(val))}"`
|
||||
}
|
||||
if (val !== undefined) {
|
||||
return `"${escapeCsvString(val.toString())}"`
|
||||
|
|
|
@ -270,20 +270,6 @@ function parseJsonExport<T>(value: any) {
|
|||
if (typeof value !== "string") {
|
||||
return value
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(value)
|
||||
|
||||
return parsed as T
|
||||
} catch (e: any) {
|
||||
if (
|
||||
e.message.startsWith("Expected property name or '}' in JSON at position ")
|
||||
) {
|
||||
// This was probably converted as CSV and it has single quotes instead of double ones
|
||||
const parsed = JSON.parse(value.replace(/'/g, '"'))
|
||||
return parsed as T
|
||||
}
|
||||
|
||||
// It is no a valid JSON
|
||||
throw e
|
||||
}
|
||||
const parsed = JSON.parse(value)
|
||||
return parsed as T
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue