Fail tests for unmocked axios requests
This commit is contained in:
parent
69f9ec77c2
commit
13bb3483d8
1 changed files with 14 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
import axios from '~/lib/utils/axios_utils';
|
||||
|
||||
const testTimeoutInMs = 300;
|
||||
jest.setTimeout(testTimeoutInMs);
|
||||
|
||||
|
@ -14,3 +16,15 @@ afterEach(() => {
|
|||
throw new Error(`Test took too long (${elapsedTimeInMs}ms > ${testTimeoutInMs}ms)!`);
|
||||
}
|
||||
});
|
||||
|
||||
// fail tests for unmocked requests
|
||||
beforeEach(done => {
|
||||
axios.defaults.adapter = config => {
|
||||
const error = new Error(`Unexpected unmocked request: ${JSON.stringify(config, null, 2)}`);
|
||||
error.config = config;
|
||||
done.fail(error);
|
||||
return Promise.reject(error);
|
||||
};
|
||||
|
||||
done();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue