Best JavaScript code snippet using mountebank
impostersControllerTest.js
Source:impostersControllerTest.js
1'use strict';2var assert = require('assert'),3 mock = require('../mock').mock,4 Controller = require('../../src/controllers/impostersController'),5 FakeResponse = require('../fakes/fakeResponse'),6 Q = require('q'),7 promiseIt = require('../testHelpers').promiseIt;8describe('ImpostersController', function () {9 var response;10 beforeEach(function () {11 response = FakeResponse.create();12 });13 describe('#get', function () {14 it('should send an empty array if no imposters', function () {15 var controller = Controller.create({}, {});16 controller.get({ url: '/imposters' }, response);17 assert.deepEqual(response.body, { imposters: [] });18 });19 it('should send list JSON for all imposters by default', function () {20 var firstImposter = { toJSON: mock().returns('firstJSON') },21 secondImposter = { toJSON: mock().returns('secondJSON') },22 controller = Controller.create({}, { 1: firstImposter, 2: secondImposter });23 controller.get({ url: '/imposters' }, response);24 assert.deepEqual(response.body, { imposters: ['firstJSON', 'secondJSON'] });25 assert.ok(firstImposter.toJSON.wasCalledWith({ replayable: false, removeProxies: false, list: true }), firstImposter.toJSON.message());26 assert.ok(secondImposter.toJSON.wasCalledWith({ replayable: false, removeProxies: false, list: true }), secondImposter.toJSON.message());27 });28 it('should send replayable JSON for all imposters if querystring present', function () {29 var firstImposter = { toJSON: mock().returns('firstJSON') },30 secondImposter = { toJSON: mock().returns('secondJSON') },31 controller = Controller.create({}, { 1: firstImposter, 2: secondImposter });32 controller.get({ url: '/imposters?replayable=true' }, response);33 assert.deepEqual(response.body, { imposters: ['firstJSON', 'secondJSON'] });34 assert.ok(firstImposter.toJSON.wasCalledWith({ replayable: true, removeProxies: false, list: false }), firstImposter.toJSON.message());35 assert.ok(secondImposter.toJSON.wasCalledWith({ replayable: true, removeProxies: false, list: false }), secondImposter.toJSON.message());36 });37 it('should send replayable and removeProxies JSON for all imposters if querystring present', function () {38 var firstImposter = { toJSON: mock().returns('firstJSON') },39 secondImposter = { toJSON: mock().returns('secondJSON') },40 controller = Controller.create({}, { 1: firstImposter, 2: secondImposter });41 controller.get({ url: '/imposters?replayable=true&removeProxies=true' }, response);42 assert.deepEqual(response.body, { imposters: ['firstJSON', 'secondJSON'] });43 assert.ok(firstImposter.toJSON.wasCalledWith({ replayable: true, removeProxies: true, list: false }), firstImposter.toJSON.message());44 assert.ok(secondImposter.toJSON.wasCalledWith({ replayable: true, removeProxies: true, list: false }), secondImposter.toJSON.message());45 });46 });47 describe('#post', function () {48 var request, Imposter, imposter, imposters, Protocol, controller, logger;49 beforeEach(function () {50 request = { body: {}, socket: { remoteAddress: 'host', remotePort: 'port' } };51 imposter = {52 url: mock().returns('imposter-url'),53 toJSON: mock().returns('JSON')54 };55 Imposter = {56 create: mock().returns(Q(imposter))57 };58 imposters = {};59 Protocol = {60 name: 'http',61 Validator: {62 create: mock().returns({ validate: mock().returns(Q({ isValid: true })) })63 }64 };65 logger = { debug: mock(), warn: mock() };66 controller = Controller.create({ http: Protocol }, imposters, Imposter, logger);67 });68 promiseIt('should return a 201 with the Location header set', function () {69 request.body = { port: 3535, protocol: 'http' };70 return controller.post(request, response).then(function () {71 assert(response.headers.Location, 'http://localhost/servers/3535');72 assert.strictEqual(response.statusCode, 201);73 });74 });75 promiseIt('should return imposter JSON', function () {76 request.body = { port: 3535, protocol: 'http' };77 return controller.post(request, response).then(function () {78 assert.strictEqual(response.body, 'JSON');79 });80 });81 promiseIt('should add new imposter to list of all imposters', function () {82 imposter.port = 3535;83 request.body = { protocol: 'http' };84 return controller.post(request, response).then(function () {85 assert.deepEqual(imposters, { 3535: imposter });86 });87 });88 promiseIt('should return a 400 for a floating point port', function () {89 request.body = { protocol: 'http', port: '123.45' };90 return controller.post(request, response).then(function () {91 assert.strictEqual(response.statusCode, 400);92 assert.deepEqual(response.body, {93 errors: [{94 code: 'bad data',95 message: "invalid value for 'port'"96 }]97 });98 });99 });100 promiseIt('should return a 400 for a missing protocol', function () {101 request.body = { port: 3535 };102 return controller.post(request, response).then(function () {103 assert.strictEqual(response.statusCode, 400);104 assert.deepEqual(response.body, {105 errors: [{106 code: 'bad data',107 message: "'protocol' is a required field"108 }]109 });110 });111 });112 promiseIt('should return a 400 for unsupported protocols', function () {113 request.body = { port: 3535, protocol: 'unsupported' };114 return controller.post(request, response).then(function () {115 assert.strictEqual(response.statusCode, 400);116 assert.strictEqual(response.body.errors.length, 1);117 assert.strictEqual(response.body.errors[0].code, 'bad data');118 });119 });120 promiseIt('should aggregate multiple errors', function () {121 request.body = { port: -1, protocol: 'invalid' };122 return controller.post(request, response).then(function () {123 assert.strictEqual(response.body.errors.length, 2, response.body.errors);124 });125 });126 promiseIt('should return a 403 for insufficient access', function () {127 Imposter.create = mock().returns(Q.reject({128 code: 'insufficient access',129 key: 'value'130 }));131 request.body = { port: 3535, protocol: 'http' };132 return controller.post(request, response).then(function () {133 assert.strictEqual(response.statusCode, 403);134 assert.deepEqual(response.body, {135 errors: [{136 code: 'insufficient access',137 key: 'value'138 }]139 });140 });141 });142 promiseIt('should return a 400 for other protocol creation errors', function () {143 Imposter.create = mock().returns(Q.reject('ERROR'));144 request.body = { port: 3535, protocol: 'http' };145 return controller.post(request, response).then(function () {146 assert.strictEqual(response.statusCode, 400);147 assert.deepEqual(response.body, { errors: ['ERROR'] });148 });149 });150 promiseIt('should not call protocol validation if there are common validation failures', function () {151 Protocol.Validator = { create: mock() };152 request.body = { protocol: 'invalid' };153 return controller.post(request, response).then(function () {154 assert.ok(!Protocol.Validator.create.wasCalled());155 });156 });157 promiseIt('should validate with Protocol if there are no common validation failures', function () {158 Protocol.Validator = {159 create: mock().returns({160 validate: mock().returns(Q({ isValid: false, errors: 'ERRORS' }))161 })162 };163 request.body = { port: 3535, protocol: 'http' };164 return controller.post(request, response).then(function () {165 assert.strictEqual(response.statusCode, 400);166 assert.deepEqual(response.body, { errors: 'ERRORS' });167 });168 });169 });170 describe('#del', function () {171 function stopMock () {172 return mock().returns(Q(true));173 }174 promiseIt('should delete all imposters', function () {175 var firstImposter = { stop: stopMock(), toJSON: mock().returns('firstJSON') },176 secondImposter = { stop: stopMock(), toJSON: mock().returns('secondJSON') },177 imposters = { 1: firstImposter, 2: secondImposter },178 controller = Controller.create({}, imposters, {}, {});179 return controller.del({ url: '/imposters' }, response).then(function () {180 assert.deepEqual(imposters, {});181 });182 });183 promiseIt('should call stop on all imposters', function () {184 var firstImposter = { stop: stopMock(), toJSON: mock().returns('firstJSON') },185 secondImposter = { stop: stopMock(), toJSON: mock().returns('secondJSON') },186 imposters = { 1: firstImposter, 2: secondImposter },187 controller = Controller.create({}, imposters, {}, {});188 return controller.del({ url: '/imposters' }, response).then(function () {189 assert(firstImposter.stop.wasCalled());190 assert(secondImposter.stop.wasCalled());191 });192 });193 promiseIt('should send replayable JSON for all imposters by default', function () {194 var firstImposter = { stop: stopMock(), toJSON: mock().returns('firstJSON') },195 secondImposter = { stop: stopMock(), toJSON: mock().returns('secondJSON') },196 imposters = { 1: firstImposter, 2: secondImposter },197 controller = Controller.create({}, imposters, {}, {});198 return controller.del({ url: '/imposters' }, response).then(function () {199 assert.deepEqual(response.body, { imposters: ['firstJSON', 'secondJSON'] });200 assert.ok(firstImposter.toJSON.wasCalledWith({ replayable: true, removeProxies: false }), firstImposter.toJSON.message());201 assert.ok(secondImposter.toJSON.wasCalledWith({ replayable: true, removeProxies: false }), secondImposter.toJSON.message());202 });203 });204 promiseIt('should send default JSON for all imposters if replayable is false on querystring', function () {205 var firstImposter = { stop: stopMock(), toJSON: mock().returns('firstJSON') },206 secondImposter = { stop: stopMock(), toJSON: mock().returns('secondJSON') },207 controller = Controller.create({}, { 1: firstImposter, 2: secondImposter });208 return controller.del({ url: '/imposters?replayable=false' }, response).then(function () {209 assert.ok(firstImposter.toJSON.wasCalledWith({ replayable: false, removeProxies: false }), firstImposter.toJSON.message());210 assert.ok(secondImposter.toJSON.wasCalledWith({ replayable: false, removeProxies: false }), secondImposter.toJSON.message());211 });212 });213 promiseIt('should send removeProxies JSON for all imposters if querystring present', function () {214 var firstImposter = { stop: stopMock(), toJSON: mock().returns('firstJSON') },215 secondImposter = { stop: stopMock(), toJSON: mock().returns('secondJSON') },216 controller = Controller.create({}, { 1: firstImposter, 2: secondImposter });217 return controller.del({ url: '/imposters?removeProxies=true' }, response).then(function () {218 assert.ok(firstImposter.toJSON.wasCalledWith({ replayable: true, removeProxies: true }), firstImposter.toJSON.message());219 assert.ok(secondImposter.toJSON.wasCalledWith({ replayable: true, removeProxies: true }), secondImposter.toJSON.message());220 });221 });222 });223 describe('#put', function () {224 var request, logger, Protocol;225 beforeEach(function () {226 request = { body: {}, socket: { remoteAddress: 'host', remotePort: 'port' } };227 logger = { debug: mock(), warn: mock() };228 Protocol = {229 name: 'http',230 Validator: {231 create: mock().returns({ validate: mock().returns(Q({ isValid: true, errors: [] })) })232 }233 };234 });235 promiseIt('should return a 400 if the "imposters" key is not present', function () {236 var existingImposter = { stop: mock() },237 imposters = { 0: existingImposter },238 controller = Controller.create({ http: Protocol }, imposters, {}, logger);239 request.body = {};240 return controller.put(request, response).then(function () {241 assert.strictEqual(response.statusCode, 400);242 assert.deepEqual(response.body, {243 errors: [{244 code: 'bad data',245 message: "'imposters' is a required field"246 }]247 });248 assert.deepEqual(imposters, { 0: existingImposter });249 });250 });251 promiseIt('should return an empty array if no imposters provided', function () {252 var existingImposter = { stop: mock() },253 imposters = { 0: existingImposter },254 controller = Controller.create({ http: Protocol }, imposters, {}, logger);255 request.body = { imposters: [] };256 return controller.put(request, response).then(function () {257 assert.deepEqual(response.body, { imposters: [] });258 assert.deepEqual(imposters, {});259 });260 });261 promiseIt('should return imposter list JSON for all imposters', function () {262 var firstImposter = { toJSON: mock().returns({ first: true }) },263 secondImposter = { toJSON: mock().returns({ second: true }) },264 imposters = [firstImposter, secondImposter],265 creates = 0,266 Imposter = {267 create: function () {268 var result = imposters[creates];269 creates += 1;270 return result;271 }272 },273 controller = Controller.create({ http: Protocol }, {}, Imposter, logger);274 request.body = { imposters: [{ protocol: 'http' }, { protocol: 'http' }] };275 return controller.put(request, response).then(function () {276 assert.deepEqual(response.body, { imposters: [{ first: true }, { second: true }] });277 assert.ok(firstImposter.toJSON.wasCalledWith({ list: true }), firstImposter.toJSON.message());278 assert.ok(secondImposter.toJSON.wasCalledWith({ list: true }), secondImposter.toJSON.message());279 });280 });281 promiseIt('should replace imposters list', function () {282 var oldImposter = { stop: mock() },283 imposters = { 0: oldImposter },284 firstImposter = { toJSON: mock().returns({ first: true }), port: 1 },285 secondImposter = { toJSON: mock().returns({ second: true }), port: 2 },286 impostersToCreate = [firstImposter, secondImposter],287 creates = 0,288 Imposter = {289 create: function () {290 var result = impostersToCreate[creates];291 creates += 1;292 return result;293 }294 },295 controller = Controller.create({ http: Protocol }, imposters, Imposter, logger);296 request.body = { imposters: [{ protocol: 'http' }, { protocol: 'http' }] };297 return controller.put(request, response).then(function () {298 assert.deepEqual(imposters, { 1: firstImposter, 2: secondImposter });299 assert.ok(firstImposter.toJSON.wasCalledWith({ list: true }), firstImposter.toJSON.message());300 assert.ok(secondImposter.toJSON.wasCalledWith({ list: true }), secondImposter.toJSON.message());301 });302 });303 promiseIt('should return a 400 for any invalid imposter', function () {304 var controller = Controller.create({ http: Protocol }, {}, {}, logger);305 request.body = { imposters: [{ protocol: 'http' }, {}] };306 return controller.put(request, response).then(function () {307 assert.strictEqual(response.statusCode, 400);308 assert.deepEqual(response.body, {309 errors: [{310 code: 'bad data',311 message: "'protocol' is a required field"312 }]313 });314 });315 });316 promiseIt('should return a 403 for insufficient access on any imposter', function () {317 var creates = 0,318 Imposter = {319 create: function () {320 creates += 1;321 if (creates === 2) {322 return Q.reject({323 code: 'insufficient access',324 key: 'value'325 });326 }327 else {328 return Q({});329 }330 }331 },332 controller = Controller.create({ http: Protocol }, {}, Imposter, logger);333 request.body = { imposters: [{ protocol: 'http' }, { protocol: 'http' }] };334 return controller.put(request, response).then(function () {335 assert.strictEqual(response.statusCode, 403);336 assert.deepEqual(response.body, {337 errors: [{338 code: 'insufficient access',339 key: 'value'340 }]341 });342 });343 });344 });...
Using AI Code Generation
1var mb = require('mountebank');2var imposter = {3 {4 {5 is: {6 headers: {7 },8 body: JSON.stringify({ "message": "Hello World" })9 }10 }11 }12};13mb.create(imposter, function (error, imposter) {14 console.log("Imposter created");15 console.log(imposter.port);16});17var mb = require('mountebank');18var imposter = {19 {20 {21 is: {22 headers: {23 },24 body: JSON.stringify({ "message": "Hello World" })25 }26 }27 }28};29mb.create(imposter).then(function (imposter) {30 console.log("Imposter created");31 console.log(imposter.port);32});33var mb = require('mountebank');34mb.delete(3000, function (error) {35 console.log("Imposter deleted");36});37var mb = require('mountebank');38mb.delete(3000).then(function () {39 console.log("Imposter deleted");40});41var mb = require('mountebank');42mb.get(3000, function (error, imposter) {43 console.log("Imposter retrieved");44 console.log(imposter.requests);45});46var mb = require('mountebank');47mb.get(3000).then(function (imposter) {48 console.log("Imposter retrieved");49 console.log(imposter.requests);50});51var mb = require('mountebank');52mb.reset(function (error) {
Using AI Code Generation
1var mb = require('mountebank');2var imposter = mb.create({3 stubs: [{4 predicates: [{5 equals: {6 }7 }],8 responses: [{9 is: {10 headers: {11 },12 }13 }]14 }]15});16var mb = require('mountebank');17var imposter = mb.create({18 stubs: [{19 predicates: [{20 equals: {21 }22 }],23 responses: [{24 is: {25 headers: {26 },27 }28 }]29 }]30});31var mb = require('mountebank');32var imposter = mb.create({33 stubs: [{34 predicates: [{35 equals: {36 }37 }],38 responses: [{39 is: {40 headers: {41 },42 }43 }]44 }]45});46var mb = require('mountebank');47var imposter = mb.create({48 stubs: [{49 predicates: [{50 equals: {51 }52 }],53 responses: [{54 is: {55 headers: {56 },57 }58 }, {59 is: {60 headers: {61 },62 }63 }]64 }]65});
Using AI Code Generation
1var mb = require('mountebank');2var promise = mb.start({3});4promise.then(function (imposter) {5 imposter.post('/test', function (request, response) {6 console.log(request.body);7 response.statusCode = 200;8 response.body = { ok: true };9 response.send();10 });11});12### start([options])13### stop()14### create(options)15### get(port)16### remove(port)17### list()18### reset()19### getLogs()20### getLog(logfile)21### getProtocols()22### getProtocol(protofile)23### getPid()24### getConfig()25### setConfig(options)26### shutdown()
Using AI Code Generation
1var mb = require('mountebank');2var imposter = mb.create({port: 2525, allowInjection: true});3imposter.addStub({4 {5 is: {6 headers: {7 },8 }9 }10});11imposter.start();12var mb = require('mountebank');13mb.create({14 {15 {16 is: {17 headers: {18 },19 }20 }21 }22});23### `imposter.addStub(stub)`24var mb = require('mountebank');25var imposter = mb.create({port: 2525, allowInjection: true});26imposter.addStub({27 {28 is: {29 headers: {30 },31 }32 }33});34imposter.start();35### `imposter.getStubs()`36var mb = require('mountebank');37var imposter = mb.create({port: 2525, allowInjection: true});38imposter.addStub({39 {40 is: {41 headers: {42 },43 }44 }45});46imposter.start();47console.log(imposter.getStubs());48### `imposter.getImposter()`
Using AI Code Generation
1const imposter = require('mountebank').oldImposter;2const imposters = require('mountebank').imposters;3const mb = require('mountebank').mb;4const mbHelper = require('mountebank').mbHelper;5const mbTest = require('mountebank').mbTest;6const logger = require('mountebank').logger;7const assert = require('mountebank').assert;8const Q = require('q');9const util = require('mountebank').util;10const portfinder = require('mountebank').portfinder;11const js = require('mountebank').js;12const json = require('mountebank').json;13const xml = require('mountebank').xml;14const http = require('mountebank').http;15const https = require('mountebank').https;16const tcp = require('mountebank').tcp;17const smtp = require('mountebank').smtp;18const logger = require('mountebank').logger;19const fs = require('mountebank').fs;20const path = require('mountebank').path;21const os = require('mountebank').os;22const process = require('mountebank').process;23const childProcess = require('mountebank').childProcess;24const shell = require('mountebank').shell;25const net = require('mountebank').net;26const tls = require('mountebank').tls;27const repl = require('mountebank').repl;28const util = require('mountebank').util;29const Q = require('mountebank').Q;30const assert = require('mountebank').assert;31const logger = require('mountebank').logger;32const js = require('mountebank').js;33const json = require('mountebank').json;34const xml = require('mountebank').xml;35const http = require('mountebank').http;36const https = require('mountebank').https;37const tcp = require('mountebank').tcp;38const smtp = require('mountebank').smtp;39const logger = require('mountebank').logger;40const fs = require('mountebank').fs;41const path = require('mountebank').path;42const os = require('mountebank').os;43const process = require('mountebank').process;44const childProcess = require('mountebank').childProcess;
Using AI Code Generation
1const mb = require('mountebank');2const oldImposter = mb.create().then((server) => {3 return server.createImposter({4 stubs: [{5 responses: [{6 is: {7 headers: {8 },9 }10 }]11 }]12 });13});14const mb = require('mountebank');15const newImposter = mb.create().then((server) => {16 return server.Imposter.create({17 stubs: [{18 responses: [{19 is: {20 headers: {21 },22 }23 }]24 }]25 });26});27const mb = require('mountebank');28const oldImposter = mb.create().then((server) => {29 return server.createImposter({30 stubs: [{31 responses: [{32 is: {33 headers: {34 },35 }36 }]37 }]38 });39});40const mb = require('mountebank');41const newImposter = mb.create().then((server) => {42 return server.Imposter.create({43 stubs: [{44 responses: [{45 is: {46 headers: {47 },48 }49 }]50 }]51 });52});53const mb = require('mountebank');54const oldImposter = mb.create().then((server) => {55 return server.createImposter({56 stubs: [{57 responses: [{58 is: {59 headers: {
Using AI Code Generation
1var mb = require('mountebank');2var newImposter = mb.create({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log'});3newImposter.start();4var mbHelper = require('mountebank-helper');5var helper = mbHelper.create({port: 2525, protocol: 'http'});6var response = {7 headers: {8 },9 body: {10 }11};12helper.post('/imposters', {13 {14 }15}, function (error, response) {16 console.log(response.body);17});18var mbHelper = require('mountebank-helper');19var helper = mbHelper.create({port: 2525, protocol: 'http'});20helper.get('/imposters', function (error, response) {21 console.log(response.body);22});23var mbHelper = require('mountebank-helper');24var helper = mbHelper.create({port: 2525, protocol: 'http'});25helper.get('/imposters', function (error, response) {26 console.log(response.body);27});28var mbHelper = require('mountebank-helper');29var helper = mbHelper.create({port: 2525, protocol: 'http'});30helper.get('/imposters', function (error, response) {31 console.log(response.body);32});33var mbHelper = require('mountebank-helper');34var helper = mbHelper.create({port: 2525, protocol: 'http'});35helper.get('/imposters', function (error, response) {36 console.log(response.body);37});38var mbHelper = require('mountebank-helper');39var helper = mbHelper.create({port:
Using AI Code Generation
1var mb = require('mountebank');2var oldImposter = mb.create({port: 2525, name: 'test', protocol: 'http'});3oldImposter.addStub({responses: [{is: {body: 'Hello, world'}}]});4oldImposter.start();5var mb = require('mountebank');6var newImposter = mb.create({port: 2525, name: 'test', protocol: 'http'});7newImposter.addStub({responses: [{is: {body: 'Hello, world'}}]});8newImposter.start();9var mb = require('mountebank');10var newImposter = mb.create({port: 2525, name: 'test', protocol: 'http'});11newImposter.addStub({responses: [{is: {body: 'Hello, world'}}]});12newImposter.start();
Using AI Code Generation
1var mb = require('mountebank');2var imposter = mb.create({port: 2525, name: 'test'});3imposter.post('/test', function (request, response) {4 response.is({5 headers: {6 },7 });8});9imposter.start();10var mb = require('mountebank');11mb.start({port: 2525, name: 'test'}, function (error, imposter) {12 imposter.post('/test', function (request, response) {13 response.is({14 headers: {15 },16 });17 });18});19var mb = require('mountebank');20mb.start({port: 2525, name: 'test'})21 .then(function (imposter) {22 imposter.post('/test', function (request, response) {23 response.is({24 headers: {25 },26 });27 });28 });29var mb = require('mountebank');30mb.start({port: 2525, name: 'test'})31 .then(imposter => {32 imposter.post('/test', (request, response) => {33 response.is({34 headers: {35 },36 });37 });38 });39var mb = require('mountebank');40mb.start({port: 2525, name: 'test'})41 .then(imposter => {42 imposter.post('/test', (request, response) => {43 response.is({44 headers: {45 },46 });47 });48 });49var mb = require('mounteb
Using AI Code Generation
1var mb = require('mountebank');2var port = 2525;3var imposter = mb.create({ port: port, name: 'test', proto: 'http' });4imposter.post('/test', function (request, response) {5 console.log(request);6 response({ statusCode: 200, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ status: 'success' }) });7});8imposter.get('/test', function (request, response) {9 console.log(request);10 response({ statusCode: 200, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ status: 'success' }) });11});12imposter.put('/test', function (request, response) {13 console.log(request);14 response({ statusCode: 200, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ status: 'success' }) });15});16imposter.delete('/test', function (request, response) {17 console.log(request);18 response({ statusCode: 200, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ status: 'success' }) });19});20imposter.start(function (error) {21 console.log('imposter started');22});23var mb = require('mountebank');24var port = 2525;25var imposter = mb.create({ port: port, name: 'test', proto: 'http' });26imposter.addStub({ predicates: [{ equals: { method: 'POST', path: '/test' } }], responses: [{ is: { statusCode: 200, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ status: 'success' }) } }] });27imposter.addStub({ predicates: [{ equals: { method: 'GET', path: '/test' } }], responses: [{ is: { statusCode: 200, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ status: 'success' }) } }] });28imposter.addStub({ predicates: [{ equals: { method: 'PUT', path: '/test' } }], responses: [{ is: { statusCode: 200, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ status: 'success' }) } }] });29imposter.addStub({
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!