79801932

Date: 2025-10-27 14:46:31
Score: 0.5
Natty:
Report link

There is another approach for a readonly direct override. @Mostafa Fakhraei did it via a data descriptor - value and a writable flag). There is accessor descriptor - getter & setter. It is:

Object.defineProperty(queue, "CHUNK_SIZE", {
  get: () => 1,
})

Then the result will look like

it('should return true for chunk_size 1', async () => {
  Object.defineProperty(queue, "CHUNK_SIZE", { get: () => 1 })

  const actual = await queue.post({ action: 'UPDATE' });
  expect(actual).toBeTruthy();
});

No setter and only getter to be readonly.

More details about the Object.defineProperty() including enumerable, configurable flags are here.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Mostafa
  • Low reputation (0.5):
Posted by: PIoneer_2