Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public done() {
// scope.done() will throw an error if there are expected api calls that have not happened.
// So ensures that all expected calls have been made.
this.scope.done();
// Remove 'no match' handler, for tests using nock without this module
nock.emitter.removeListener('no match', this.handleUnexpectedRequest);
// Restore unmocked behaviour
nock.cleanAll();
nock.restore();
}
beforeEach('Setting up Fake Server', function bef() {
deleted = clearHelixEnv();
this.timeout(5000);
writeDictItem = sinon.fake.resolves(true);
purgeAll = sinon.fake.resolves(true);
RemotePublishCommand = proxyquire('../src/remotepublish.cmd', {
'@adobe/fastly-native-promises': () => ({
transact: (fn) => fn(3),
writeDictItem,
purgeAll,
}),
});
// ensure to reset nock to avoid conflicts with PollyJS
nock.restore();
nock.cleanAll();
nock.activate();
scope = nock('https://adobeioruntime.net')
.post('/api/v1/web/helix/helix-services/publish@v2')
.reply(200, {})
.post('/api/v1/web/helix/helix-services/logging@v1')
.reply(200, {});
});
setupNock() {
nock.restore();
nock.cleanAll();
const interceptor = nock(/.*/).persist();
const recorder = this;
Object.keys(Methods).forEach((m) => {
interceptor
.intercept(/.*/, m)
.reply(async function reply(uri, body, respond) {
// @ts-ignore
const { method, req } = this as any;
const { headers } = req;
const [options] = REQUEST_ARGUMENTS.get(req);
const interceptedRequest: InterceptedRequest = {
body,
test.after.always('cleanup', t => {
nock.cleanAll();
nock.restore();
});
afterEach(async () => {
nock.cleanAll();
nock.restore();
await removeFile(destChainJsonPath);
});
after(() => {
nock.restore()
})
}
after(function() {
nock.cleanAll();
nock.restore();
});
});
function nockReset() {
nock.cleanAll();
nock.recorder.clear();
nock.restore();
}
function startRecording(options) {
nock.restore();
nock.recorder.clear();
nock.recorder.rec(options.recorder);
}