'Node, Sinon - unable to test constructor agruments

I need to test/assert the constructor call with expected arguments while calling a function but getting an error AssertError: step1,step2 is not a function. I'm using sinon, chai libraries for testing function in nodejs

// pipeline.js
class Pipeline {
  constructor(steps) {
      this.steps = steps;
  }

  run(data) {
      console.log('run steps with data');
  }
}
// job.js
function peformJobs(data, steps) {
  const pipeline = new Pipeline(steps)
  pipeline.run(data)
}
// jobs.test.js
const sinon = require('sinon');
const Pipeline = require('./pipeline')
onst peformJobs = require('./job')
describe('test performJobs function', () => {
  it('should call pipeline with step1, step2', () => {
    sinon.spy(Pipeline, 'constructor');
  
    const data = { some: 'data' };
    const steps = ['step1', 'step2']
    peformJobs(data, steps)
  
    // want to test Pipeline constructor called with the required arguments or not
    sinon.assert.calledWithNew(steps)
  });
});


Solution 1:[1]

If I'd need to choose one of your approaches I would probably choose the first approach.

But I'd probably change the path here.

Instead of using the applications' metrics to decide how many jobs/pods you need I would probably use the queue's metrics.

For that, I used KEDA and I recommend it. Using KEDA can help you scaling your solution and keep using Prometheus only to keep track of what's happening.

KEDA supports Jobs or Deployments. Jobs (ScaledJob) have advantages over deployments (ScaledObject) in some cases. For example, if you can use jobs, you can also leverage from scaling ephemeral nodes or scaling from zero nodes to the needed node count.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fernando Nogueira