How to use buildExists method in mountebank

Best JavaScript code snippet using mountebank

server-integration.e2e.ts

Source:server-integration.e2e.ts Github

copy

Full Screen

...50 getFile(pr9, sha9, 'index.html').then(h.verifyResponse(404)),51 getFile(pr9, sha9, 'foo/bar.js').then(h.verifyResponse(404)),52 ])).53 then(() => {54 expect(h.buildExists(pr9, sha9)).toBe(false);55 expect(h.buildExists(pr9, sha9, false)).toBe(true);56 expect(h.readBuildFile(pr9, sha9, 'index.html', false)).toMatch(idxContentRegex9);57 expect(h.readBuildFile(pr9, sha9, 'foo/bar.js', false)).toMatch(barContentRegex9);58 }).59 then(done);60 });61 it('should reject an upload if verification fails', done => {62 const errorRegex9 = new RegExp(`Error while verifying upload for PR ${pr9}: Test`);63 h.createDummyArchive(pr9, sha9, archivePath);64 uploadBuild(pr9, sha9, archivePath, c.BV_verify_error).65 then(h.verifyResponse(403, errorRegex9)).66 then(() => {67 expect(h.buildExists(pr9)).toBe(false);68 expect(h.buildExists(pr9, '', false)).toBe(false);69 }).70 then(done);71 });72 it('should be able to notify that a PR has been updated (and do nothing)', done => {73 prUpdated(+pr9).74 then(h.verifyResponse(200)).75 then(() => {76 // The PR should still not exist.77 expect(h.buildExists(pr9, '', false)).toBe(false);78 expect(h.buildExists(pr9, '', true)).toBe(false);79 }).80 then(done);81 });82 });83 describe('for an existing PR', () => {84 it('should be able to upload and serve a public build', done => {85 const regexPrefix0 = `^PR: ${pr9} \\| SHA: ${sha0} \\| File:`;86 const idxContentRegex0 = new RegExp(`${regexPrefix0} \\/index\\.html$`);87 const barContentRegex0 = new RegExp(`${regexPrefix0} \\/foo\\/bar\\.js$`);88 const regexPrefix9 = `^PR: uploaded\\/${pr9} \\| SHA: ${sha9} \\| File:`;89 const idxContentRegex9 = new RegExp(`${regexPrefix9} \\/index\\.html$`);90 const barContentRegex9 = new RegExp(`${regexPrefix9} \\/foo\\/bar\\.js$`);91 h.createDummyBuild(pr9, sha0);92 h.createDummyArchive(pr9, sha9, archivePath);93 uploadBuild(pr9, sha9, archivePath).94 then(() => Promise.all([95 getFile(pr9, sha0, 'index.html').then(h.verifyResponse(200, idxContentRegex0)),96 getFile(pr9, sha0, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex0)),97 getFile(pr9, sha9, 'index.html').then(h.verifyResponse(200, idxContentRegex9)),98 getFile(pr9, sha9, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex9)),99 ])).100 then(done);101 });102 it('should be able to upload but not serve a hidden build', done => {103 const regexPrefix0 = `^PR: ${pr9} \\| SHA: ${sha0} \\| File:`;104 const idxContentRegex0 = new RegExp(`${regexPrefix0} \\/index\\.html$`);105 const barContentRegex0 = new RegExp(`${regexPrefix0} \\/foo\\/bar\\.js$`);106 const regexPrefix9 = `^PR: uploaded\\/${pr9} \\| SHA: ${sha9} \\| File:`;107 const idxContentRegex9 = new RegExp(`${regexPrefix9} \\/index\\.html$`);108 const barContentRegex9 = new RegExp(`${regexPrefix9} \\/foo\\/bar\\.js$`);109 h.createDummyBuild(pr9, sha0, false);110 h.createDummyArchive(pr9, sha9, archivePath);111 uploadBuild(pr9, sha9, archivePath, c.BV_verify_verifiedNotTrusted).112 then(() => Promise.all([113 getFile(pr9, sha0, 'index.html').then(h.verifyResponse(404)),114 getFile(pr9, sha0, 'foo/bar.js').then(h.verifyResponse(404)),115 getFile(pr9, sha9, 'index.html').then(h.verifyResponse(404)),116 getFile(pr9, sha9, 'foo/bar.js').then(h.verifyResponse(404)),117 ])).118 then(() => {119 expect(h.buildExists(pr9, sha9)).toBe(false);120 expect(h.buildExists(pr9, sha9, false)).toBe(true);121 expect(h.readBuildFile(pr9, sha0, 'index.html', false)).toMatch(idxContentRegex0);122 expect(h.readBuildFile(pr9, sha0, 'foo/bar.js', false)).toMatch(barContentRegex0);123 expect(h.readBuildFile(pr9, sha9, 'index.html', false)).toMatch(idxContentRegex9);124 expect(h.readBuildFile(pr9, sha9, 'foo/bar.js', false)).toMatch(barContentRegex9);125 }).126 then(done);127 });128 it('should reject an upload if verification fails', done => {129 const errorRegex9 = new RegExp(`Error while verifying upload for PR ${pr9}: Test`);130 h.createDummyBuild(pr9, sha0);131 h.createDummyArchive(pr9, sha9, archivePath);132 uploadBuild(pr9, sha9, archivePath, c.BV_verify_error).133 then(h.verifyResponse(403, errorRegex9)).134 then(() => {135 expect(h.buildExists(pr9)).toBe(true);136 expect(h.buildExists(pr9, sha0)).toBe(true);137 expect(h.buildExists(pr9, sha9)).toBe(false);138 }).139 then(done);140 });141 it('should not be able to overwrite an existing public build', done => {142 const regexPrefix9 = `^PR: ${pr9} \\| SHA: ${sha9} \\| File:`;143 const idxContentRegex9 = new RegExp(`${regexPrefix9} \\/index\\.html$`);144 const barContentRegex9 = new RegExp(`${regexPrefix9} \\/foo\\/bar\\.js$`);145 h.createDummyBuild(pr9, sha9);146 h.createDummyArchive(pr9, sha9, archivePath);147 uploadBuild(pr9, sha9, archivePath).148 then(h.verifyResponse(409)).149 then(() => Promise.all([150 getFile(pr9, sha9, 'index.html').then(h.verifyResponse(200, idxContentRegex9)),151 getFile(pr9, sha9, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex9)),152 ])).153 then(done);154 });155 it('should not be able to overwrite an existing hidden build', done => {156 const regexPrefix9 = `^PR: ${pr9} \\| SHA: ${sha9} \\| File:`;157 const idxContentRegex9 = new RegExp(`${regexPrefix9} \\/index\\.html$`);158 const barContentRegex9 = new RegExp(`${regexPrefix9} \\/foo\\/bar\\.js$`);159 h.createDummyBuild(pr9, sha9, false);160 h.createDummyArchive(pr9, sha9, archivePath);161 uploadBuild(pr9, sha9, archivePath, c.BV_verify_verifiedNotTrusted).162 then(h.verifyResponse(409)).163 then(() => {164 expect(h.readBuildFile(pr9, sha9, 'index.html', false)).toMatch(idxContentRegex9);165 expect(h.readBuildFile(pr9, sha9, 'foo/bar.js', false)).toMatch(barContentRegex9);166 }).167 then(done);168 });169 it('should be able to request re-checking visibility (if outdated)', done => {170 const publicPr = pr9;171 const hiddenPr = String(c.BV_getPrIsTrusted_notTrusted);172 h.createDummyBuild(publicPr, sha9, false);173 h.createDummyBuild(hiddenPr, sha9, true);174 // PR visibilities are outdated (i.e. the opposte of what the should).175 expect(h.buildExists(publicPr, '', false)).toBe(true);176 expect(h.buildExists(publicPr, '', true)).toBe(false);177 expect(h.buildExists(hiddenPr, '', false)).toBe(false);178 expect(h.buildExists(hiddenPr, '', true)).toBe(true);179 Promise.180 all([181 prUpdated(+publicPr).then(h.verifyResponse(200)),182 prUpdated(+hiddenPr).then(h.verifyResponse(200)),183 ]).184 then(() => {185 // PR visibilities should have been updated.186 expect(h.buildExists(publicPr, '', false)).toBe(false);187 expect(h.buildExists(publicPr, '', true)).toBe(true);188 expect(h.buildExists(hiddenPr, '', false)).toBe(true);189 expect(h.buildExists(hiddenPr, '', true)).toBe(false);190 }).191 then(() => {192 h.deletePrDir(publicPr, true);193 h.deletePrDir(hiddenPr, false);194 }).195 then(done);196 });197 it('should be able to request re-checking visibility (if up-to-date)', done => {198 const publicPr = pr9;199 const hiddenPr = String(c.BV_getPrIsTrusted_notTrusted);200 h.createDummyBuild(publicPr, sha9, true);201 h.createDummyBuild(hiddenPr, sha9, false);202 // PR visibilities are already up-to-date.203 expect(h.buildExists(publicPr, '', false)).toBe(false);204 expect(h.buildExists(publicPr, '', true)).toBe(true);205 expect(h.buildExists(hiddenPr, '', false)).toBe(true);206 expect(h.buildExists(hiddenPr, '', true)).toBe(false);207 Promise.208 all([209 prUpdated(+publicPr).then(h.verifyResponse(200)),210 prUpdated(+hiddenPr).then(h.verifyResponse(200)),211 ]).212 then(() => {213 // PR visibilities are still up-to-date.214 expect(h.buildExists(publicPr, '', false)).toBe(false);215 expect(h.buildExists(publicPr, '', true)).toBe(true);216 expect(h.buildExists(hiddenPr, '', false)).toBe(true);217 expect(h.buildExists(hiddenPr, '', true)).toBe(false);218 }).219 then(done);220 });221 it('should reject a request if re-checking visibility fails', done => {222 const errorPr = String(c.BV_getPrIsTrusted_error);223 h.createDummyBuild(errorPr, sha9, true);224 expect(h.buildExists(errorPr, '', false)).toBe(false);225 expect(h.buildExists(errorPr, '', true)).toBe(true);226 prUpdated(+errorPr).227 then(h.verifyResponse(500, /Test/)).228 then(() => {229 // PR visibility should not have been updated.230 expect(h.buildExists(errorPr, '', false)).toBe(false);231 expect(h.buildExists(errorPr, '', true)).toBe(true);232 }).233 then(done);234 });235 it('should reject a request if updating visibility fails', done => {236 // One way to cause an error is to have both a public and a hidden directory for the same PR.237 h.createDummyBuild(pr9, sha9, false);238 h.createDummyBuild(pr9, sha9, true);239 const hiddenPrDir = h.getPrDir(pr9, false);240 const publicPrDir = h.getPrDir(pr9, true);241 const bodyRegex = new RegExp(`Request to move '${hiddenPrDir}' to existing directory '${publicPrDir}'`);242 expect(h.buildExists(pr9, '', false)).toBe(true);243 expect(h.buildExists(pr9, '', true)).toBe(true);244 prUpdated(+pr9).245 then(h.verifyResponse(409, bodyRegex)).246 then(() => {247 // PR visibility should not have been updated.248 expect(h.buildExists(pr9, '', false)).toBe(true);249 expect(h.buildExists(pr9, '', true)).toBe(true);250 }).251 then(done);252 });253 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const mb = require('mountebank');2const imposter = {3 {4 {5 "is": {6 }7 }8 }9};10mb.create(imposter).then(function (imposter) {11 return mb.buildExists();12}).then(function (exists) {13 console.log(exists);14}).catch(function (error) {15 console.log(error);16});17const mb = require('mountebank');18const imposter = {19 {20 {21 "is": {22 }23 }24 }25};26mb.create(imposter).then(function (imposter) {27 return mb.buildExists();28}).then(function (exists) {29 console.log(exists);30}).catch(function (error) {31 console.log(error);32});33const mb = require('mountebank');34const imposter = {35 {36 {37 "is": {38 }39 }40 }41};42mb.create(imposter).then(function (imposter) {43 return mb.buildExists();44}).then(function (exists) {45 console.log(exists);46}).catch(function (error) {47 console.log(error);48});49const mb = require('mountebank');50const imposter = {51 {52 {53 "is": {54 }55 }56 }57};

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.buildExists(function (exists) {3 if (exists) {4 console.log("mountebank already exists");5 } else {6 console.log("mountebank does not exist");7 }8});9var mb = require('mountebank');10mb.buildExists(function (exists) {11 if (exists) {12 console.log("mountebank already exists");13 } else {14 console.log("mountebank does not exist");15 }16});

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.create({ port: 2525, pidfile: "mb.pid", logfile: "mb.log" }, function (error, mb) {3 if (error) {4 console.error("Error starting server: ", error);5 } else {6 console.log("Server started");7 mb.buildExists(function (error, exists) {8 if (error) {9 console.error("Error checking for build: ", error);10 } else {11 console.log("Build exists: ", exists);12 }13 });14 }15});

Full Screen

Using AI Code Generation

copy

Full Screen

1const mbHelper = require('./mountebank-helper');2mbHelper.buildExists()3.then((exists) => {4 console.log(exists);5})6.catch((err) => {7 console.log(err);8});9const path = require('path');10const { spawn } = require('child_process');11const isWin = process.platform === 'win32';12const mbPath = isWin ? path.join(__dirname, 'mountebank', 'mb.exe') : path.join(__dirname, 'mountebank', 'mb');13const mbExists = () => new Promise((resolve, reject) => {14 const mb = spawn(mbPath, ['--version']);15 mb.on('error', (err) => {16 reject(err);17 });18 mb.on('close', (code) => {19 resolve(code === 0);20 });21});22module.exports = {23};

Full Screen

Using AI Code Generation

copy

Full Screen

1var mbHelper = require('mountebank-helper');2mb.buildExists('test').then(function(exists) {3 if (exists) {4 console.log('build exists');5 } else {6 console.log('build does not exist');7 }8});9var mbHelper = require('mountebank-helper');10mb.buildExists('test').then(function(exists) {11 if (exists) {12 console.log('build exists');13 } else {14 console.log('build does not exist');15 }16});17var mbHelper = require('mountebank-helper');18mb.buildExists('test').then(function(exists) {19 if (exists) {20 console.log('build exists');21 } else {22 console.log('build does not exist');23 }24});25var mbHelper = require('mountebank-helper');26mb.buildExists('test').then(function(exists) {27 if (exists) {28 console.log('build exists');29 } else {30 console.log('build does not exist');31 }32});33var mbHelper = require('mountebank-helper');34mb.buildExists('test').then(function(exists) {35 if (exists) {36 console.log('build exists');37 } else {38 console.log('build does not exist');39 }40});41var mbHelper = require('mountebank-helper');42mb.buildExists('test').then(function(exists) {43 if (exists) {44 console.log('build exists');45 } else {46 console.log('build does not exist');47 }48});

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var host = 'localhost';3var port = 2525;4var client = mb.createClient({host: host, port: port});5client.buildExists('build').then(function (exists) {6 console.log('build exists: ' + exists);7});8var mb = require('mountebank');9var host = 'localhost';10var port = 2525;11var client = mb.createClient({host: host, port: port});12client.buildExists('build').then(function (exists) {13 console.log('build exists: ' + exists);14});15var mb = require('mountebank');16var host = 'localhost';17var port = 2525;18var client = mb.createClient({host: host, port: port});19client.buildExists('build').then(function (exists) {20 console.log('build exists: ' + exists);21});22var mb = require('mountebank');23var host = 'localhost';24var port = 2525;25var client = mb.createClient({host: host, port: port});26client.buildExists('build').then(function (exists) {27 console.log('build exists: ' + exists);28});29var mb = require('mountebank');30var host = 'localhost';31var port = 2525;32var client = mb.createClient({host: host, port: port});33client.buildExists('build').then(function (exists) {34 console.log('build exists: ' + exists);35});36var mb = require('mountebank');37var host = 'localhost';38var port = 2525;39var client = mb.createClient({host: host, port: port});40client.buildExists('build').then(function (exists) {41 console.log('build exists: ' + exists);42});43var mb = require('mountebank');44var host = 'localhost';45var port = 2525;46var client = mb.createClient({host: host, port: port});47client.buildExists('build').then(function (exists) {48 console.log('

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var assert = require('assert');3var imposterPort = 4545;4mb.create({5 stubs: [{6 predicates: [{7 equals: {8 }9 }],10 responses: [{11 is: {12 }13 }]14 }]15}).then(function () {16 return mb.buildExists({ port: imposterPort });17}).then(function (exists) {18 assert(exists);19 console.log('Imposter exists');20 return mb.stop({ port: imposterPort });21}).then(function () {22 console.log('Imposter stopped');23 return mb.buildExists({ port: imposterPort });24}).then(function (exists) {25 assert(!exists);26 console.log('Imposter does not exist');27}).catch(function (error) {28 console.error(error);29});

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var mbHelper = require('mountebank-helper');3var assert = require('assert');4const port = 4545;5mb.create({6}).then(function () {7 console.log('Imposter created');8 var mbClient = mbHelper.createClient({9 });10 mbClient.buildExists({11 }).then(function () {12 console.log('Imposter is up and running');13 }).catch(function () {14 console.log('Imposter is not up and running');15 });16}, function () {17 console.log('Imposter not created');18});

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run mountebank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful