Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function serenityResultFrom(stepStatus: string, error?: Error): Result {
const timeOut = (e: Error) => e && /timed out/.test(e.message);
const results = {
undefined: Result.PENDING,
failed: Result.FAILURE,
pending: Result.PENDING,
passed: Result.SUCCESS,
skipped: Result.SKIPPED,
};
if (! results[stepStatus]) {
throw new Error(`Couldn't map the '${ stepStatus }' to a Serenity Result`);
}
return timeOut(error)
? Result.ERROR
: results[stepStatus];
}
function serenityResultFrom(stepStatus: string, error?: Error): Result {
const timeOut = (e: Error) => e && /timed out/.test(e.message);
const results = {
undefined: Result.PENDING,
failed: Result.FAILURE,
pending: Result.PENDING,
passed: Result.SUCCESS,
skipped: Result.SKIPPED,
};
if (! results[stepStatus]) {
throw new Error(`Couldn't map the '${ stepStatus }' to a Serenity Result`);
}
return timeOut(error)
? Result.ERROR
: results[stepStatus];
}
function serenityResultFrom(stepStatus: string, error?: Error): Result {
const timeOut = (e: Error) => e && /timed out/.test(e.message);
const results = {
undefined: Result.PENDING,
ambiguous: Result.ERROR,
failed: Result.FAILURE,
pending: Result.PENDING,
passed: Result.SUCCESS,
skipped: Result.SKIPPED,
};
if (! results[stepStatus]) {
throw new Error(`Couldn't map '${ stepStatus }' to a Serenity Result`);
}
return timeOut(error)
? Result.ERROR
: results[stepStatus];
}
static from = (result: StepResult | ScenarioResult) => {
const isTimeOut = (e: Error) => e && /timed out/.test(e.message);
const results = {
undefined: Result.PENDING,
failed: Result.FAILURE,
pending: Result.PENDING,
passed: Result.SUCCESS,
skipped: Result.SKIPPED,
};
if (!results[ result.status ]) {
throw new Error(`Couldn't map the '${ result.status }' to a Serenity Result`);
}
return isTimeOut(realErrorFrom(result.failureException))
? Result.ERROR
: results[ result.status ];
}
}
return expect(spawned.result).to.be.eventually.fulfilled.then(() => {
expect(spawned.messages).to.have.length.greaterThan(2);
const event = lastOf(SceneFinished, spawned.messages);
expect(Result[event.value.result]).to.equal(Result[Result.PENDING]);
});
});
return expect(spawned.result).to.be.eventually.fulfilled.then(() => {
expect(spawned.messages).to.have.lengthOf(2);
const event = lastOf(SceneFinished, spawned.messages);
expect(Result[event.value.result]).to.equal(Result[Result.PENDING]);
});
});
return expect(spawned.result).to.be.eventually.fulfilled.then(() => {
expect(spawned.messages).to.have.lengthOf(4);
expect(spawned.messages[0].value.name).to.equal(scenario);
expect(spawned.messages[1].value.name).to.equal(step);
expect(spawned.messages[2].value.subject.name).to.equal(step);
expect(Result[spawned.messages[3].value.result]).to.equal(Result[Result.PENDING]);
expect(spawned.messages[3].value.subject.name).to.equal(scenario);
expect(Result[spawned.messages[3].value.result]).to.equal(Result[Result.PENDING]);
});
});
return expect(spawned.result).to.be.eventually.fulfilled.then(() => {
expect(spawned.messages).to.have.lengthOf(messagesPerStep);
const lastMessage = spawned.messages.pop();
expect(lastMessage).to.be.instanceOf(SceneFinished);
expect(Result[lastMessage.value.result]).to.equal(Result[Result.PENDING]);
});
});
lastMessages.forEach(lastMessage => {
expect(lastMessage).to.be.instanceOf(SceneFinished);
expect(Result[lastMessage.value.result]).to.equal(Result[Result.PENDING]);
});
});