У меня есть объект, который, когда я печатаю его с console.log без stringify, выглядит так:
SuiteStats {
type: 'suite',
start: 2019 - 06 - 04T13: 04: 10.640Z,
_duration: 6262,
uid: 'District1',
cid: '0-0',
title: 'District',
fullTitle: undefined,
tests: [],
hooks: [],
suites:
[SuiteStats {
type: 'suite',
start: 2019 - 06 - 04T13: 04: 15.271Z,
_duration: 1621,
uid: 'Create District5',
cid: '0-0',
title: '@sanity, @sanityUpgraded, @debug: Create District',
fullTitle: undefined,
tests: [Array],
hooks: [],
suites: [],
end: 2019 - 06 - 04T13: 04: 16.892Z
}
],
end: 2019 - 06 - 04T13: 04: 16.902Z
}
Теперь я хочу получить заголовок SuiteStats, которыйвнутри наборов, которые находятся внутри SuiteStats (это значение: '@sanity, @sanityUpgraded, @debug: Create District')
console.log(SuiteStats.suites[0].title
не работает, выходит с ошибкой о "TypeError: Cannot read property'title' of undefined "
Я безуспешно пробовал другой способ, например:
console.log(SuiteStats.suites[0].SuiteStats.title
, так что я делаю неправильно, и почему этот объект отличается от другого объекта, с которым я работалпрошлое?
вот так выглядит объект после stringify:
{
"type": "suite",
"start": "2019-06-04T13:29:25.385Z",
"_duration": 5575,
"uid": "District1",
"cid": "0-0",
"title": "District",
"tests": [],
"hooks": [],
"suites": [{
"type": "suite",
"start": "2019-06-04T13:29:29.737Z",
"_duration": 1220,
"uid": "Create District5",
"cid": "0-0",
"title": "@sanity, @sanityUpgraded, @debug: Create District",
"tests": [{
"type": "test",
"start": "2019-06-04T13:29:29.745Z",
"_duration": 369,
"uid": "I am logged in as admin user \"ufedadmin\"7",
"cid": "0-0",
"title": "I am logged in as admin user \"ufedadmin\"",
"output": [],
"state": "passed",
"end": "2019-06-04T13:29:30.114Z"
}, {
"type": "test",
"start": "2019-06-04T13:29:30.122Z",
"_duration": 523,
"uid": "I create or overwrite District \"Argentina3\" with code \"Argentina3\"8",
"cid": "0-0",
"title": "I create or overwrite District \"Argentina3\" with code \"Argentina3\"",
"output": [],
"state": "passed",
"end": "2019-06-04T13:29:30.645Z"
}, {
"type": "test",
"start": "2019-06-04T13:29:30.667Z",
"_duration": 283,
"uid": "I expect that district \"Argentina3\" was created9",
"cid": "0-0",
"title": "I expect that district \"Argentina3\" was created",
"output": [],
"state": "passed",
"end": "2019-06-04T13:29:30.950Z"
}
],
"hooks": [],
"suites": [],
"end": "2019-06-04T13:29:30.957Z"
}
],
"end": "2019-06-04T13:29:30.960Z"
}