I have been trying to setup mocha/chai tests for my vuex mutations. However, I get an error saying:
mutations.spec.js: 'return' outside of function (1:20)
> 1 | const _f38=exports;return _f38.r((function *(exports,require){"use strict";"main";let mutations;_f38.w("../src/View/store/modules/agenda/mutations",[["mutations",["mutations"],function(v){mutations=v}]]);let expect;_f38.w("chai",[["expect",["expect"],function(v){expect=v}]]);yield;
My mutations.js file is:
const setEditedItemIndex = (state, newIndex) => {
state.editedIndex = newIndex;
};
export default {
setEditedItemIndex
}
My mutations.spec.js file is
import { mutations } from '../src/View/store/modules/agenda/mutations';
import { expect } from 'chai';
describe('mutations', () => {
it ('should change the edited item index', () => {
const state = { editedIndex: -1 };
mutations.setEditedItemIndex(state, 1);
expect(state.editedIndex).to.equal(1);
})
})
and the command I am running is
./node_modules/mocha/bin/mocha -r esm -r @babel/register './test/**/*.spec.js'
I have tried the solution as documented in this comment, but that doesn't work and the next solution seems to point to a read only project.