UNPKG

@apica-io/asm-pm-runner

Version:

Run a postman collection in Apica ASM.

194 lines 6.69 kB
{ "info": { "_postman_id": "ed0ace16-baa7-46ac-ae4c-fbd1702c3c25", "name": "Lighthouse", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Lighthouse call", "event": [ { "listen": "prerequest", "script": { "exec": [ "const items = ['DESKTOP', 'MOBILE'];", "pm.expect(items).to.contain(pm.environment.get(\"desktopOrMobile\"));", "", "const returnTypes = ['firstMeaningfulPaint', 'firstContentfulPaint', 'speedIndex', 'largestContentfulPaint', 'maxpotentialfid', 'interactive', 'totalBlockingTime'];", "pm.expect(returnTypes).to.contain(pm.environment.get(\"returnCheckType\"));" ], "type": "text/javascript" } }, { "listen": "test", "script": { "exec": [ "// Created by Christian Backström", "// Created date: 2021-11-03", "// Last update: 2021-11-03", "// Revision: 1.0", "//", "//", "// Required params in asm: ", "// requestURL (valid url to check against lighthouse)", "// desktopOrMobile (MOBILE or DESKTOP only)", "// returnCheckType (only these options: 'firstMeaningfulPaint', 'firstContentfulPaint', 'speedIndex', 'largestContentfulPaint', 'maxpotentialfid', 'interactive', 'totalBlockingTime')", "", "", "pm.test(\"Response must be valid and have a json body\", function () {", " pm.response.to.be.ok;", " pm.response.to.be.withBody;", " pm.response.to.be.json;", " pm.response.to.have.status(200);", "});", "var jsonData = pm.response.json();", "pm.collectionVariables.set(\"firstMeaningfulPaint\", jsonData.lighthouseResult.audits.metrics.details.items[0].firstMeaningfulPaint);", "pm.collectionVariables.set(\"firstContentfulPaint\", jsonData.lighthouseResult.audits.metrics.details.items[0].firstContentfulPaint);", "pm.collectionVariables.set(\"speedIndex\", jsonData.lighthouseResult.audits.metrics.details.items[0].speedIndex);", "pm.collectionVariables.set(\"largestContentfulPaint\", jsonData.lighthouseResult.audits.metrics.details.items[0].largestContentfulPaint);", "pm.collectionVariables.set(\"maxpotentialfid\", jsonData.lighthouseResult.audits[\"max-potential-fid\"].numericValue);", "pm.collectionVariables.set(\"interactive\", jsonData.lighthouseResult.audits.metrics.details.items[0].interactive);", "pm.collectionVariables.set(\"totalBlockingTime\", jsonData.lighthouseResult.audits.metrics.details.items[0].totalBlockingTime);", "", "if (pm.environment.get(\"returnCheckType\") == \"firstMeaningfulPaint\"){", " returnValue = pm.collectionVariables.get(\"firstMeaningfulPaint\");", " pm.test(\"First Meaningful Paint is 0 or above\", function () {", " pm.expect(returnValue).to.be.least(0);", " });", "} else if (pm.environment.get(\"returnCheckType\") == \"firstContentfulPaint\"){", " returnValue = pm.collectionVariables.get(\"firstContentfulPaint\");", " pm.test(\"First Contentful Painting is 0 or above\", function () {", " pm.expect(returnValue).to.be.least(0);", " });", "} else if (pm.environment.get(\"returnCheckType\") == \"speedIndex\"){", " returnValue = pm.collectionVariables.get(\"speedIndex\");", " pm.test(\"The Speed Index is 0 or above\", function () {", " pm.expect(returnValue).to.be.least(0);", " });", "} else if (pm.environment.get(\"returnCheckType\") == \"largestContentfulPaint\"){", " returnValue = pm.collectionVariables.get(\"largestContentfulPaint\");", " pm.test(\"Largest Contentful Painting is 0 or above\", function () {", " pm.expect(returnValue).to.be.least(0);", " });", "} else if (pm.environment.get(\"returnCheckType\") == \"maxpotentialfid\"){", " returnValue = pm.collectionVariables.get(\"maxpotentialfid\");", " pm.test(\"First Input Delay is 0 or above\", function () {", " pm.expect(returnValue).to.be.least(0);", " });", "} else if (pm.environment.get(\"returnCheckType\") == \"interactive\"){", " returnValue = pm.collectionVariables.get(\"interactive\");", " pm.test(\"Time to Interactive is 0 or above\", function () {", " pm.expect(returnValue).to.be.least(0);", " });", "} else if (pm.environment.get(\"returnCheckType\") == \"totalBlockingTime\"){", " returnValue = pm.collectionVariables.get(\"totalBlockingTime\");", " pm.test(\"Total Blocking Time is 0 or above\", function () {", " pm.expect(returnValue).to.be.least(0);", " });", "} ", "pm.collectionVariables.set(\"_Apica_ReturnValue\", returnValue);" ], "type": "text/javascript" } } ], "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { "method": "GET", "header": [], "body": { "mode": "raw", "raw": "", "options": { "raw": { "language": "json" } } }, "url": { "raw": "https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url={{requestURL}}&strategy={{desktopOrMobile}}", "protocol": "https", "host": [ "pagespeedonline", "googleapis", "com" ], "path": [ "pagespeedonline", "v5", "runPagespeed" ], "query": [ { "key": "url", "value": "{{requestURL}}" }, { "key": "strategy", "value": "{{desktopOrMobile}}" } ] } }, "response": [] } ], "event": [ { "listen": "prerequest", "script": { "type": "text/javascript", "exec": [ "" ] } }, { "listen": "test", "script": { "type": "text/javascript", "exec": [ "" ] } } ], "variable": [ { "key": "firstMeaningfulPaint", "value": "" }, { "key": "firstContentfulPaint", "value": "" }, { "key": "speedIndex", "value": "" }, { "key": "largestContentfulPaint", "value": "" }, { "key": "maxpotentialfid", "value": "" }, { "key": "interactive", "value": "" }, { "key": "totalBlockingTime", "value": "" }, { "key": "_Apica_ReturnValue", "value": "" } ] }