in x-test.js [650:709]
static onReady(context, event) {
if (!context.state.ended) {
const data = event.data.data;
const only = (
Object.values(context.state.its).some(candidate => {
return candidate.only && candidate.parents[0].testId === data.testId;
}) ||
Object.values(context.state.describes).some(candidate => {
return candidate.only && candidate.parents[0].testId === data.testId;
})
);
if (only) {
for (const it of Object.values(context.state.its)) { // eslint-disable-line no-shadow
if (it.parents[0].testId === data.testId) {
if (!it.only) {
const describeParents = it.parents
.filter(candidate => candidate.type === 'describe')
.map(parent => context.state.describes[parent.describeId]);
const hasOnlyDescribeParent = describeParents.some(candidate => candidate.only);
if (!hasOnlyDescribeParent) {
it.directive = 'SKIP';
} else if (!it.directive) {
const lastDescribeParentWithDirective = describeParents.findLast(candidate => !!candidate.directive);
if (lastDescribeParentWithDirective) {
it.directive = lastDescribeParentWithDirective.directive;
}
}
}
}
}
} else {
for (const it of Object.values(context.state.its)) { // eslint-disable-line no-shadow
if (it.parents[0].testId === data.testId) {
if (!it.directive) {
const describeParents = it.parents
.filter(candidate => candidate.type === 'describe')
.map(parent => context.state.describes[parent.describeId]);
const lastDescribeParentWithDirective = describeParents.findLast(candidate => !!candidate.directive);
if (lastDescribeParentWithDirective) {
it.directive = lastDescribeParentWithDirective.directive;
}
}
}
}
}
const stepId = context.state.stepIds.find(candidateId => {
const candidate = context.state.steps[candidateId];
return candidate.type === 'test-start' && candidate.testId === data.testId;
});
const step = context.state.steps[stepId];
if (step.status !== 'running') {
throw new Error('test to ready is not running');
}
const href = XTestRoot.href(context, stepId);
const level = XTestRoot.level(context, stepId);
const tap = XTestTap.subtest(href, level);
XTestRoot.output(context, stepId, tap);
step.status = 'done';
}
}