I'm starting to lean more on `reactiveUtils.watch()` for reactivity that isn't easily handled by my JavaScript framework. Generally, things are going well, but I'm running into an issue with unit/integration tests:
A common issue is that I will want to stub or mock a JS SDK class. For example, I frequently create a fake WebMap with fake layers:
class FakeLayer {
constructor({ id, listMode, visible, type }) {
this.id = id;
this.listMode = listMode;
this.visible = visible;
this.type = type;
}
when = async () => true;
}
const fakeWebMap = {
allLayers: [
new FakeLayer({
id: 'layer-1',
listMode: 'hide',
visible: true,
}),
new FakeLayer({
id: 'layer-2',
listMode: 'hide',
visible: false,
}),
new FakeLayer({
id: 'layer-3',
listMode: 'show',
visible: true,
}),
};
My problem is this: reactiveUtils.watch() does not seem to work on POJOs or custom classes like FakeLayer above.
In the example above, I might be testing code that watches the `visible` property on each FakeLayer and mutates `listMode` if `visible` changes. How can I implement a mock/stub testing class that works with reactiveUtils.watch()?