Skip to content

Commit

Permalink
Merge pull request #21 from tabkram/tests
Browse files Browse the repository at this point in the history
test: trace sync and async errors with times
  • Loading branch information
tabkram authored Feb 11, 2025
2 parents be39f9f + e0657ba commit 3cc2107
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/trace/traceableExecution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('TraceableExecution', () => {
throw new Error(`Sample Error: ${param}`);
}

jest.useFakeTimers();
jest.useFakeTimers({ doNotFake: ['performance'] });

async function asyncThrowErrorFunction(param: string) {
jest.advanceTimersByTime(1000);
Expand All @@ -203,13 +203,13 @@ describe('TraceableExecution', () => {
const nodeId = 'errorTrace_custom_id_1';
traceableExecution.run(throwErrorFunction, ['InputParam'], {
trace: { id: nodeId },
config: { errors: 'catch', traceExecution: { errors: true } }
config: { errors: 'catch', traceExecution: { errors: true, startTime: true, endTime: true } }
});

const nodeId2 = 'errorTrace_custom_id_2';
await traceableExecution.run(asyncThrowErrorFunction, ['InputParam2'], {
trace: { id: nodeId2 },
config: { errors: 'catch', traceExecution: { errors: true } }
config: { errors: 'catch', traceExecution: { errors: true, startTime: true, endTime: true } }
});

const trace = traceableExecution.getTrace();
Expand All @@ -220,6 +220,10 @@ describe('TraceableExecution', () => {
expect(node1?.data).toEqual({
abstract: false,
createTime: expect.any(Date),
startTime: expect.any(Date),
endTime: expect.any(Date),
duration: expect.any(Number),
elapsedTime: expect.any(String),
errors: [
{
message: 'Sample Error: InputParam',
Expand All @@ -235,6 +239,10 @@ describe('TraceableExecution', () => {
expect(node2?.data).toEqual({
abstract: false,
createTime: expect.any(Date),
startTime: expect.any(Date),
endTime: expect.any(Date),
duration: expect.any(Number),
elapsedTime: expect.any(String),
errors: [
{
message: 'Sample Async Error: InputParam2',
Expand Down

1 comment on commit 3cc2107

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 92.37% 242/262
🟢 Branches 86.21% 175/203
🟢 Functions 91.78% 67/73
🟢 Lines 93.09% 229/246

Test suite run success

33 tests passing in 5 suites.

Report generated by 🧪jest coverage report action from 3cc2107

Please sign in to comment.