Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await this._loadFromPath(this.init);
else {
const { path: initPath, content: initContent, module: initModule, page: initPage } = this.init as ClientScript;
if (initPath && initContent || initPath && initModule || initContent && initModule)
throw new GeneralError(RUNTIME_ERRORS.clientScriptInitializerMultipleContentSources);
if (initPath)
await this._loadFromPath(initPath);
else if (initModule)
await this._loadFromModule(initModule);
else
this.content = initContent;
if (initPage)
this.page = new RequestFilterRule(initPage);
}
this._calculateHash();
this._prepareUrl();
}
respond (body, statusCode, headers) {
if (!this.pendingRequestFilterRuleInit)
throw new APIError('respond', RUNTIME_ERRORS.requestHookConfigureAPIError, RequestMock.name, "The 'onRequestTo' method was not called before 'respond'. You must call the 'onRequestTo' method to provide the URL requests to which are mocked.");
const mock = new ResponseMock(body, statusCode, headers);
const rule = new RequestFilterRule(this.pendingRequestFilterRuleInit);
this.requestFilterRules.push(rule);
this.mocks.set(rule, mock);
this.pendingRequestFilterRuleInit = null;
return this;
}
}
this.requestFilterRules.forEach(rule => {
const instantiatedRule = rule instanceof RequestFilterRule ? rule : new RequestFilterRule(rule);
this._instantiatedRequestFilterRules.push(instantiatedRule);
});
}