test: fix nock usage

by default, nock intercepts and redirects everything to 127.0.0.1:80
this is regardless of any http request is mocked or not

nock.isActive() - is interceptor active
nock.restore() removes the interceptor
nock.activate() - enables interceptor again

nock.cleanAll() - deletes all mocks. nothing to do with interceptor
nock.activeMock() - to get the active mocks
nock.persist(true/false) - the mock will reply once and set isDone(). but you can persist(true)
This commit is contained in:
Girish Ramakrishnan
2025-06-06 15:49:07 +02:00
parent 0f3eb42332
commit 5cf266c5be
+5 -1
View File
@@ -8,12 +8,16 @@
const common = require('./common.js'),
expect = require('expect.js'),
nock = require('nock'),
system = require('../system.js');
describe('System', function () {
const { setup, cleanup } = common;
before(setup);
before(async function () {
await setup();
if (nock.isActive()) nock.restore(); // required to connect to the docker socket
});
after(cleanup);
it('can get filesystems', async function () {