Skip to content

Commit

Permalink
fix: execution timer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tabkram committed Nov 24, 2023
1 parent 8c6f362 commit ef30d27
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/timer/executionTimer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { ExecutionTimer } from "./executionTimer";
describe("ExecutionTimer", () => {
let timer: ExecutionTimer;

beforeAll(() => {
// redefining readonly property of the performance object
Object.defineProperty(performance, "now", {
value: jest.fn(),
configurable: true,
writable: true,
});
});

beforeEach(() => {
timer = new ExecutionTimer();
});
Expand Down

1 comment on commit ef30d27

@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

❌ An unexpected error occurred. For more details, check console

Error: The process '/usr/local/bin/npx' failed with exit code 1
St.
Category Percentage Covered / Total
🟡 Statements 64.19% 147/229
🔴 Branches 59.88% 103/172
🟡 Functions 67.19% 43/64
🟡 Lines 65.02% 145/223

Test suite run failed

Failed tests: 6/24. Failed suites: 1/4.
  ● ExecutionTimer › should start the timer

    expect(received).toBeDefined()

    Received: undefined

      19 |   it("should start the timer", () => {
      20 |     timer.start();
    > 21 |     expect(timer.getStartDate()).toBeDefined();
         |                                  ^
      22 |   });
      23 |
      24 |   it("should stop the timer", () => {

      at Object.<anonymous> (src/timer/executionTimer.spec.ts:21:34)

  ● ExecutionTimer › should stop the timer

    expect(received).toBeDefined()

    Received: undefined

      25 |     timer.start();
      26 |     timer.stop();
    > 27 |     expect(timer.getEndDate()).toBeDefined();
         |                                ^
      28 |   });
      29 |
      30 |   it("should get the duration", () => {

      at Object.<anonymous> (src/timer/executionTimer.spec.ts:27:32)

  ● ExecutionTimer › should get the start date in ISO format

    expect(received).toBe(expected) // Object.is equality

    Expected: true
    Received: false

      39 |   it("should get the start date in ISO format", () => {
      40 |     timer.start();
    > 41 |     expect(timer.getStartDate() instanceof Date).toBe(true);
         |                                                  ^
      42 |   });
      43 |
      44 |   it("should get the end date in ISO format", () => {

      at Object.<anonymous> (src/timer/executionTimer.spec.ts:41:50)

  ● ExecutionTimer › should get the end date in ISO format

    expect(received).toBe(expected) // Object.is equality

    Expected: true
    Received: false

      45 |     timer.start();
      46 |     timer.stop();
    > 47 |     expect(timer.getEndDate() instanceof Date).toBe(true);
         |                                                ^
      48 |   });
      49 |
      50 |   it("should get the duration with a custom execution ID", () => {

      at Object.<anonymous> (src/timer/executionTimer.spec.ts:47:48)

  ● ExecutionTimer › should get the start date with a custom execution ID

    expect(received).toBe(expected) // Object.is equality

    Expected: true
    Received: false

      60 |     const customId = "customId";
      61 |     timer.start(customId);
    > 62 |     expect(timer.getStartDate(customId) instanceof Date).toBe(true);
         |                                                          ^
      63 |   });
      64 |
      65 |   it("should get the end date with a custom execution ID", () => {

      at Object.<anonymous> (src/timer/executionTimer.spec.ts:62:58)

  ● ExecutionTimer › should get the end date with a custom execution ID

    expect(received).toBe(expected) // Object.is equality

    Expected: true
    Received: false

      67 |     timer.start(customId);
      68 |     timer.stop(customId);
    > 69 |     expect(timer.getEndDate(customId) instanceof Date).toBe(true);
         |                                                        ^
      70 |   });
      71 |
      72 |   it("should get human-readable elapsed time for a duration", () => {

      at Object.<anonymous> (src/timer/executionTimer.spec.ts:69:56)

Report generated by 🧪jest coverage report action from ef30d27

Please sign in to comment.