Best JavaScript code snippet using wpt
7_record_spec.js
Source:7_record_spec.js
1const _ = require('lodash')2const path = require('path')3const Promise = require('bluebird')4const bodyParser = require('body-parser')5const jsonSchemas = require('@cypress/json-schemas').api6const snapshot = require('snap-shot-it')7const e2e = require('../support/helpers/e2e').default8const fs = require('../../lib/util/fs')9const Fixtures = require('../support/helpers/fixtures')10const { expectRunsToHaveCorrectTimings } = require('../support/helpers/resultsUtils')11const postRunResponseWithWarnings = jsonSchemas.getExample('postRunResponse')('2.2.0')12const postRunResponse = _.assign({}, postRunResponseWithWarnings, { warnings: [] })13const postRunInstanceResponse = jsonSchemas.getExample('postRunInstanceResponse')('2.1.0')14const e2ePath = Fixtures.projectPath('e2e')15const outputPath = path.join(e2ePath, 'output.json')16let { runId, groupId, machineId, runUrl, tags } = postRunResponse17const { instanceId } = postRunInstanceResponse18let requests = null19const getRequestUrls = () => {20 return _.map(requests, 'url')21}22const getSchemaErr = (tag, err, schema) => {23 return {24 errors: err.errors,25 object: err.object,26 example: err.example,27 message: `${tag} should follow ${schema} schema`,28 }29}30const getResponse = function (responseSchema) {31 if (_.isObject(responseSchema)) {32 return responseSchema33 }34 const [name, version] = responseSchema.split('@')35 return jsonSchemas.getExample(name)(version)36}37const sendResponse = function (req, res, responseBody) {38 if (_.isFunction(responseBody)) {39 return responseBody(req, res)40 }41 return res.json(getResponse(responseBody))42}43const ensureSchema = function (expectedRequestSchema, responseBody, expectedResponseSchema) {44 let reqName; let reqVersion45 if (expectedRequestSchema) {46 [reqName, reqVersion] = expectedRequestSchema.split('@')47 }48 return function (req, res) {49 const { body } = req50 try {51 if (expectedRequestSchema) {52 jsonSchemas.assertSchema(reqName, reqVersion)(body)53 }54 res.expectedResponseSchema = expectedResponseSchema55 sendResponse(req, res, responseBody)56 const key = [req.method, req.url].join(' ')57 return requests.push({58 url: key,59 body,60 })61 } catch (err) {62 return res.status(412).json(getSchemaErr('request', err, expectedRequestSchema))63 }64 }65}66const sendUploadUrls = function (req, res) {67 const { body } = req68 let num = 069 const json = {}70 if (body.video) {71 json.videoUploadUrl = 'http://localhost:1234/videos/video.mp4'72 }73 const screenshotUploadUrls = _.map(body.screenshots, (s) => {74 num += 175 return {76 screenshotId: s.screenshotId,77 uploadUrl: `http://localhost:1234/screenshots/${num}.png`,78 }79 })80 json.screenshotUploadUrls = screenshotUploadUrls81 return res.json(json)82}83const assertResponseBodySchema = function (req, res, next) {84 const oldWrite = res.write85 const oldEnd = res.end86 const chunks = []87 res.write = (chunk) => {88 // buffer the response, we'll really write it on end89 return chunks.push(chunk)90 }91 res.end = function (chunk) {92 if (chunk) {93 chunks.push(chunk)94 }95 res.write = oldWrite96 res.end = oldEnd97 if (res.expectedResponseSchema && _.inRange(res.statusCode, 200, 299)) {98 const body = JSON.parse(Buffer.concat(chunks).toString('utf8'))99 const [resName, resVersion] = res.expectedResponseSchema.split('@')100 try {101 jsonSchemas.assertSchema(resName, resVersion)(body)102 } catch (err) {103 return res.status(412).json(getSchemaErr('response', err, res.expectedResponseSchema))104 }105 }106 chunks.map((chunk) => {107 return res.write(chunk)108 })109 return res.end()110 }111 return next()112}113const onServer = (routes) => {114 return (function (app) {115 app.use(bodyParser.json())116 app.use(assertResponseBodySchema)117 return _.each(routes, (route) => {118 return app[route.method](route.url, ensureSchema(119 route.req,120 route.res,121 route.resSchema,122 ))123 })124 })125}126const setup = (routes, settings = {}) => {127 return e2e.setup({128 settings: _.extend({129 projectId: 'pid123',130 videoUploadOnPasses: false,131 }, settings),132 servers: {133 port: 1234,134 onServer: onServer(routes),135 },136 })137}138const defaultRoutes = [139 {140 method: 'post',141 url: '/runs',142 req: 'postRunRequest@2.2.0',143 resSchema: 'postRunResponse@2.2.0',144 res: postRunResponse,145 }, {146 method: 'post',147 url: '/runs/:id/instances',148 req: 'postRunInstanceRequest@2.1.0',149 resSchema: 'postRunInstanceResponse@2.1.0',150 res: postRunInstanceResponse,151 }, {152 method: 'put',153 url: '/instances/:id',154 req: 'putInstanceRequest@3.0.0',155 resSchema: 'putInstanceResponse@2.0.0',156 res: sendUploadUrls,157 }, {158 method: 'put',159 url: '/instances/:id/stdout',160 req: 'putInstanceStdoutRequest@1.0.0',161 res (req, res) {162 return res.sendStatus(200)163 },164 }, {165 method: 'put',166 url: '/videos/:name',167 res (req, res) {168 return Promise.delay(500)169 .then(() => {170 return res.sendStatus(200)171 })172 },173 }, {174 method: 'put',175 url: '/screenshots/:name',176 res (req, res) {177 return res.sendStatus(200)178 },179 },180]181describe('e2e record', () => {182 beforeEach(() => {183 return requests = []184 })185 context('passing', () => {186 setup(defaultRoutes)187 it('passes', async function () {188 const { stdout } = await e2e.exec(this, {189 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',190 spec: 'record*',191 record: true,192 snapshot: true,193 outputPath,194 expectedExitCode: 3,195 })196 console.log(stdout)197 expect(stdout).to.include('Run URL:')198 expect(stdout).to.include(runUrl)199 const urls = getRequestUrls()200 // first create run request201 expect(urls[0]).to.eq('POST /runs')202 // grab the first set of 4203 const firstInstanceSet = urls.slice(1, 5)204 expect(firstInstanceSet).to.deep.eq([205 `POST /runs/${runId}/instances`,206 `PUT /instances/${instanceId}`,207 'PUT /videos/video.mp4',208 `PUT /instances/${instanceId}/stdout`,209 ])210 // grab the second set of 5211 const secondInstanceSet = urls.slice(5, 10)212 console.log(secondInstanceSet)213 expect(secondInstanceSet).to.have.members([214 `POST /runs/${runId}/instances`,215 `PUT /instances/${instanceId}`,216 'PUT /videos/video.mp4',217 'PUT /screenshots/1.png',218 `PUT /instances/${instanceId}/stdout`,219 ])220 // grab the third set of 5221 const thirdInstanceSet = urls.slice(10, 14)222 // no video because no tests failed223 expect(thirdInstanceSet).to.deep.eq([224 `POST /runs/${runId}/instances`,225 `PUT /instances/${instanceId}`,226 'PUT /screenshots/1.png',227 `PUT /instances/${instanceId}/stdout`,228 ])229 // grab the forth set of 5230 const forthInstanceSet = urls.slice(14, 19)231 expect(forthInstanceSet).to.have.members([232 `POST /runs/${runId}/instances`,233 `PUT /instances/${instanceId}`,234 'PUT /videos/video.mp4',235 'PUT /screenshots/1.png',236 `PUT /instances/${instanceId}/stdout`,237 ])238 const postRun = requests[0]239 // ensure its relative to projectRoot240 expect(postRun.body.specs).to.deep.eq([241 'cypress/integration/record_error_spec.coffee',242 'cypress/integration/record_fail_spec.coffee',243 'cypress/integration/record_pass_spec.coffee',244 'cypress/integration/record_uncaught_spec.coffee',245 ])246 expect(postRun.body.projectId).to.eq('pid123')247 expect(postRun.body.recordKey).to.eq('f858a2bc-b469-4e48-be67-0876339ee7e1')248 expect(postRun.body.specPattern).to.eq('cypress/integration/record*')249 const firstInstance = requests[1]250 expect(firstInstance.body.groupId).to.eq(groupId)251 expect(firstInstance.body.machineId).to.eq(machineId)252 expect(firstInstance.body.spec).to.eq(253 'cypress/integration/record_error_spec.coffee',254 )255 const firstInstancePut = requests[2]256 expect(firstInstancePut.body.error).to.include('Oops...we found an error preparing this test file')257 expect(firstInstancePut.body.tests).to.be.null258 expect(firstInstancePut.body.hooks).to.be.null259 expect(firstInstancePut.body.screenshots).to.have.length(0)260 expect(firstInstancePut.body.stats.tests).to.eq(0)261 expect(firstInstancePut.body.stats.failures).to.eq(1)262 expect(firstInstancePut.body.stats.passes).to.eq(0)263 const firstInstanceStdout = requests[4]264 expect(firstInstanceStdout.body.stdout).to.include('record_error_spec.coffee')265 const secondInstance = requests[5]266 expect(secondInstance.body.groupId).to.eq(groupId)267 expect(secondInstance.body.machineId).to.eq(machineId)268 expect(secondInstance.body.spec).to.eq(269 'cypress/integration/record_fail_spec.coffee',270 )271 const secondInstancePut = requests[6]272 expect(secondInstancePut.body.error).to.be.null273 expect(secondInstancePut.body.tests).to.have.length(2)274 expect(secondInstancePut.body.hooks).to.have.length(1)275 expect(secondInstancePut.body.screenshots).to.have.length(1)276 expect(secondInstancePut.body.stats.tests).to.eq(2)277 expect(secondInstancePut.body.stats.failures).to.eq(1)278 expect(secondInstancePut.body.stats.passes).to.eq(0)279 expect(secondInstancePut.body.stats.skipped).to.eq(1)280 const secondInstanceStdout = requests[9]281 expect(secondInstanceStdout.body.stdout).to.include('record_fail_spec.coffee')282 expect(secondInstanceStdout.body.stdout).not.to.include('record_error_spec.coffee')283 const thirdInstance = requests[10]284 expect(thirdInstance.body.groupId).to.eq(groupId)285 expect(thirdInstance.body.machineId).to.eq(machineId)286 expect(thirdInstance.body.spec).to.eq(287 'cypress/integration/record_pass_spec.coffee',288 )289 const thirdInstancePut = requests[11]290 expect(thirdInstancePut.body.error).to.be.null291 expect(thirdInstancePut.body.tests).to.have.length(2)292 expect(thirdInstancePut.body.hooks).to.have.length(0)293 expect(thirdInstancePut.body.screenshots).to.have.length(1)294 expect(thirdInstancePut.body.stats.tests).to.eq(2)295 expect(thirdInstancePut.body.stats.passes).to.eq(1)296 expect(thirdInstancePut.body.stats.failures).to.eq(0)297 expect(thirdInstancePut.body.stats.pending).to.eq(1)298 const thirdInstanceStdout = requests[13]299 expect(thirdInstanceStdout.body.stdout).to.include('record_pass_spec.coffee')300 expect(thirdInstanceStdout.body.stdout).not.to.include('record_error_spec.coffee')301 expect(thirdInstanceStdout.body.stdout).not.to.include('record_fail_spec.coffee')302 const fourthInstance = requests[14]303 expect(fourthInstance.body.groupId).to.eq(groupId)304 expect(fourthInstance.body.machineId).to.eq(machineId)305 expect(fourthInstance.body.spec).to.eq(306 'cypress/integration/record_uncaught_spec.coffee',307 )308 const fourthInstancePut = requests[15]309 expect(fourthInstancePut.body.error).to.be.null310 expect(fourthInstancePut.body.tests).to.have.length(1)311 expect(fourthInstancePut.body.hooks).to.have.length(0)312 expect(fourthInstancePut.body.screenshots).to.have.length(1)313 expect(fourthInstancePut.body.stats.tests).to.eq(1)314 expect(fourthInstancePut.body.stats.failures).to.eq(1)315 expect(fourthInstancePut.body.stats.passes).to.eq(0)316 const forthInstanceStdout = requests[18]317 expect(forthInstanceStdout.body.stdout).to.include('record_uncaught_spec.coffee')318 expect(forthInstanceStdout.body.stdout).not.to.include('record_error_spec.coffee')319 expect(forthInstanceStdout.body.stdout).not.to.include('record_fail_spec.coffee')320 expect(forthInstanceStdout.body.stdout).not.to.include('record_pass_spec.coffee')321 const runs = requests.filter((v) => v.body.tests).map((v) => v.body)322 expectRunsToHaveCorrectTimings(runs)323 snapshot(runs)324 const results = await fs.readJsonAsync(outputPath)325 expect(results.runUrl).to.equal(runUrl)326 })327 })328 context('parallelization', () => {329 const allSpecs = [330 'cypress/integration/record_error_spec.coffee',331 'cypress/integration/record_fail_spec.coffee',332 'cypress/integration/record_pass_spec.coffee',333 'cypress/integration/record_uncaught_spec.coffee',334 ]335 const postInstanceResponses = (specs) => {336 return _337 .chain(specs)338 .map((spec, i) => {339 return {340 spec,341 instanceId,342 estimatedWallClockDuration: (i + 1) * 1000,343 }344 })345 .concat({346 spec: null,347 instanceId: null,348 estimatedWallClockDuration: null,349 })350 .value()351 }352 // a1 does 3 specs, b2 does 1 spec353 const a1Specs = _.without(allSpecs, 'cypress/integration/record_pass_spec.coffee')354 const b2Specs = _.difference(allSpecs, a1Specs)355 let firstRunResponse = false356 let waitUntilSecondInstanceClaims = null357 const claimed = []358 const responses = {359 a1: postInstanceResponses(a1Specs),360 b2: postInstanceResponses(b2Specs),361 }362 // replace the 1st + 2nd routes object363 const routes = defaultRoutes.slice(0)364 routes[0] = {365 method: 'post',366 url: '/runs',367 req: 'postRunRequest@2.2.0',368 resSchema: 'postRunResponse@2.2.0',369 res (req, res) {370 let ciBuildId; let group;371 ({ group, tags, ciBuildId } = req.body)372 expect(group).to.eq('prod-e2e')373 expect(tags).to.deep.eq(['nightly'])374 expect(ciBuildId).to.eq('ciBuildId123')375 // if this is the first response376 // give machineId a1, else b2377 if (!firstRunResponse) {378 firstRunResponse = true379 machineId = 'a1ad2bcf-6398-46ed-b201-2fd90b188d5f'380 } else {381 machineId = 'b2bd2bcf-6398-46ed-b201-2fd90b188d5f'382 }383 return res.json(384 _.extend({}, postRunResponse, { machineId }),385 )386 },387 }388 routes[1] = {389 method: 'post',390 url: '/runs/:id/instances',391 req: 'postRunInstanceRequest@2.1.0',392 resSchema: 'postRunInstanceResponse@2.1.0',393 res (req, res) {394 let spec;395 ({ machineId, spec } = req.body)396 expect(spec).to.be.null397 const mId = machineId.slice(0, 2)398 const respond = function () {399 const resp = responses[mId].shift()400 // if theres a spec to claim401 if (resp.spec) {402 claimed.push(resp)403 }404 resp.claimedInstances = claimed.length405 resp.totalInstances = allSpecs.length406 jsonSchemas.assertSchema('postRunInstanceResponse', '2.1.0')(resp)407 return res.json(resp)408 }409 // when the 1st machine attempts to claim its FIRST spec, we410 // automatically delay it until the 2nd machine claims its FIRST411 // spec so that the request URL's are deterministic412 if ((mId === 'a1') && (claimed.length === 0)) {413 waitUntilSecondInstanceClaims = function () {414 waitUntilSecondInstanceClaims = null415 return respond()416 }417 } else {418 respond()419 return (typeof waitUntilSecondInstanceClaims === 'function' ? waitUntilSecondInstanceClaims() : undefined)420 }421 },422 }423 setup(routes)424 it('passes in parallel with group', function () {425 return Promise.all([426 e2e.exec(this, {427 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',428 spec: 'record*',429 group: 'prod-e2e',430 record: true,431 parallel: true,432 snapshot: true,433 tag: 'nightly',434 ciBuildId: 'ciBuildId123',435 expectedExitCode: 3,436 config: {437 trashAssetsBeforeRuns: false,438 },439 })440 .get('stdout'),441 // stagger the 2nd run442 // starting up a bit443 Promise444 .delay(3000)445 .then(() => {446 return e2e.exec(this, {447 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',448 spec: 'record*',449 group: 'prod-e2e',450 record: true,451 parallel: true,452 snapshot: true,453 tag: 'nightly',454 ciBuildId: 'ciBuildId123',455 config: {456 trashAssetsBeforeRuns: false,457 },458 })459 .get('stdout')460 }),461 ])462 })463 })464 context('misconfiguration', () => {465 setup([])466 it('errors and exits when no specs found', function () {467 return e2e.exec(this, {468 spec: 'notfound/**',469 snapshot: true,470 expectedExitCode: 1,471 })472 .then(() => {473 expect(getRequestUrls()).to.be.empty474 })475 })476 it('errors and exits when no browser found', function () {477 return e2e.exec(this, {478 browser: 'browserDoesNotExist',479 spec: 'record_pass*',480 snapshot: true,481 expectedExitCode: 1,482 })483 .then(() => {484 expect(getRequestUrls()).to.be.empty485 })486 })487 })488 context('projectId', () => {489 e2e.setup()490 it('errors and exits without projectId', function () {491 return e2e.exec(this, {492 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',493 spec: 'record_pass*',494 record: true,495 snapshot: true,496 expectedExitCode: 1,497 })498 })499 })500 context('recordKey', () => {501 setup(defaultRoutes)502 it('errors and exits without recordKey', function () {503 return e2e.exec(this, {504 spec: 'record_pass*',505 record: true,506 snapshot: true,507 expectedExitCode: 1,508 })509 .then(() => {510 expect(getRequestUrls()).to.be.empty511 })512 })513 it('warns but does not exit when is forked pr', function () {514 process.env.CIRCLECI = 'true'515 process.env.CIRCLE_PR_NUMBER = '123'516 process.env.CIRCLE_PR_USERNAME = 'brian-mann'517 process.env.CIRCLE_PR_REPONAME = 'cypress'518 process.env.CYPRESS_INTERNAL_E2E_TESTS = '0'519 return e2e.exec(this, {520 spec: 'record_pass*',521 record: true,522 snapshot: true,523 })524 .then(() => {525 console.log('GETREQUESTURLS', getRequestUrls())526 expect(getRequestUrls()).to.be.empty527 })528 })529 it('warns but does not exit when is forked pr and parallel', function () {530 process.env.CIRCLECI = 'true'531 process.env.CIRCLE_WORKFLOW_ID = '123'532 process.env.CIRCLE_PR_NUMBER = '123'533 process.env.CIRCLE_PR_USERNAME = 'brian-mann'534 process.env.CIRCLE_PR_REPONAME = 'cypress'535 process.env.CYPRESS_INTERNAL_E2E_TESTS = '0'536 return e2e.exec(this, {537 spec: 'record_pass*',538 record: true,539 parallel: true,540 snapshot: true,541 })542 .then(() => {543 expect(getRequestUrls()).to.be.empty544 })545 })546 })547 context('video recording', () => {548 setup(defaultRoutes, {549 video: false,550 })551 it('does not upload when not enabled', function () {552 return e2e.exec(this, {553 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',554 spec: 'record_pass*',555 record: true,556 snapshot: true,557 })558 })559 })560 context('api interaction errors', () => {561 describe('recordKey and projectId', () => {562 const routes = [563 {564 method: 'post',565 url: '/runs',566 req: 'postRunRequest@2.2.0',567 res (req, res) {568 return res.sendStatus(401)569 },570 },571 ]572 setup(routes)573 it('errors and exits on 401', function () {574 return e2e.exec(this, {575 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',576 spec: 'record_pass*',577 record: true,578 snapshot: true,579 expectedExitCode: 1,580 })581 })582 })583 describe('project 404', () => {584 const routes = [585 {586 method: 'post',587 url: '/runs',588 req: 'postRunRequest@2.2.0',589 res (req, res) {590 return res.sendStatus(404)591 },592 },593 ]594 setup(routes)595 it('errors and exits', function () {596 return e2e.exec(this, {597 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',598 spec: 'record_pass*',599 record: true,600 snapshot: true,601 expectedExitCode: 1,602 })603 })604 })605 describe('create run 500', () => {606 const routes = [{607 method: 'post',608 url: '/runs',609 req: 'postRunRequest@2.2.0',610 res (req, res) {611 return res.sendStatus(500)612 },613 }]614 setup(routes)615 it('warns and does not create or update instances', function () {616 process.env.DISABLE_API_RETRIES = 'true'617 return e2e.exec(this, {618 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',619 spec: 'record_pass*',620 record: true,621 snapshot: true,622 })623 .then(() => {624 const urls = getRequestUrls()625 expect(urls).to.deep.eq([626 'POST /runs',627 ])628 })629 })630 it('warns but proceeds when grouping without parallelization', function () {631 process.env.DISABLE_API_RETRIES = 'true'632 return e2e.exec(this, {633 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',634 spec: 'record_pass*',635 group: 'foo',636 record: true,637 snapshot: true,638 ciBuildId: 'ciBuildId123',639 })640 .then(() => {641 const urls = getRequestUrls()642 expect(urls).to.deep.eq([643 'POST /runs',644 ])645 })646 })647 it('does not proceed and exits with error when parallelizing', function () {648 process.env.DISABLE_API_RETRIES = 'true'649 return e2e.exec(this, {650 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',651 spec: 'record_pass*',652 group: 'foo',653 tag: 'nightly',654 record: true,655 parallel: true,656 snapshot: true,657 ciBuildId: 'ciBuildId123',658 expectedExitCode: 1,659 })660 .then(() => {661 const urls = getRequestUrls()662 expect(urls).to.deep.eq([663 'POST /runs',664 ])665 })666 })667 })668 describe('create instance 500', () => {669 const routes = defaultRoutes.slice(0)670 routes[1] = {671 method: 'post',672 url: '/runs/:id/instances',673 req: 'postRunInstanceRequest@2.1.0',674 resSchema: 'postRunInstanceResponse@2.1.0',675 res (req, res) {676 return res.sendStatus(500)677 },678 }679 setup(routes)680 it('does not proceed and exits with error when parallelizing and creating instance', function () {681 process.env.DISABLE_API_RETRIES = 'true'682 return e2e.exec(this, {683 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',684 spec: 'record_pass*',685 group: 'foo',686 tag: 'nightly',687 record: true,688 parallel: true,689 snapshot: true,690 ciBuildId: 'ciBuildId123',691 expectedExitCode: 1,692 })693 .then(() => {694 const urls = getRequestUrls()695 expect(urls).to.deep.eq([696 'POST /runs',697 `POST /runs/${runId}/instances`,698 ])699 })700 })701 })702 describe('update instance 500', () => {703 const routes = defaultRoutes.slice(0)704 routes[1] = {705 method: 'post',706 url: '/runs/:id/instances',707 req: 'postRunInstanceRequest@2.1.0',708 resSchema: 'postRunInstanceResponse@2.1.0',709 res (req, res) {710 return res.json({711 instanceId,712 spec: 'cypress/integration/record_pass_spec.coffee',713 estimatedWallClockDuration: 5000,714 totalInstances: 1,715 claimedInstances: 1,716 })717 },718 }719 routes[2] = {720 method: 'put',721 url: '/instances/:id',722 req: 'putInstanceRequest@3.0.0',723 res (req, res) {724 return res.sendStatus(500)725 },726 }727 setup(routes)728 it('does not proceed and exits with error when parallelizing and updating instance', function () {729 process.env.DISABLE_API_RETRIES = 'true'730 return e2e.exec(this, {731 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',732 spec: 'record_pass*',733 group: 'foo',734 tag: 'nightly',735 record: true,736 parallel: true,737 snapshot: true,738 ciBuildId: 'ciBuildId123',739 expectedExitCode: 1,740 })741 .then(() => {742 const urls = getRequestUrls()743 expect(urls).to.deep.eq([744 'POST /runs',745 `POST /runs/${runId}/instances`,746 'PUT /instances/e9e81b5e-cc58-4026-b2ff-8ae3161435a6',747 ])748 })749 })750 })751 describe('create run 422', () => {752 const routes = [{753 method: 'post',754 url: '/runs',755 req: 'postRunRequest@2.2.0',756 res (req, res) {757 return res.status(422).json({758 code: 'RUN_GROUP_NAME_NOT_UNIQUE',759 message: 'Run group name cannot be used again without passing the parallel flag.',760 payload: {761 runUrl: 'https://dashboard.cypress.io/runs/12345',762 },763 })764 },765 }]766 setup(routes)767 // the other 422 tests for this are in integration/cypress_spec768 it('errors and exits when group name is in use', function () {769 process.env.CIRCLECI = '1'770 return e2e.exec(this, {771 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',772 spec: 'record_pass*',773 group: 'e2e-tests',774 record: true,775 snapshot: true,776 expectedExitCode: 1,777 })778 .then(() => {779 const urls = getRequestUrls()780 expect(urls).to.deep.eq([781 'POST /runs',782 ])783 })784 })785 })786 describe('create run unknown 422', () => {787 const routes = [{788 method: 'post',789 url: '/runs',790 req: 'postRunRequest@2.2.0',791 res (req, res) {792 return res.status(422).json({793 code: 'SOMETHING_UNKNOWN',794 message: 'An unknown message here from the server.',795 })796 },797 }]798 setup(routes)799 it('errors and exits when there is an unknown 422 response', function () {800 return e2e.exec(this, {801 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',802 spec: 'record_pass*',803 group: 'e2e-tests',804 tag: 'nightly',805 record: true,806 parallel: true,807 snapshot: true,808 ciBuildId: 'ciBuildId123',809 expectedExitCode: 1,810 })811 .then(() => {812 const urls = getRequestUrls()813 expect(urls).to.deep.eq([814 'POST /runs',815 ])816 })817 })818 })819 describe('create run 402 - free plan exceeds monthly private tests', () => {820 setup([{821 method: 'post',822 url: '/runs',823 req: 'postRunRequest@2.2.0',824 res (req, res) {825 return res.status(402).json({826 code: 'FREE_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS',827 payload: {828 used: 600,829 limit: 500,830 orgId: 'org-id-1234',831 },832 })833 },834 }])835 it('errors and exits when on free plan and over recorded runs limit', function () {836 return e2e.exec(this, {837 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',838 spec: 'record_pass*',839 record: true,840 snapshot: true,841 expectedExitCode: 1,842 })843 })844 })845 describe('create run 402 - free plan exceeds monthly tests', () => {846 setup([{847 method: 'post',848 url: '/runs',849 req: 'postRunRequest@2.2.0',850 res (req, res) {851 return res.status(402).json({852 code: 'FREE_PLAN_EXCEEDS_MONTHLY_TESTS',853 payload: {854 used: 600,855 limit: 500,856 orgId: 'org-id-1234',857 },858 })859 },860 }])861 it('errors and exits when on free plan and over recorded tests limit', function () {862 return e2e.exec(this, {863 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',864 spec: 'record_pass*',865 record: true,866 snapshot: true,867 expectedExitCode: 1,868 })869 })870 })871 describe('create run 402 - parallel feature not available in plan', () => {872 setup([{873 method: 'post',874 url: '/runs',875 req: 'postRunRequest@2.2.0',876 res (req, res) {877 return res.status(402).json({878 code: 'PARALLEL_FEATURE_NOT_AVAILABLE_IN_PLAN',879 payload: {880 orgId: 'org-id-1234',881 },882 })883 },884 }])885 it('errors and exits when attempting parallel run when not available in plan', function () {886 return e2e.exec(this, {887 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',888 spec: 'record_pass*',889 record: true,890 snapshot: true,891 expectedExitCode: 1,892 })893 })894 })895 describe('create run 402 - grouping feature not available in plan', () => {896 setup([{897 method: 'post',898 url: '/runs',899 req: 'postRunRequest@2.2.0',900 res (req, res) {901 return res.status(402).json({902 code: 'RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN',903 payload: {904 orgId: 'org-id-1234',905 },906 })907 },908 }])909 it('errors and exits when attempting parallel run when not available in plan', function () {910 return e2e.exec(this, {911 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',912 spec: 'record_pass*',913 record: true,914 snapshot: true,915 expectedExitCode: 1,916 })917 })918 })919 describe('create run 402 - unknown error', () => {920 setup([{921 method: 'post',922 url: '/runs',923 req: 'postRunRequest@2.2.0',924 res (req, res) {925 return res.status(402).json({926 error: 'Something went wrong',927 })928 },929 }])930 it('errors and exits when there\'s an unknown 402 error', function () {931 return e2e.exec(this, {932 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',933 spec: 'record_pass*',934 record: true,935 snapshot: true,936 expectedExitCode: 1,937 })938 })939 })940 describe('create instance', () => {941 const routes = [942 {943 method: 'post',944 url: '/runs',945 req: 'postRunRequest@2.2.0',946 resSchema: 'postRunResponse@2.2.0',947 res: postRunResponse,948 }, {949 method: 'post',950 url: '/runs/:id/instances',951 req: 'postRunInstanceRequest@2.1.0',952 resSchema: 'postRunInstanceResponse@2.1.0',953 res (req, res) {954 return res.sendStatus(500)955 },956 },957 ]958 setup(routes)959 it('does not update instance', function () {960 process.env.DISABLE_API_RETRIES = 'true'961 return e2e.exec(this, {962 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',963 spec: 'record_pass*',964 record: true,965 snapshot: true,966 })967 .then(() => {968 const urls = getRequestUrls()969 expect(urls).to.deep.eq([970 'POST /runs',971 `POST /runs/${runId}/instances`,972 ])973 })974 })975 })976 describe('update instance', () => {977 const routes = [978 {979 method: 'post',980 url: '/runs',981 req: 'postRunRequest@2.2.0',982 resSchema: 'postRunResponse@2.2.0',983 res: postRunResponse,984 }, {985 method: 'post',986 url: '/runs/:id/instances',987 req: 'postRunInstanceRequest@2.1.0',988 resSchema: 'postRunInstanceResponse@2.1.0',989 res: postRunInstanceResponse,990 }, {991 method: 'put',992 url: '/instances/:id',993 req: 'putInstanceRequest@3.0.0',994 res (req, res) {995 return res.sendStatus(500)996 },997 },998 ]999 setup(routes)1000 it('does not update instance stdout', function () {1001 process.env.DISABLE_API_RETRIES = 'true'1002 return e2e.exec(this, {1003 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1004 spec: 'record_pass*',1005 record: true,1006 snapshot: true,1007 })1008 .then(() => {1009 const urls = getRequestUrls()1010 expect(urls).to.deep.eq([1011 'POST /runs',1012 `POST /runs/${runId}/instances`,1013 `PUT /instances/${instanceId}`,1014 ])1015 })1016 })1017 })1018 describe('update instance stdout', () => {1019 const routes = [1020 {1021 method: 'post',1022 url: '/runs',1023 req: 'postRunRequest@2.2.0',1024 resSchema: 'postRunResponse@2.2.0',1025 res: postRunResponse,1026 }, {1027 method: 'post',1028 url: '/runs/:id/instances',1029 req: 'postRunInstanceRequest@2.1.0',1030 resSchema: 'postRunInstanceResponse@2.1.0',1031 res: postRunInstanceResponse,1032 }, {1033 method: 'put',1034 url: '/instances/:id',1035 req: 'putInstanceRequest@3.0.0',1036 resSchema: 'putInstanceResponse@2.0.0',1037 res: sendUploadUrls,1038 }, {1039 method: 'put',1040 url: '/instances/:id/stdout',1041 req: 'putInstanceStdoutRequest@1.0.0',1042 resSchema: 'putInstanceStdoutRequest@1.0.0',1043 res (req, res) {1044 return res.sendStatus(500)1045 },1046 }, {1047 method: 'put',1048 url: '/videos/:name',1049 res (req, res) {1050 return Promise.delay(500)1051 .then(() => {1052 return res.sendStatus(200)1053 })1054 },1055 }, {1056 method: 'put',1057 url: '/screenshots/:name',1058 res (req, res) {1059 return res.sendStatus(200)1060 },1061 },1062 ]1063 setup(routes)1064 it('warns but proceeds', function () {1065 process.env.DISABLE_API_RETRIES = 'true'1066 return e2e.exec(this, {1067 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1068 spec: 'record_pass*',1069 record: true,1070 snapshot: true,1071 })1072 .then(() => {1073 const urls = getRequestUrls()1074 expect(urls).to.deep.eq([1075 'POST /runs',1076 `POST /runs/${runId}/instances`,1077 `PUT /instances/${instanceId}`,1078 'PUT /screenshots/1.png',1079 `PUT /instances/${instanceId}/stdout`,1080 ])1081 })1082 })1083 })1084 describe('uploading assets', () => {1085 const routes = [1086 {1087 method: 'post',1088 url: '/runs',1089 req: 'postRunRequest@2.2.0',1090 resSchema: 'postRunResponse@2.2.0',1091 res: postRunResponse,1092 }, {1093 method: 'post',1094 url: '/runs/:id/instances',1095 req: 'postRunInstanceRequest@2.1.0',1096 resSchema: 'postRunInstanceResponse@2.1.0',1097 res: postRunInstanceResponse,1098 }, {1099 method: 'put',1100 url: '/instances/:id',1101 req: 'putInstanceRequest@3.0.0',1102 resSchema: 'putInstanceResponse@2.0.0',1103 res: sendUploadUrls,1104 }, {1105 method: 'put',1106 url: '/instances/:id/stdout',1107 req: 'putInstanceStdoutRequest@1.0.0',1108 res (req, res) {1109 return res.sendStatus(200)1110 },1111 }, {1112 method: 'put',1113 url: '/videos/:name',1114 res (req, res) {1115 return Promise.delay(500)1116 .then(() => {1117 return res.sendStatus(500)1118 })1119 },1120 }, {1121 method: 'put',1122 url: '/screenshots/:name',1123 res (req, res) {1124 return res.sendStatus(500)1125 },1126 },1127 ]1128 setup(routes, {1129 videoUploadOnPasses: true,1130 })1131 it('warns but proceeds', function () {1132 return e2e.exec(this, {1133 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1134 spec: 'record_pass*',1135 record: true,1136 snapshot: true,1137 })1138 .then(() => {1139 const urls = getRequestUrls()1140 expect(urls).to.have.members([1141 'POST /runs',1142 `POST /runs/${runId}/instances`,1143 `PUT /instances/${instanceId}`,1144 'PUT /videos/video.mp4',1145 'PUT /screenshots/1.png',1146 `PUT /instances/${instanceId}/stdout`,1147 ])1148 })1149 })1150 })1151 describe('api retries on error', () => {1152 let count = 01153 const routes = defaultRoutes.slice(0)1154 routes[0] = {1155 method: 'post',1156 url: '/runs',1157 req: 'postRunRequest@2.2.0',1158 res (req, res) {1159 count += 11160 if (count === 4) {1161 return res.json(postRunResponse)1162 }1163 return res.sendStatus(500)1164 },1165 }1166 routes[1] = {1167 method: 'post',1168 url: '/runs/:id/instances',1169 req: 'postRunInstanceRequest@2.1.0',1170 resSchema: 'postRunInstanceResponse@2.1.0',1171 res (req, res) {1172 count += 11173 if (count === 5) {1174 return res.sendStatus(500)1175 }1176 if (count === 6) {1177 return res.json({1178 instanceId,1179 spec: 'cypress/integration/record_pass_spec.coffee',1180 estimatedWallClockDuration: 5000,1181 totalInstances: 1,1182 claimedInstances: 1,1183 })1184 }1185 return res.json({1186 instanceId,1187 spec: null,1188 estimatedWallClockDuration: null,1189 totalInstances: 0,1190 claimedInstances: 0,1191 })1192 },1193 }1194 setup(routes)1195 it('warns and does not create or update instances', function () {1196 process.env.API_RETRY_INTERVALS = '1000,2000,3000'1197 return e2e.exec(this, {1198 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1199 spec: 'record_pass*',1200 group: 'foo',1201 tag: 'nightly',1202 record: true,1203 parallel: true,1204 snapshot: true,1205 ciBuildId: 'ciBuildId123',1206 })1207 .then(() => {1208 const urls = getRequestUrls()1209 expect(urls).to.deep.eq([1210 'POST /runs',1211 'POST /runs',1212 'POST /runs',1213 'POST /runs',1214 'POST /runs/00748421-e035-4a3d-8604-8468cc48bdb5/instances',1215 'POST /runs/00748421-e035-4a3d-8604-8468cc48bdb5/instances',1216 'PUT /instances/e9e81b5e-cc58-4026-b2ff-8ae3161435a6',1217 'PUT /screenshots/1.png',1218 'PUT /instances/e9e81b5e-cc58-4026-b2ff-8ae3161435a6/stdout',1219 'POST /runs/00748421-e035-4a3d-8604-8468cc48bdb5/instances',1220 ])1221 })1222 })1223 })1224 })1225 describe('api interaction warnings', () => {1226 describe('create run warnings', () => {1227 describe('grace period - over private tests limit', () => {1228 const routes = defaultRoutes.slice()1229 routes[0] = {1230 method: 'post',1231 url: '/runs',1232 req: 'postRunRequest@2.2.0',1233 resSchema: 'postRunResponse@2.2.0',1234 res (req, res) {1235 return res.status(200).json({1236 runId,1237 groupId,1238 machineId,1239 runUrl,1240 tags,1241 warnings: [{1242 name: 'foo',1243 message: 'foo',1244 code: 'FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_PRIVATE_TESTS',1245 limit: 500,1246 gracePeriodEnds: '2999-12-31',1247 orgId: 'org-id-1234',1248 }],1249 })1250 },1251 }1252 setup(routes)1253 it('warns when over private test recordings', function () {1254 return e2e.exec(this, {1255 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1256 spec: 'record_pass*',1257 record: true,1258 snapshot: true,1259 })1260 })1261 })1262 describe('grace period - over tests limit', () => {1263 const routes = defaultRoutes.slice()1264 routes[0] = {1265 method: 'post',1266 url: '/runs',1267 req: 'postRunRequest@2.2.0',1268 resSchema: 'postRunResponse@2.2.0',1269 res (req, res) {1270 return res.status(200).json({1271 runId,1272 groupId,1273 machineId,1274 runUrl,1275 tags,1276 warnings: [{1277 name: 'foo',1278 message: 'foo',1279 code: 'FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_TESTS',1280 limit: 500,1281 gracePeriodEnds: '2999-12-31',1282 orgId: 'org-id-1234',1283 }],1284 })1285 },1286 }1287 setup(routes)1288 it('warns when over test recordings', function () {1289 return e2e.exec(this, {1290 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1291 spec: 'record_pass*',1292 record: true,1293 snapshot: true,1294 })1295 })1296 })1297 describe('grace period - parallel feature', () => {1298 const routes = defaultRoutes.slice()1299 routes[0] = {1300 method: 'post',1301 url: '/runs',1302 req: 'postRunRequest@2.2.0',1303 resSchema: 'postRunResponse@2.2.0',1304 res (req, res) {1305 return res.status(200).json({1306 runId,1307 groupId,1308 machineId,1309 runUrl,1310 tags,1311 warnings: [{1312 name: 'foo',1313 message: 'foo',1314 code: 'FREE_PLAN_IN_GRACE_PERIOD_PARALLEL_FEATURE',1315 gracePeriodEnds: '2999-12-31',1316 orgId: 'org-id-1234',1317 }],1318 })1319 },1320 }1321 setup(routes)1322 it('warns when using parallel feature', function () {1323 return e2e.exec(this, {1324 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1325 spec: 'record_pass*',1326 record: true,1327 snapshot: true,1328 })1329 })1330 })1331 describe('grace period - grouping feature', () => {1332 const routes = defaultRoutes.slice()1333 routes[0] = {1334 method: 'post',1335 url: '/runs',1336 req: 'postRunRequest@2.2.0',1337 resSchema: 'postRunResponse@2.2.0',1338 res (req, res) {1339 return res.status(200).json({1340 runId,1341 groupId,1342 machineId,1343 runUrl,1344 tags,1345 warnings: [{1346 name: 'foo',1347 message: 'foo',1348 code: 'PLAN_IN_GRACE_PERIOD_RUN_GROUPING_FEATURE_USED',1349 gracePeriodEnds: '2999-12-31',1350 orgId: 'org-id-1234',1351 }],1352 })1353 },1354 }1355 setup(routes)1356 it('warns when using parallel feature', function () {1357 return e2e.exec(this, {1358 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1359 spec: 'record_pass*',1360 record: true,1361 snapshot: true,1362 })1363 })1364 })1365 describe('paid plan - over private tests limit', () => {1366 const routes = defaultRoutes.slice()1367 routes[0] = {1368 method: 'post',1369 url: '/runs',1370 req: 'postRunRequest@2.2.0',1371 resSchema: 'postRunResponse@2.2.0',1372 res (req, res) {1373 return res.status(200).json({1374 runId,1375 groupId,1376 machineId,1377 runUrl,1378 tags,1379 warnings: [{1380 name: 'foo',1381 message: 'foo',1382 code: 'PAID_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS',1383 used: 700,1384 limit: 500,1385 orgId: 'org-id-1234',1386 }],1387 })1388 },1389 }1390 setup(routes)1391 it('warns when over private test recordings', function () {1392 return e2e.exec(this, {1393 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1394 spec: 'record_pass*',1395 record: true,1396 snapshot: true,1397 })1398 })1399 })1400 describe('paid plan - over tests limit', () => {1401 const routes = defaultRoutes.slice()1402 routes[0] = {1403 method: 'post',1404 url: '/runs',1405 req: 'postRunRequest@2.2.0',1406 resSchema: 'postRunResponse@2.2.0',1407 res (req, res) {1408 return res.status(200).json({1409 runId,1410 groupId,1411 machineId,1412 runUrl,1413 tags,1414 warnings: [{1415 name: 'foo',1416 message: 'foo',1417 code: 'PAID_PLAN_EXCEEDS_MONTHLY_TESTS',1418 used: 700,1419 limit: 500,1420 orgId: 'org-id-1234',1421 }],1422 })1423 },1424 }1425 setup(routes)1426 it('warns when over test recordings', function () {1427 return e2e.exec(this, {1428 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1429 spec: 'record_pass*',1430 record: true,1431 snapshot: true,1432 })1433 })1434 })1435 describe('unknown warning', () => {1436 const routes = defaultRoutes.slice()1437 routes[0] = {1438 method: 'post',1439 url: '/runs',1440 req: 'postRunRequest@2.2.0',1441 resSchema: 'postRunResponse@2.2.0',1442 res: postRunResponseWithWarnings,1443 }1444 setup(routes)1445 it('warns with unknown warning code', function () {1446 return e2e.exec(this, {1447 key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',1448 spec: 'record_pass*',1449 record: true,1450 snapshot: true,1451 })1452 })1453 })1454 })1455 })...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getRequestURLs(url, function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9wpt.getTesters(function(err, data) {10 if (err) return console.error(err);11 console.log(data);12});13var wpt = require('webpagetest');14var wpt = new WebPageTest('www.webpagetest.org');15wpt.getLocations(function(err, data) {16 if (err) return console.error(err);17 console.log(data);18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21wpt.getBrowsers(function(err, data) {22 if (err) return console.error(err);23 console.log(data);24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org');27wpt.getTesters(function(err, data) {28 if (err) return console.error(err);29 console.log(data);30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');33wpt.getTesters(function(err, data) {34 if (err) return console.error(err);35 console.log(data);36});37var wpt = require('webpagetest');38var wpt = new WebPageTest('www.webpagetest.org');39wpt.getTesters(function(err, data) {40 if (err) return console.error(err);41 console.log(data);42});
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getRequestURLs(url, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('wpt');11var wpt = new WebPageTest('www.webpagetest.org');12wpt.getRequests(url, function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var wpt = require('wpt');20var wpt = new WebPageTest('www.webpagetest.org');21wpt.getTimings(url, function(err, data) {22 if (err) {23 console.log(err);24 } else {25 console.log(data);26 }27});28var wpt = require('wpt');29var wpt = new WebPageTest('www.webpagetest.org');30wpt.getBreakdown(url, function(err, data) {31 if (err) {32 console.log(err);33 } else {34 console.log(data);35 }36});37var wpt = require('wpt');38var wpt = new WebPageTest('www.webpagetest.org');39wpt.getLocations(function(err, data) {40 if (err) {41 console.log(err);42 } else {43 console.log(data);44 }45});46var wpt = require('wpt');47var wpt = new WebPageTest('www.webpagetest.org');48wpt.getTesters(function(err, data) {49 if (err) {50 console.log(err);51 } else {52 console.log(data);53 }54});
Using AI Code Generation
1var wpt = require('./wpt.js');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log(data);7 }8});
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5wpt.runTest(options, function(err, data) {6 if (err) return console.error(err);7 wpt.getRequestURLs(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log(data);10 });11});12{13 "scripts": {14 },15 "dependencies": {16 }17}
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('wpt');10var wpt = new WebPageTest('www.webpagetest.org');11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = require('wpt');18var wpt = new WebPageTest('www.webpagetest.org');19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('wpt');26var wpt = new WebPageTest('www.webpagetest.org');27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var wpt = require('wpt');34var wpt = new WebPageTest('www.webpagetest.org');35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('wpt');42var wpt = new WebPageTest('www.webpagetest.org');43 if (err) {44 console.log(err);
Using AI Code Generation
1var wpt = require('webpagetest');2console.log(urls);3var wpt = require('webpagetest');4 console.log(urls);5});6var wpt = require('webpagetest');7 console.log(urls);8});9var wpt = require('webpagetest');10 console.log(urls);11});12var wpt = require('webpagetest');13 console.log(urls);14});15var wpt = require('webpagetest');16 console.log(urls);17});18var wpt = require('webpagetest');19 console.log(urls);20});21var wpt = require('webpagetest');22 console.log(urls);23});24var wpt = require('webpagetest');
Using AI Code Generation
1var wpt = require('./wpt.js');2console.log(urls);3exports.getRequestURLs = function(url) {4 var requestUrls = [];5 requestUrls.push(url);6 return requestUrls;7}8var wpt = require('./wpt.js');9console.log(testId);10exports.createTest = function(url) {11 var testId = '12345';12 return testId;13}14var wpt = require('./wpt.js');15var testStatus = wpt.getTestStatus('12345');16console.log(testStatus);17exports.getTestStatus = function(testId) {18 var testStatus = 'Test is running';19 return testStatus;20}21var wpt = require('./wpt.js');22var testResults = wpt.getTestResults('12345');
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!!