Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-mock-record

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-mock-record - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

10

client/mock.utilities.js

@@ -40,4 +40,14 @@ Object.defineProperty(exports, "__esModule", { value: true });

};
MockUtilities.prototype.setClient = function (domain) {
browser.executeScript(this.setClientRequest(domain));
};
MockUtilities.prototype.setClientRequest = function (domain) {
var url = this.api_host + '/domain/' + domain;
var xmlHttp = new XMLHttpRequest();
xmlHttp.open('GET', url, false);
xmlHttp.send(null);
return xmlHttp.responseText;
};
return MockUtilities;
}());
exports.MockUtilities = MockUtilities;

2

package.json
{
"name": "angular-mock-record",
"version": "1.2.0",
"version": "1.2.1",
"description": "An angular / protractor framework that mocks and records requests. Requests can be manually mocked or recorded like VCR.",

@@ -5,0 +5,0 @@ "main": "server.js",

@@ -27,4 +27,12 @@ const Utilities = require('./utilities.js');

let recording = this.isRecordingOnTape(requestUrl, tape);
if (recording.length) {
let recordingWithDomain = recording ? recording.find(rec => rec.domain === this.config.domain) : null;
if (recording.length && !recordingWithDomain) {
out = recording[0];
} else if (recordingWithDomain) {
out = recordingWithDomain;
}

@@ -78,2 +86,6 @@ }

if (this.config.domain) {
data.domain = this.config.domain;
}
out.push(data);

@@ -80,0 +92,0 @@

@@ -9,2 +9,3 @@ const Http = require('./http.js');

constructor(config) {
this.defaultDomain = config.domain;
this.config = config;

@@ -29,5 +30,11 @@ this.http = new Http(this.config);

} else if (this.shouldSetDomain(req.path)) {
this.setDomain(req.path);
res.status(200).send(true);
} else if (this.shouldClearMocks(req.path)) {
this.mock.clearMockedRequests();
this.setDefaultDomain();
res.status(200).send(true);

@@ -94,4 +101,24 @@

shouldSetDomain(path) {
return !!( path.includes('/domain/') );
}
setDomain(path) {
path = path.split('/');
this.config.domain = 'https://' + path[path.length - 1];
this.refreshConfigs();
}
setDefaultDomain() {
this.config.domain = this.defaultDomain;
this.refreshConfigs();
}
refreshConfigs() {
this.http = new Http(this.config);
this.recorder = new Record(this.config);
}
}
module.exports = RequestHandler;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc