Best JavaScript code snippet using mountebank
worker.js
Source:worker.js
1/*!2 * Project: Audio Sort3 * File: AS.js4 * Source: https://github.com/skratchdot/audio-sort/5 *6 * Copyright (c) 2013 skratchdot7 * Licensed under the MIT license.8 */9(function (global) {10 'use strict';11 var AS = {},12 // internal arrays13 _array = [],14 _frames = [],15 _token = '',16 // state17 recent = {18 play: [],19 mark: [],20 swap: [],21 compare: [],22 highlight: []23 },24 // counters25 compareCount = 0,26 swapCount = 0,27 // functions28 addFrame,29 compare,30 copyObject,31 frameCheck,32 getIndexFromSortObject,33 getSortObjects,34 mark;35 copyObject = function (obj) {36 var isObject = (typeof obj === 'object'),37 rand = parseInt(Math.random() * 10000000, 10),38 result;39 result = {40 id: isObject ? obj.id : rand + '_' + obj,41 value: isObject ? obj.value : obj,42 play: isObject ? obj.play : false,43 mark: isObject ? obj.mark : false,44 swap: isObject ? obj.swap : false,45 justSwapped: isObject ? obj.justSwapped : false,46 compare: isObject ? obj.compare : false,47 highlight: isObject ? obj.highlight : false48 };49 return result;50 };51 frameCheck = function (type) {52 if (_frames.length === 0 || (recent.hasOwnProperty(type) && recent[type].length)) {53 addFrame();54 }55 };56 addFrame = function () {57 var i, copy = [], obj;58 for (i = 0; i < _array.length; i++) {59 obj = copyObject(_array[i]);60 // justSwapped61 if (recent.swap.indexOf(obj.id) >= 0) {62 obj.justSwapped = true;63 }64 // highlight65 if (recent.highlight.indexOf(obj.id) >= 0) {66 obj.highlight = true;67 }68 copy.push(obj);69 }70 _frames.push({71 arr: copy,72 compareCount: compareCount,73 swapCount: swapCount74 });75 recent.play = [];76 recent.mark = [];77 recent.swap = [];78 recent.compare = [];79 };80 getIndexFromSortObject = function (obj) {81 var i;82 for (i = 0; i < _array.length; i++) {83 if (_array[i].id === obj.id) {84 return i;85 }86 }87 return -1;88 };89 getSortObjects = function (inputArray) {90 var i, current, ret = [];91 for (i = 0; i < inputArray.length; i++) {92 current = inputArray[i];93 if (typeof current === 'number') {94 current = AS.get(current);95 }96 ret.push(current);97 }98 return ret;99 };100 compare = function (one, two) {101 var sortObjects = mark('compare', [one, two]);102 compareCount++;103 _frames[_frames.length - 1].compareCount = compareCount;104 return sortObjects;105 };106 mark = function (type, inputArray) {107 var frameIndex, len, i, index, sortObjects = getSortObjects(inputArray);108 frameCheck(type);109 frameIndex = _frames.length - 1;110 len = _frames[frameIndex].arr.length;111 for (i = 0; i < sortObjects.length; i++) {112 index = getIndexFromSortObject(sortObjects[i]);113 if (index >= 0 && index < len) {114 _frames[frameIndex].arr[index][type] = true;115 if (recent.hasOwnProperty(type)) {116 recent[type].push(_frames[frameIndex].arr[index].id);117 }118 }119 }120 return sortObjects;121 };122 AS.getFrames = function () {123 return _frames;124 };125 AS.init = function (inputArray, token) {126 var i;127 _array = [];128 _frames = [];129 _token = token;130 compareCount = 0;131 swapCount = 0;132 for (i = 0; i < inputArray.length; i++) {133 _array.push(copyObject(inputArray[i]));134 }135 };136 AS.end = function (token) {137 var i, lastFrameArray;138 if (_token === token) {139 // handle empty frames140 if (_frames.length === 0) {141 addFrame();142 }143 // handle the case in which last frame doesn't match _array144 lastFrameArray = _frames[_frames.length - 1].arr;145 for (i = 0; i < _array.length; i++) {146 if (_array[i].id !== lastFrameArray) {147 addFrame();148 return _frames;149 }150 }151 // we didn't have to artificially add a new frame152 return _frames;153 } else {154 // someone besides the worker was trying to call AS.end();155 return [];156 }157 };158 AS.length = function () {159 return _array.length;160 };161 AS.size = AS.length;162 AS.lt = function (one, two) {163 var sortObjects = compare(one, two);164 return sortObjects[0].value < sortObjects[1].value;165 };166 AS.lte = function (one, two) {167 var sortObjects = compare(one, two);168 return sortObjects[0].value <= sortObjects[1].value;169 };170 AS.gt = function (one, two) {171 var sortObjects = compare(one, two);172 return sortObjects[0].value > sortObjects[1].value;173 };174 AS.gte = function (one, two) {175 var sortObjects = compare(one, two);176 return sortObjects[0].value >= sortObjects[1].value;177 };178 AS.eq = function (one, two) {179 var sortObjects = compare(one, two);180 return sortObjects[0].value === sortObjects[1].value;181 };182 AS.neq = function (one, two) {183 var sortObjects = compare(one, two);184 return sortObjects[0].value !== sortObjects[1].value;185 };186 AS.play = function () {187 mark('play', arguments);188 };189 AS.mark = function () {190 mark('mark', arguments);191 };192 AS.clearHighlight = function () {193 recent.highlight = [];194 };195 AS.highlight = function () {196 AS.clearHighlight();197 mark('highlight', arguments);198 };199 AS.get = function (index) {200 return copyObject(_array[index]);201 };202 AS.swap = function (one, two) {203 var indexOne, indexTwo, tempOne, tempTwo, sortObjects;204 // mark as swapped205 sortObjects = mark('swap', [one, two]);206 indexOne = getIndexFromSortObject(sortObjects[0]);207 indexTwo = getIndexFromSortObject(sortObjects[1]);208 // perform swap209 tempOne = _array[indexOne];210 tempTwo = _array[indexTwo];211 _array[indexOne] = tempTwo;212 _array[indexTwo] = tempOne;213 swapCount++;214 _frames[_frames.length - 1].swapCount = swapCount;215 };216 global.AS = AS;217}(this));218/*!219 * Project: Audio Sort220 * File: SortWorker.js221 * Source: https://github.com/skratchdot/audio-sort/222 *223 * Copyright (c) 2013 skratchdot224 * Licensed under the MIT license.225 */226/*global sort */227(function (global) {228 'use strict';229 var getMethod;230 getMethod = function (method) {231 var defaultMethod = 'bubble';232 method = method || defaultMethod;233 if (!sort.hasOwnProperty(method)) {234 method = defaultMethod;235 }236 return method;237 };238 global.onmessage = function (event) {239 var Fn = Function,240 obj = {},241 token = (new Date()).getTime(),242 fnArray,243 frames;244 // ensure obj is valid245 obj.key = event.data.key || '';246 obj.fn = event.data.fn || 'function () {\n}';247 obj.arr = event.data.arr || [];248 // convert our function249 fnArray = obj.fn.split('\n');250 obj.fn = fnArray.splice(1, fnArray.length - 2).join('\n');251 obj.fn = new Fn(obj.fn);252 // get result253 AS.init(obj.arr, token);254 obj.fn();255 frames = AS.end(token);256 // return result257 global.postMessage({258 key: obj.key,259 frames: frames,260 fn: obj.fn.toString()261 });262 };...
AS.js
Source:AS.js
1/*!2 * Project: Audio Sort3 * File: AS.js4 * Source: https://github.com/skratchdot/audio-sort/5 *6 * Copyright (c) 2013 skratchdot7 * Licensed under the MIT license.8 */9(function (global) {10 'use strict';11 var AS = {},12 // internal arrays13 _array = [],14 _frames = [],15 _token = '',16 // state17 recent = {18 play: [],19 mark: [],20 swap: [],21 compare: [],22 highlight: []23 },24 // counters25 compareCount = 0,26 swapCount = 0,27 // functions28 addFrame,29 compare,30 copyObject,31 frameCheck,32 getIndexFromSortObject,33 getSortObjects,34 mark;35 copyObject = function (obj) {36 var isObject = (typeof obj === 'object'),37 rand = parseInt(Math.random() * 10000000, 10),38 result;39 result = {40 id: isObject ? obj.id : rand + '_' + obj,41 value: isObject ? obj.value : obj,42 play: isObject ? obj.play : false,43 mark: isObject ? obj.mark : false,44 swap: isObject ? obj.swap : false,45 justSwapped: isObject ? obj.justSwapped : false,46 compare: isObject ? obj.compare : false,47 highlight: isObject ? obj.highlight : false48 };49 return result;50 };51 frameCheck = function (type) {52 if (_frames.length === 0 || (recent.hasOwnProperty(type) && recent[type].length)) {53 addFrame();54 }55 };56 addFrame = function () {57 var i, copy = [], obj;58 for (i = 0; i < _array.length; i++) {59 obj = copyObject(_array[i]);60 // justSwapped61 if (recent.swap.indexOf(obj.id) >= 0) {62 obj.justSwapped = true;63 }64 // highlight65 if (recent.highlight.indexOf(obj.id) >= 0) {66 obj.highlight = true;67 }68 copy.push(obj);69 }70 _frames.push({71 arr: copy,72 compareCount: compareCount,73 swapCount: swapCount74 });75 recent.play = [];76 recent.mark = [];77 recent.swap = [];78 recent.compare = [];79 };80 getIndexFromSortObject = function (obj) {81 var i;82 for (i = 0; i < _array.length; i++) {83 if (_array[i].id === obj.id) {84 return i;85 }86 }87 return -1;88 };89 getSortObjects = function (inputArray) {90 var i, current, ret = [];91 for (i = 0; i < inputArray.length; i++) {92 current = inputArray[i];93 if (typeof current === 'number') {94 current = AS.get(current);95 }96 ret.push(current);97 }98 return ret;99 };100 compare = function (one, two) {101 var sortObjects = mark('compare', [one, two]);102 compareCount++;103 _frames[_frames.length - 1].compareCount = compareCount;104 return sortObjects;105 };106 mark = function (type, inputArray) {107 var frameIndex, len, i, index, sortObjects = getSortObjects(inputArray);108 frameCheck(type);109 frameIndex = _frames.length - 1;110 len = _frames[frameIndex].arr.length;111 for (i = 0; i < sortObjects.length; i++) {112 index = getIndexFromSortObject(sortObjects[i]);113 if (index >= 0 && index < len) {114 _frames[frameIndex].arr[index][type] = true;115 if (recent.hasOwnProperty(type)) {116 recent[type].push(_frames[frameIndex].arr[index].id);117 }118 }119 }120 return sortObjects;121 };122 AS.getFrames = function () {123 return _frames;124 };125 AS.init = function (inputArray, token) {126 var i;127 _array = [];128 _frames = [];129 _token = token;130 compareCount = 0;131 swapCount = 0;132 for (i = 0; i < inputArray.length; i++) {133 _array.push(copyObject(inputArray[i]));134 }135 };136 AS.end = function (token) {137 var i, lastFrameArray;138 if (_token === token) {139 // handle empty frames140 if (_frames.length === 0) {141 addFrame();142 }143 // handle the case in which last frame doesn't match _array144 lastFrameArray = _frames[_frames.length - 1].arr;145 for (i = 0; i < _array.length; i++) {146 if (_array[i].id !== lastFrameArray) {147 addFrame();148 return _frames;149 }150 }151 // we didn't have to artificially add a new frame152 return _frames;153 } else {154 // someone besides the worker was trying to call AS.end();155 return [];156 }157 };158 AS.length = function () {159 return _array.length;160 };161 AS.size = AS.length;162 AS.lt = function (one, two) {163 var sortObjects = compare(one, two);164 return sortObjects[0].value < sortObjects[1].value;165 };166 AS.lte = function (one, two) {167 var sortObjects = compare(one, two);168 return sortObjects[0].value <= sortObjects[1].value;169 };170 AS.gt = function (one, two) {171 var sortObjects = compare(one, two);172 return sortObjects[0].value > sortObjects[1].value;173 };174 AS.gte = function (one, two) {175 var sortObjects = compare(one, two);176 return sortObjects[0].value >= sortObjects[1].value;177 };178 AS.eq = function (one, two) {179 var sortObjects = compare(one, two);180 return sortObjects[0].value === sortObjects[1].value;181 };182 AS.neq = function (one, two) {183 var sortObjects = compare(one, two);184 return sortObjects[0].value !== sortObjects[1].value;185 };186 AS.play = function () {187 mark('play', arguments);188 };189 AS.mark = function () {190 mark('mark', arguments);191 };192 AS.clearHighlight = function () {193 recent.highlight = [];194 };195 AS.highlight = function () {196 AS.clearHighlight();197 mark('highlight', arguments);198 };199 AS.get = function (index) {200 return copyObject(_array[index]);201 };202 AS.swap = function (one, two) {203 var indexOne, indexTwo, tempOne, tempTwo, sortObjects;204 // mark as swapped205 sortObjects = mark('swap', [one, two]);206 indexOne = getIndexFromSortObject(sortObjects[0]);207 indexTwo = getIndexFromSortObject(sortObjects[1]);208 // perform swap209 tempOne = _array[indexOne];210 tempTwo = _array[indexTwo];211 _array[indexOne] = tempTwo;212 _array[indexTwo] = tempOne;213 swapCount++;214 _frames[_frames.length - 1].swapCount = swapCount;215 };216 global.AS = AS;...
ObjectsHeader.test.js
Source:ObjectsHeader.test.js
1/*2 * MinIO Cloud Storage (C) 2018 MinIO, Inc.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16import React from "react"17import { shallow } from "enzyme"18import { ObjectsHeader } from "../ObjectsHeader"19import { SORT_ORDER_ASC, SORT_ORDER_DESC } from "../../constants"20describe("ObjectsHeader", () => {21 it("should render without crashing", () => {22 const sortObjects = jest.fn()23 shallow(<ObjectsHeader sortObjects={sortObjects} />)24 })25 it("should render the name column with asc class when objects are sorted by name asc", () => {26 const sortObjects = jest.fn()27 const wrapper = shallow(28 <ObjectsHeader29 sortObjects={sortObjects}30 sortedByName={true}31 sortOrder={SORT_ORDER_ASC}32 />33 )34 expect(35 wrapper.find("#sort-by-name i").hasClass("fa-sort-alpha-down")36 ).toBeTruthy()37 })38 it("should render the name column with desc class when objects are sorted by name desc", () => {39 const sortObjects = jest.fn()40 const wrapper = shallow(41 <ObjectsHeader42 sortObjects={sortObjects}43 sortedByName={true}44 sortOrder={SORT_ORDER_DESC}45 />46 )47 expect(48 wrapper.find("#sort-by-name i").hasClass("fa-sort-alpha-down-alt")49 ).toBeTruthy()50 })51 it("should render the size column with asc class when objects are sorted by size asc", () => {52 const sortObjects = jest.fn()53 const wrapper = shallow(54 <ObjectsHeader55 sortObjects={sortObjects}56 sortedBySize={true}57 sortOrder={SORT_ORDER_ASC}58 />59 )60 expect(61 wrapper.find("#sort-by-size i").hasClass("fa-sort-amount-down-alt")62 ).toBeTruthy()63 })64 it("should render the size column with desc class when objects are sorted by size desc", () => {65 const sortObjects = jest.fn()66 const wrapper = shallow(67 <ObjectsHeader68 sortObjects={sortObjects}69 sortedBySize={true}70 sortOrder={SORT_ORDER_DESC}71 />72 )73 expect(74 wrapper.find("#sort-by-size i").hasClass("fa-sort-amount-down")75 ).toBeTruthy()76 })77 it("should render the date column with asc class when objects are sorted by date asc", () => {78 const sortObjects = jest.fn()79 const wrapper = shallow(80 <ObjectsHeader81 sortObjects={sortObjects}82 sortedByLastModified={true}83 sortOrder={SORT_ORDER_ASC}84 />85 )86 expect(87 wrapper.find("#sort-by-last-modified i").hasClass("fa-sort-numeric-down")88 ).toBeTruthy()89 })90 it("should render the date column with desc class when objects are sorted by date desc", () => {91 const sortObjects = jest.fn()92 const wrapper = shallow(93 <ObjectsHeader94 sortObjects={sortObjects}95 sortedByLastModified={true}96 sortOrder={SORT_ORDER_DESC}97 />98 )99 expect(100 wrapper.find("#sort-by-last-modified i").hasClass("fa-sort-numeric-down-alt")101 ).toBeTruthy()102 })103 it("should call sortObjects when a column is clicked", () => {104 const sortObjects = jest.fn()105 const wrapper = shallow(<ObjectsHeader sortObjects={sortObjects} />)106 wrapper.find("#sort-by-name").simulate("click")107 expect(sortObjects).toHaveBeenCalledWith("name")108 wrapper.find("#sort-by-size").simulate("click")109 expect(sortObjects).toHaveBeenCalledWith("size")110 wrapper.find("#sort-by-last-modified").simulate("click")111 expect(sortObjects).toHaveBeenCalledWith("last-modified")112 })...
Using AI Code Generation
1var mb = require('mountebank');2 {3 {4 { equals: { method: 'GET' } },5 { deepEquals: { path: '/test' } }6 { is: { body: 'Hello from mountebank!' } }7 }8 }9];10mb.create({ imposters: imposters }, function (error, mb) {11 console.log('Mountebank started on port %s', mb.port);12});13var mb = require('mountebank');14 {15 {16 { equals: { method: 'GET' } },17 { deepEquals: { path: '/test' } }18 { is: { body: 'Hello from mountebank!' } }19 }20 }21];22mb.create({ imposters: imposters }, function (error, mb) {23 console.log('Mountebank started on port %s', mb.port);24});25var mb = require('mountebank');26 {27 {28 { equals: { method: 'GET' } },29 { deepEquals: { path: '/test' } }30 { is: { body: 'Hello from mountebank!' } }31 }32 }33];34mb.create({ imposters: imposters }, function (error, mb) {35 console.log('Mountebank started on port %s', mb.port);36});37var mb = require('mountebank');38 {39 {40 { equals: { method: 'GET' } },41 { deepEquals:
Using AI Code Generation
1var mb = require('mountebank');2var imposter = {3 {4 {5 'is': {6 'headers': {7 },8 'body': JSON.stringify(9 {10 },11 {12 },13 {14 }15 }16 }17 }18};19mb.create(imposter).then(function (response) {20 console.log(response.body);21}, function (error) {22 console.error(error);23});24### create(imposter)25### get(port)26### getAll()27### del(port)28### delAll()29### createProxy(port, options)30### createTcpProxy(port, options)31### createHttpsProxy(port, options)32### createHttpsImposter(port, key, cert, options)
Using AI Code Generation
1var mb = require('mountebank');2var port = 2525;3 {4 {5 {6 equals: {7 }8 }9 {10 is: {11 headers: {12 },13 body: JSON.stringify(mb.sortObjects(JSON.parse(request.body)))14 }15 }16 }17 }18];19mb.create({ imposters: imposters }, function () {20});21var mb = require('mountebank');22var port = 2525;23 {24 {25 {26 equals: {27 }28 }29 {30 is: {31 headers: {32 },33 body: JSON.stringify(mb.sortObjects(JSON.parse(request.body)))34 }35 }36 }37 }38];39mb.create({ imposters: imposters }, function () {40});41var mb = require('mountebank');42var port = 2525;43 {44 {45 {46 equals: {47 }48 }49 {50 is: {51 headers: {52 },53 body: JSON.stringify(mb.sortObjects(JSON.parse(request.body)))54 }55 }56 }57 }58];59mb.create({ imposters: imposters }, function () {60});
Using AI Code Generation
1const mb = require('mountebank');2 {3 {4 {5 {6 equals: {7 query: {8 }9 }10 }11 }12 {13 is: {14 headers: {15 },16 body: JSON.stringify({ a: 1, b: 2, c: 3 })17 }18 }19 }20 }21];22mb.create({23 imposters: mb.sortObjects(imposters)24});25const mb = require('mountebank');26 {27 {28 {29 {30 equals: {31 query: {32 }33 }34 }35 }36 {37 is: {38 headers: {39 },40 body: JSON.stringify({ a: 1, b: 2, c: 3 })41 }42 }43 }44 }45];46mb.create({47 imposters: mb.sortObjects(imposters)48});49const mb = require('mountebank');50 {51 {52 {53 {54 equals: {55 query: {56 }57 }58 }59 }60 {61 is: {62 headers: {
Using AI Code Generation
1var mb = require('mountebank');2var fs = require('fs');3var options = {4 key: fs.readFileSync('certs/localhost-key.pem'),5 cert: fs.readFileSync('certs/localhost.pem'),6 defaultInjection: 'function () {}',7 defaultStub: '{}',8 defaultProxy: '{}',9 defaultInjection: 'function () {}',10 defaultStub: '{}',11 defaultProxy: '{}',
Using AI Code Generation
1var mb = require('mountebank');2mb.sortObjects({a: 1, b: 2, c: 3});3var mb = require('mountebank');4mb.sortObjects({a: 1, b: 2, c: 3});5var mb = require('mountebank');6mb.sortObjects({a: 1, b: 2, c: 3});7var mb = require('mountebank');8mb.sortObjects({a: 1, b: 2, c: 3});9var mb = require('mountebank');10mb.sortObjects({a: 1, b: 2, c: 3});11var mb = require('mountebank');12mb.sortObjects({a: 1, b: 2, c: 3});13var mb = require('mountebank');14mb.sortObjects({a: 1, b: 2, c: 3});15var mb = require('mountebank');16mb.sortObjects({a: 1, b: 2, c: 3});17var mb = require('mountebank');18mb.sortObjects({a: 1, b: 2, c: 3});19var mb = require('mountebank');20mb.sortObjects({a: 1, b: 2, c: 3});21var mb = require('mountebank');22mb.sortObjects({a: 1, b: 2, c: 3});
Using AI Code Generation
1const mb = require('mountebank');2const imposters = mb.create();3const port = 2525;4const protocol = 'http';5 {6 {7 equals: {8 }9 }10 {11 is: {12 headers: {13 },14 body: JSON.stringify({ "test": "test" })15 }16 }17 }18];19const imposter = {20};21imposters.add(imposter);22imposters.sortObjects();23imposters.start();
Using AI Code Generation
1var mb = require('mountebank');2mb.create({3}).then(function () {4 console.log('Mountebank started');5 return mb.post('/imposters', {6 {7 {8 is: {9 }10 }11 }12 });13}).then(function (response) {14 console.log(response.body);15 return mb.get('/imposters');16}).then(function (response) {17 console.log('All imposters');18 console.log(response.body);19 return mb.del('/imposters/5555');20}).then(function (response) {21 console.log('Deleted imposter');22 console.log(response.body);23 return mb.del('/imposters');24}).then(function (response) {25 console.log('Deleted all imposters');26 console.log(response.body);27 return mb.stop();28}).then(function () {29 console.log('Mountebank stopped');30}).catch(function (error) {31 console.error(error);32});
Using AI Code Generation
1var mb = require('mountebank');2var fs = require('fs');3var server = mb.create({4});5server.then(function () {6 var imposter = {7 "stubs": [{8 "responses": [{9 "is": {10 "headers": {11 },12 "body": fs.readFileSync('response.json').toString()13 }14 }]15 }]16 };17 return mb.post('/imposters', imposter);18}).then(function (response) {19 console.log(response.body);20 return mb.get('/imposters/3000/stubs/0');21}).then(function (response) {22 console.log(response.body);23 return mb.del('/imposters/3000');24}).then(function (response) {25 console.log(response.body);26 return mb.del('/imposters');27}).then(function (response) {28 console.log(response.body);29 return mb.stop();30}).then(function () {31 console.log('done!');32}).done();33 {34 },35 {36 },37 {38 },39 {40 },41 {42 }
Using AI Code Generation
1var mb = require('mountebank');2var imposters = require('./imposters.json');3mb.create({port:2525, pidfile:'./mb.pid', logfile:'./mb.log'}, function(error, mbServer){4 if (error) {5 console.log('Error creating mb server', error);6 } else {7 mbServer.post('/imposters', imposters, function (error, response) {8 if (error) {9 console.log('Error creating imposters', error);10 } else {11 console.log('Imposters created', response.body);12 }13 });14 }15});16{17 {18 {19 {20 "is": {21 "headers": {22 },23 "body": {24 }25 }26 }27 }28 }29}30var mb = require('mountebank');31var imposters = require('./imposters.json');32mb.create({port:2525, pidfile:'./mb.pid', logfile:'./mb.log'}, function(error, mbServer){33 if (error) {34 console.log('Error creating mb server', error);35 } else {36 mbServer.post('/imposters', imposters, function (error, response) {37 if (error) {38 console.log('Error creating imposters', error);39 } else {40 console.log('Imposters created', response.body);41 }42 });43 }44});45{46 {47 {48 {49 "is": {50 "headers": {51 },52 "body": {53 }54 }
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!!