I have a suite of tests that run completely fine in the console and during the first run after starting up the browser session (i.e. karma start). But once I make a change and the browser session auto runs the tests again I'm getting the error below:
Error: <spyOn> : mySpydMethod is not declared writable or has no setter
Usage: spyOn(<object>, <methodName>)
This is a basic skeleton of what I'm doing.
import { mySpydMethod } from "modules/api";
describe(testNumber + '. Component display', () => {
it('the test name', async () => {
spyOn(api, "mySpydMethod ").and.returnValue(Promise.resolve([]));
const vm = new TestVueComponent({
propsData: { showData: true}
}).$mount();
await Vue.nextTick();
const $component = $(vm.$el);
expect($component.find(".wrapper").length).toEqual(1);
vm.$destroy();
});
});
Again, in the console and on the first run in the browser it works just fine. If it get's re-run automatically then it errors on the Spy. Does anyone know what may be causing this issue?
Karma v6.4.2 | karma-jasmine 4.0.2 | karma-chrome-launcher: 3.2.0 | puppeteer: 21.4.1