Open
Description
I'm using moxios in two files to mock out API requests and getting tests that seem to randomly fail.
For example:
import { expect } from 'chai'
import moxios from 'moxios'
import { SharedState, updateRenewal, mbcRequest, fetchVersions } from '../../../app/javascript/packs/sharedState.js'
const genericResponse = {
id: 1,
status: 'approved',
versions: ['underwriting', 'approved']
}
describe('SharedState', () => {
SharedState.currentRenewal = { id: 1 }
beforeAll(() => {
moxios.install()
moxios.stubRequest('/commercial_renewals/1', {
status: 200,
response: genericResponse
})
})
afterAll(() => {
moxios.uninstall()
})
describe('updateRenewal', () => {
let basic_params = {
id: 1,
status: 'approved'
}
it('updates the attributes on the SharedState updatedRenewals field', (done) => {
let attribute = basic_params['status'];
moxios.wait(() => {
updateRenewal(basic_params);
expect(SharedState.updatedRenewals[basic_params['id']]['status']).to.equal(attribute);
done();
})
});
});
...
If I run this test file, followed by another test file with a similar moxios setup, I get various errors around afterAll
and variables being undefined and I don't quite get why.
Metadata
Metadata
Assignees
Labels
No labels
Activity