Best JavaScript code snippet using wpt
location_spec.ts
Source:location_spec.ts
1/**2 * @license3 * Copyright Google Inc. All Rights Reserved.4 *5 * Use of this source code is governed by an MIT-style license that can be6 * found in the LICENSE file at https://angular.io/license7 */8import {describe, it, iit, ddescribe, expect, inject, beforeEach, beforeEachProviders,} from '@angular/core/testing/testing_internal';9import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';10import {Injector, provide, ReflectiveInjector} from '@angular/core';11import {Location, LocationStrategy, APP_BASE_HREF} from '@angular/common';12import {MockLocationStrategy} from '@angular/common/testing/mock_location_strategy';13export function main() {14 describe('Location', () => {15 var locationStrategy: any /** TODO #9100 */, location: any /** TODO #9100 */;16 function makeLocation(17 baseHref: string = '/my/app', provider: any = /*@ts2dart_const*/[]): Location {18 locationStrategy = new MockLocationStrategy();19 locationStrategy.internalBaseHref = baseHref;20 let injector = ReflectiveInjector.resolveAndCreate(21 [Location, {provide: LocationStrategy, useValue: locationStrategy}, provider]);22 return location = injector.get(Location);23 }24 beforeEach(makeLocation);25 it('should not prepend urls with starting slash when an empty URL is provided',26 () => { expect(location.prepareExternalUrl('')).toEqual(locationStrategy.getBaseHref()); });27 it('should not prepend path with an extra slash when a baseHref has a trailing slash', () => {28 let location = makeLocation('/my/slashed/app/');29 expect(location.prepareExternalUrl('/page')).toEqual('/my/slashed/app/page');30 });31 it('should not append urls with leading slash on navigate', () => {32 location.go('/my/app/user/btford');33 expect(locationStrategy.path()).toEqual('/my/app/user/btford');34 });35 it('should normalize urls on popstate',36 inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {37 location.subscribe((ev: any /** TODO #9100 */) => {38 expect(ev['url']).toEqual('/user/btford');39 async.done();40 });41 locationStrategy.simulatePopState('/my/app/user/btford');42 }));43 it('should revert to the previous path when a back() operation is executed', () => {44 var locationStrategy = new MockLocationStrategy();45 var location = new Location(locationStrategy);46 function assertUrl(path: any /** TODO #9100 */) { expect(location.path()).toEqual(path); }47 location.go('/ready');48 assertUrl('/ready');49 location.go('/ready/set');50 assertUrl('/ready/set');51 location.go('/ready/set/go');52 assertUrl('/ready/set/go');53 location.back();54 assertUrl('/ready/set');55 location.back();56 assertUrl('/ready');57 });58 it('should incorporate the provided query values into the location change', () => {59 var locationStrategy = new MockLocationStrategy();60 var location = new Location(locationStrategy);61 location.go('/home', 'key=value');62 expect(location.path()).toEqual('/home?key=value');63 });64 });...
network.test.ts
Source:network.test.ts
1/*---------------------------------------------------------------------------------------------2 * Copyright (c) Microsoft Corporation. All rights reserved.3 * Licensed under the MIT License. See License.txt in the project root for license information.4 *--------------------------------------------------------------------------------------------*/5'use strict';6import * as assert from 'assert';7import URI from 'vs/base/common/uri';8function assertUrl(raw:string, scheme:string, domain:string, port:string, path:string, queryString:string, fragmentId:string): void {9 // check for equivalent behaviour10 var uri = URI.parse(raw);11 assert.equal(uri.scheme, scheme);12 assert.equal(uri.authority, port ? domain + ':' + port : domain);13 assert.equal(uri.path, path);14 assert.equal(uri.query, queryString);15 assert.equal(uri.fragment, fragmentId);16}17suite('Network', () => {18 test('urls', () => {19 assertUrl('http://www.test.com:8000/this/that/theother.html?query=foo#hash',20 'http', 'www.test.com', '8000', '/this/that/theother.html', 'query=foo', 'hash'21 );22 assertUrl('http://www.test.com:8000/this/that/theother.html?query=foo',23 'http', 'www.test.com', '8000', '/this/that/theother.html', 'query=foo', ''24 );25 assertUrl('http://www.test.com:8000/this/that/theother.html#hash',26 'http', 'www.test.com', '8000', '/this/that/theother.html', '', 'hash'27 );28 assertUrl('http://www.test.com:8000/#hash',29 'http', 'www.test.com', '8000', '/', '', 'hash'30 );31 assertUrl('http://www.test.com:8000#hash',32 'http', 'www.test.com', '8000', '', '', 'hash'33 );34 assertUrl('http://www.test.com/#hash',35 'http', 'www.test.com', '', '/', '', 'hash'36 );37 assertUrl('http://www.test.com#hash',38 'http', 'www.test.com', '', '', '', 'hash'39 );40 assertUrl('http://www.test.com:8000/this/that/theother.html',41 'http', 'www.test.com', '8000', '/this/that/theother.html', '', ''42 );43 assertUrl('http://www.test.com:8000/',44 'http', 'www.test.com', '8000', '/', '', ''45 );46 assertUrl('http://www.test.com:8000',47 'http', 'www.test.com', '8000', '', '', ''48 );49 assertUrl('http://www.test.com/',50 'http', 'www.test.com', '', '/', '', ''51 );52 assertUrl('//www.test.com/',53 '', 'www.test.com', '', '/', '', ''54 );55 assertUrl('//www.test.com:8000/this/that/theother.html?query=foo#hash',56 '', 'www.test.com', '8000', '/this/that/theother.html', 'query=foo', 'hash'57 );58 assertUrl('//www.test.com/this/that/theother.html?query=foo#hash',59 '', 'www.test.com', '', '/this/that/theother.html', 'query=foo', 'hash'60 );61 assertUrl('https://www.test.com:8000/this/that/theother.html?query=foo#hash',62 'https', 'www.test.com', '8000', '/this/that/theother.html', 'query=foo', 'hash'63 );64 assertUrl('f12://www.test.com:8000/this/that/theother.html?query=foo#hash',65 'f12', 'www.test.com', '8000', '/this/that/theother.html', 'query=foo', 'hash'66 );67 assertUrl('inmemory://model/0',68 'inmemory', 'model', '', '/0', '', ''69 );70 assertUrl('file:///c/far/boo/file.cs', 'file', '', '', '/c/far/boo/file.cs', '', '');71 });...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.log(err);4 wpt.getTestStatus(data.data.testId, function(err, data) {5 if (err) return console.log(err);6 if (data.statusCode == 200) {7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.log(err);9 console.log(data);10 });11 }12 });13});14### WebPageTest(url, [options])15**url** - The url to the WebPageTest instance (default: www.webpagetest.org)16* **key** - The WebPageTest API key (default: none)17* **host** - The host to use for the WebPageTest API (default: www.webpagetest.org)18* **port** - The port to use for the WebPageTest API (default: 80)19* **secure** - Use HTTPS for the WebPageTest API (default: false)20* **apiVersion** - The version of the WebPageTest API to use (default: 3)21* **pollResults** - Poll the WebPageTest API for test results (default: true)22* **pollInterval** - The interval (in milliseconds) to poll the WebPageTest API for test results (default: 5000)23* **timeout** - The timeout (in milliseconds) to wait for the test to complete (default: 600000)24* **location** - The location to run the test from (default: none)25* **connectivity** - The connectivity to use for the test (default: none)26* **firstViewOnly** - Only test the first view of the page (default: false)27* **runs** - The number of runs to test (default: 1)28* **private** - Make the test private (default: false)29* **video** - Capture a video of the test (default: false)30* **timeline** - Capture a timeline of the test (default: false)31* **netlog** - Capture a network log of the test (default: false)
Using AI Code Generation
1var wpt = require('wpt-api');2var options = {3};4wpt.assertURL(options, function(err, data) {5 if (err) {6 console.log('Error: ' + err);7 } else {8 console.log('Test ID: ' + data.data.testId);9 console.log('Test Status: ' + data.data.statusText);10 }11});12var wpt = require('wpt-api');13var options = {14};15wpt.testStatus(options, function(err, data) {16 if (err) {17 console.log('Error: ' + err);18 } else {19 console.log('Test Status: ' + data.statusText);20 }21});22var wpt = require('wpt-api');23var options = {24};25wpt.testResults(options, function(err, data) {26 if (err) {27 console.log('Error: ' + err);28 } else {29 console.log('Test Status: ' + data.statusText);30 }31});32[MIT](LICENSE)
Using AI Code Generation
1const wpt = require('wpt-api');2const wptApi = new wpt(process.env.WPT_KEY);3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9The full API documentation can be found [here](
Using AI Code Generation
1var wpt = require('./wpt.js');2var assert = require('assert');3var wpt = new wpt('API_KEY');4wpt.assertURL(url, 'assertURL', function(err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data.statusCode);9 console.log(data.statusText);10 console.log(data.data);11 }12});13var wpt = require('./wpt.js');14var assert = require('assert');15var wpt = new wpt('API_KEY');16wpt.getLocations('getLocations', function(err, data) {17 if (err) {18 console.log(err);19 } else {20 console.log(data.statusCode);21 console.log(data.statusText);22 console.log(data.data);23 }24});25var wpt = require('./wpt.js');26var assert = require('assert');27var wpt = new wpt('API_KEY');28wpt.getTesters('getTesters', function(err, data) {29 if (err) {30 console.log(err);31 } else {32 console.log(data.statusCode);33 console.log(data.statusText);34 console.log(data.data);35 }36});37var wpt = require('./wpt.js');38var assert = require('assert');39var wpt = new wpt('API_KEY');40wpt.getLocations('getLocations', function(err, data) {41 if (err) {42 console.log(err);43 } else {44 console.log(data.statusCode);45 console.log(data.statusText);46 console.log(data.data);47 }48});49var wpt = require('./wpt.js');
Using AI Code Generation
1const wpt = require('./wpt-api.js');2const assert = require('assert');3var testKey = 'A.1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6Q7R8S9T0U1V2W3X4Y5Z6';4var testLocation = 'Dulles:Chrome';5var testConnectivity = 'Cable';6var testScript = 'testScript.js';7var testTimeout = 1000;8var testRuns = 1;9var testPollResults = 1;10var testPollResultsInterval = 1;11var testVideo = true;12var testVideoCapture = true;13var testVideoParams = 'testVideoParams';14var testVideoUploadOnCompletion = true;15var testVideoUploadSecret = 'testVideoUploadSecret';16var testFirstViewOnly = true;17var testRepeatView = true;18var testPrivate = true;19var testBlock = true;20var testLabel = 'testLabel';21var testPriority = 1;22var testWeb10 = true;23var testTcpDump = true;24var testSplice = true;25var testSpliceUser = 'testSpliceUser';26var testSplicePassword = 'testSplicePassword';27var testSpliceCheckRate = 1;28var testSpliceResultFormat = 'testSpliceResultFormat';29var testSpliceResultUrl = 'testSpliceResultUrl';30var testSpliceResultToken = 'testSpliceResultToken';31var testSpliceResultFilename = 'testSpliceResultFilename';32var testSpliceCustomHeaderName = 'testSpliceCustomHeaderName';33var testSpliceCustomHeaderValue = 'testSpliceCustomHeaderValue';34var testSpliceCustomHeaderName2 = 'testSpliceCustomHeaderName2';35var testSpliceCustomHeaderValue2 = 'testSpliceCustomHeaderValue2';36var testSpliceCustomHeaderName3 = 'testSpliceCustomHeaderName3';37var testSpliceCustomHeaderValue3 = 'testSpliceCustomHeaderValue3';38var testSpliceCustomHeaderName4 = 'testSpliceCustomHeaderName4';39var testSpliceCustomHeaderValue4 = 'testSpliceCustomHeaderValue4';40var testSpliceCustomHeaderName5 = 'testSpliceCustomHeaderName5';
Using AI Code Generation
1var wpt = require('./wpt.js');2wptObj.assertURL(url, function(err, data){3 if(err){4 console.log(err);5 }6 else{7 console.log(data);8 }9});10 [MIT](LICENSE)
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!!