Skip to content

Commit

Permalink
test: Test fix 3
Browse files Browse the repository at this point in the history
  • Loading branch information
this-is-shivamsingh committed Jan 27, 2025
1 parent 9f8f020 commit 375d3c5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/core/test/percy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1495,18 +1495,27 @@ describe('Percy', () => {
discovery: { concurrency: 5 }
});

spyOn(percy.monitoring, 'startMonitoring').and.callFake(() => Promise.resolve());
mockRestSystemMonitor = spyOn(percy, 'resetSystemMonitor').and.callFake(() => Promise.resolve());
mockConfigureSystem = spyOn(percy, 'configureSystemMonitor').and.callThrough();
mockRestSystemMonitor = spyOn(percy, 'resetSystemMonitor').and.callThrough();
});

afterEach(async () => {
await percy.stop(true);
});

describe('when monitoring is already started', () => {
beforeEach(() => {
percy.monitoring.running = true;
});

afterEach(() => {
percy.monitoring.running = false;
});

it('should not configure system monitoring again', async () => {
await percy.start();
expect(percy.monitoring.running).toEqual(true);
expect(mockConfigureSystem).toHaveBeenCalled();

mockConfigureSystem.calls.reset();
mockRestSystemMonitor.calls.reset();
Expand All @@ -1518,7 +1527,7 @@ describe('Percy', () => {

it('early exist if called in interval < MONITORING_INTERVAL', async () => {
await percy.start();
expect(percy.monitoring.running).toEqual(true);
expect(mockConfigureSystem).toHaveBeenCalled();
expect(mockRestSystemMonitor).toHaveBeenCalled();

mockRestSystemMonitor.calls.reset();
Expand All @@ -1539,7 +1548,7 @@ describe('Percy', () => {
describe('when monitoring is stopped', () => {
it('should configure system monitoring', async () => {
await percy.start();
expect(percy.monitoring.running).toEqual(true);
expect(mockConfigureSystem).toHaveBeenCalled();

// stopping monitoring
await percy.monitoring.stopMonitoring();
Expand Down

0 comments on commit 375d3c5

Please sign in to comment.