How to use allTests method in wpt

Best JavaScript code snippet using wpt

test-runner.ts

Source:test-runner.ts Github

copy

Full Screen

1/* tslint:disable */2import * as TKUnit from './tk-unit';3import './ui-test';4import { _resetRootView } from 'tns-core-modules/application';5import * as platform from 'tns-core-modules/platform';6import { messageType } from 'tns-core-modules/trace';7import { Button } from 'tns-core-modules/ui/button';8import { Frame, topmost } from 'tns-core-modules/ui/frame';9import { StackLayout } from 'tns-core-modules/ui/layouts/stack-layout';10import { Page } from 'tns-core-modules/ui/page';11import { TextView } from 'tns-core-modules/ui/text-view';12import { ios } from 'tns-core-modules/utils/utils';13Frame.defaultAnimatedNavigation = false;14export function isRunningOnEmulator(): boolean {15 // These checks are not good enough to be added to modules but they keep unit tests green.16 if (platform.device.os === platform.platformNames.android) {17 return android.os.Build.FINGERPRINT.indexOf("generic") > -1 ||18 android.os.Build.HARDWARE.toLowerCase() === "goldfish" ||19 android.os.Build.HARDWARE.toLowerCase() === "donatello" || // VS Emulator20 android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("sdk") > -1 ||21 android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("emulator") > -1; // VS Emulator22 }23 else if (platform.device.os === platform.platformNames.ios) {24 return (__dirname.search("Simulator") > -1);25 }26}27export const allTests = {};28import * as domNodeTest from "./debugger/dom-node-tests";29allTests["DOM-NODE"] = domNodeTest;30import * as profilingTests from "./profiling/profiling-tests";31allTests["PROFILING"] = profilingTests;32import * as platformTests from "./platform/platform-tests";33allTests["PLATFORM"] = platformTests;34import * as fsTests from "./file-system/file-system-tests";35allTests["FILE-SYSTEM"] = fsTests;36// import * as httpTests from "./http/http-tests";37// allTests["HTTP"] = httpTests;38// import * as xhrTests from "./xhr/xhr-tests";39// allTests["XHR"] = xhrTests;40// import * as fetchTests from "./fetch/fetch-tests";41// allTests["FETCH"] = fetchTests;42import * as appSettingsTests from "./application-settings/application-settings-tests";43allTests["APPLICATION-SETTINGS"] = appSettingsTests;44import * as applicationTests from "./application/application-tests";45allTests["APPLICATION"] = applicationTests;46import * as imageSourceTests from "./image-source/image-source-tests";47allTests["IMAGE-SOURCE"] = imageSourceTests;48import * as observableArrayTests from "./data/observable-array-tests";49allTests["OBSERVABLE-ARRAY"] = observableArrayTests;50import * as virtualArrayTests from "./data/virtual-array-tests";51allTests["VIRTUAL-ARRAY"] = virtualArrayTests;52import * as observableTests from "./data/observable-tests";53allTests["OBSERVABLE"] = observableTests;54import * as timerTests from "./timer/timer-tests";55allTests["TIMER"] = timerTests;56import * as colorTests from "./color/color-tests";57allTests["COLOR"] = colorTests;58import * as bindableTests from "./ui/core/bindable/bindable-tests";59allTests["BINDABLE"] = bindableTests;60import * as bindingExpressionTests from "./ui/core/bindable/binding-expressions-tests";61allTests["BINDING-EXPRESSIONS"] = bindingExpressionTests;62import * as xmlParserTests from "./xml-parser-tests/xml-parser-tests";63allTests["XML-PARSER"] = xmlParserTests;64import * as formattedStringTests from "./text/formatted-string-tests";65allTests["FORMATTEDSTRING"] = formattedStringTests;66import * as fileSystemAccessTests from "./file-system-access-tests/file-system-access-tests";67allTests["FILE-SYSTEM-ACCESS"] = fileSystemAccessTests;68import * as qualifierMatcherTests from "./name-resolvers-tests/qualifier-matcher-tests";69allTests["QUALIFIER-MATCHER"] = qualifierMatcherTests;70import * as fileNameResolverTests from "./name-resolvers-tests/file-name-resolver-tests";71allTests["FILE-NAME-RESOLVER"] = fileNameResolverTests;72import * as moduleNameResolverTests from "./name-resolvers-tests/module-name-resolver-tests";73allTests["MODULE-NAME-RESOLVER"] = moduleNameResolverTests;74import * as weakEventsTests from "./ui/core/weak-event-listener/weak-event-listener-tests";75allTests["WEAK-EVENTS"] = weakEventsTests;76import * as traceErrorTests from "./trace/trace-error-tests";77allTests["TRACE-ERROR"] = traceErrorTests;78import * as connectivityTests from "./connectivity/connectivity-tests";79allTests["CONNECTIVITY"] = connectivityTests;80import * as proxyViewContainerTests from "./ui/proxy-view-container/proxy-view-container-tests";81allTests["PROXY-VIEW-CONTAINER"] = proxyViewContainerTests;82import * as scrollViewTests from "./ui/scroll-view/scroll-view-tests";83allTests["SCROLL-VIEW"] = scrollViewTests;84import * as actionBarTests from "./ui/action-bar/action-bar-tests";85allTests["ACTION-BAR"] = actionBarTests;86//TODO: 1 test commented out: test_EventInCodelessFragment87import * as xmlDeclarationTests from "./xml-declaration/xml-declaration-tests";88allTests["XML-DECLARATION"] = xmlDeclarationTests;89import * as dockLayoutTests from "./ui/layouts/dock-layout-tests";90allTests["DOCKLAYOUT"] = dockLayoutTests;91import * as wrapLayoutTests from "./ui/layouts/wrap-layout-tests";92allTests["WRAPLAYOUT"] = wrapLayoutTests;93import * as absoluteLayoutTests from "./ui/layouts/absolute-layout-tests";94allTests["ABSOLUTELAYOUT"] = absoluteLayoutTests;95import * as gridLayoutTests from "./ui/layouts/grid-layout-tests";96allTests["GRIDLAYOUT"] = gridLayoutTests;97import * as stackLayoutTests from "./ui/layouts/stack-layout-tests";98allTests["STACKLAYOUT"] = stackLayoutTests;99import * as flexBoxLayoutTests from "./ui/layouts/flexbox-layout-tests";100allTests["FLEXBOXLAYOUT"] = flexBoxLayoutTests;101import * as safeAreaLayoutTests from "./ui/layouts/safe-area-tests";102import * as safeAreaListViewtTests from "./ui/list-view/list-view-safe-area-tests";103import * as scrollViewSafeAreaTests from "./ui/scroll-view/scroll-view-safe-area-tests";104import * as repeaterSafeAreaTests from "./ui/repeater/repeater-safe-area-tests";105import * as webViewSafeAreaTests from "./ui/web-view/web-view-safe-area-tests";106if (platform.isIOS && ios.MajorVersion > 10) {107 allTests["SAFEAREALAYOUT"] = safeAreaLayoutTests;108 allTests["SAFEAREA-LISTVIEW"] = safeAreaListViewtTests;109 allTests["SAFEAREA-SCROLL-VIEW"] = scrollViewSafeAreaTests;110 allTests["SAFEAREA-REPEATER"] = repeaterSafeAreaTests;111 allTests["SAFEAREA-WEBVIEW"] = webViewSafeAreaTests;112}113import * as stylePropertiesTests from "./ui/styling/style-properties-tests";114allTests["STYLE-PROPERTIES"] = stylePropertiesTests;115import * as frameTests from "./ui/frame/frame-tests";116allTests["FRAME"] = frameTests;117import * as viewTests from "./ui/view/view-tests";118allTests["VIEW"] = viewTests;119import * as viewLayoutChangedEventTests from "./ui/view/view-tests-layout-event";120allTests["VIEW-LAYOUT-EVENT"] = viewLayoutChangedEventTests;121import * as styleTests from "./ui/styling/style-tests";122allTests["STYLE"] = styleTests;123import * as visualStateTests from "./ui/styling/visual-state-tests";124allTests["VISUAL-STATE"] = visualStateTests;125import * as valueSourceTests from "./ui/styling/value-source-tests";126allTests["VALUE-SOURCE"] = valueSourceTests;127import * as borderTests from "./ui/border/border-tests";128allTests["BORDER"] = borderTests;129import * as builderTests from "./ui/builder/builder-tests";130allTests["BUILDER"] = builderTests;131import * as builderFileQualifierTests from "./ui/builder/builder-file-qualifiers-tests";132allTests["BUILDER-QUALIFIERS"] = builderFileQualifierTests;133import * as buttonTests from "./ui/button/button-tests";134allTests["BUTTON"] = buttonTests;135import * as labelTests from "./ui/label/label-tests";136allTests["LABEL"] = labelTests;137import * as bottomNavigationTests from "./ui/bottom-navigation/bottom-navigation-tests";138allTests["BOTTOM-NAVIGATION"] = bottomNavigationTests;139import * as bottomNavigationNavigationTests from "./ui/bottom-navigation/bottom-navigation-navigation-tests";140// TODO: uncomment this141// allTests["BOTTOM-NAVIGATION-NAVIGATION"] = bottomNavigationNavigationTests;142import * as tabsTests from "./ui/tabs/tabs-tests";143allTests["TABS"] = tabsTests;144import * as tabsNavigationTests from "./ui/tabs/tabs-navigation-tests";145allTests["TABS-NAVIGATION"] = tabsNavigationTests;146import * as tabViewTests from "./ui/tab-view/tab-view-tests";147allTests["TAB-VIEW"] = tabViewTests;148import * as tabViewNavigationTests from "./ui/tab-view/tab-view-navigation-tests";149allTests["TAB-VIEW-NAVIGATION"] = tabViewNavigationTests;150import * as imageTests from "./ui/image/image-tests";151allTests["IMAGE"] = imageTests;152import * as imageCacheTests from "./ui/image-cache/image-cache-tests";153allTests["IMAGE-CACHE"] = imageCacheTests;154import * as sliderTests from "./ui/slider/slider-tests";155allTests["SLIDER"] = sliderTests;156import * as switchTests from "./ui/switch/switch-tests";157allTests["SWITCH"] = switchTests;158import * as progressTests from "./ui/progress/progress-tests";159allTests["PROGRESS"] = progressTests;160import * as placeholderTests from "./ui/placeholder/placeholder-tests";161allTests["PLACEHOLDER"] = placeholderTests;162import * as pageTests from "./ui/page/page-tests";163allTests["PAGE"] = pageTests;164import * as listViewTests from "./ui/list-view/list-view-tests";165allTests["LISTVIEW"] = listViewTests;166import * as activityIndicatorTests from "./ui/activity-indicator/activity-indicator-tests";167allTests["ACTIVITY-INDICATOR"] = activityIndicatorTests;168import * as textFieldTests from "./ui/text-field/text-field-tests";169allTests["TEXT-FIELD"] = textFieldTests;170import * as textViewTests from "./ui/text-view/text-view-tests";171allTests["TEXT-VIEW"] = textViewTests;172import * as listPickerTests from "./ui/list-picker/list-picker-tests";173allTests["LIST-PICKER"] = listPickerTests;174import * as datePickerTests from "./ui/date-picker/date-picker-tests";175allTests["DATE-PICKER"] = datePickerTests;176import * as timePickerTests from "./ui/time-picker/time-picker-tests";177allTests["TIME-PICKER"] = timePickerTests;178import * as webViewTests from "./ui/web-view/web-view-tests";179allTests["WEB-VIEW"] = webViewTests;180import * as htmlViewTests from "./ui/html-view/html-view-tests";181allTests["HTML-VIEW"] = htmlViewTests;182import * as repeaterTests from "./ui/repeater/repeater-tests";183allTests["REPEATER"] = repeaterTests;184import * as segmentedBarTests from "./ui/segmented-bar/segmented-bar-tests";185allTests["SEGMENTED-BAR"] = segmentedBarTests;186import * as animationTests from "./ui/animation/animation-tests";187allTests["ANIMATION"] = animationTests;188import * as lifecycle from "./ui/lifecycle/lifecycle-tests";189allTests["LIFECYCLE"] = lifecycle;190import * as cssAnimationTests from "./ui/animation/css-animation-tests";191allTests["CSS-ANIMATION"] = cssAnimationTests;192import * as transitionTests from "./navigation/transition-tests";193allTests["TRANSITIONS"] = transitionTests;194import * as searchBarTests from "./ui/search-bar/search-bar-tests";195allTests["SEARCH-BAR"] = searchBarTests;196import * as navigationTests from "./navigation/navigation-tests";197allTests["NAVIGATION"] = navigationTests;198import * as livesyncTests from "./livesync/livesync-tests";199allTests["LIVESYNC"] = livesyncTests;200import * as tabViewRootTests from "./ui/tab-view/tab-view-root-tests";201allTests["TAB-VIEW-ROOT"] = tabViewRootTests;202import * as bottomNavigationRootTests from "./ui/bottom-navigation/bottom-navigation-root-tests";203allTests["BOTTOM-NAVIGATION-ROOT"] = bottomNavigationRootTests;204// Reset root view didn't work with android tabs205// import * as tabsRootTests from "./ui/tabs/tabs-root-tests";206// allTests["TABS-ROOT"] = tabsRootTests;207import * as resetRootViewTests from "./ui/root-view/reset-root-view-tests";208allTests["RESET-ROOT-VIEW"] = resetRootViewTests;209import * as rootViewTests from "./ui/root-view/root-view-tests";210allTests["ROOT-VIEW"] = rootViewTests;211import * as utilsTests from "./utils/utils-tests";212allTests["UTILS"] = utilsTests;213const testsSuitesWithLongDelay = {214 HTTP: 15 * 1000,215}216const testsWithLongDelay = {217 testLocation: 10000,218 testLocationOnce: 10000,219 testLocationOnceMaximumAge: 10000,220 // web-view-tests221 testLoadExistingUrl: 10000 * 5,222 testLoadLocalFile: 10000 * 5,223 testLoadInvalidUrl: 10000,224 testLoadUpperCaseSrc: 10000 * 5,225 test_SettingImageSrc: 30 * 1000,226 test_ChainingAnimations: 30 * 1000,227 test_AnimatingProperties: 30 * 1000,228 test_AnimateBackgroundColor_FromString: 10 * 1000229}230let startTime;231let running = false;232let testsQueue = new Array<TestInfo>();233function printRunTestStats() {234 let failedTestCount = 0;235 const failedTestInfo = [];236 const slowTests = new Array<string>();237 let allTests = testsQueue.filter(t => t.isTest);238 allTests.forEach((testCase, i, arr) => {239 let testName = testCase.testName;240 if (!testCase.isPassed) {241 failedTestCount++;242 failedTestInfo.push(testName + " FAILED: " + testCase.errorMessage);243 }244 let duration = (testCase.duration / 1000).toFixed(2);245 if (testCase.duration > 500) {246 slowTests.push(`${testName}: ${duration}s`);247 }248 });249 const totalTime = (TKUnit.time() - startTime).toFixed(2);250 let finalMessage = `\n` +251 `=== ALL TESTS COMPLETE ===\n` +252 `${(allTests.length - failedTestCount)} OK, ${failedTestCount} failed\n` +253 `DURATION: ${totalTime} ms\n` +254 `=== END OF TESTS ===\n`;255 TKUnit.write(finalMessage, messageType.info);256 failedTestInfo.forEach((message, i, arr) => {257 TKUnit.write(message, messageType.error);258 finalMessage += "\n" + message;259 });260 // console.log("test-result.xml:\n" + generateTestFile(allTests));261 // DO NOT CHANGE THE FIRST ROW! Used as an indicator for test run pass detection.262 TKUnit.write(`Tests EOF!`, messageType.info);263 showReportPage(finalMessage);264}265function generateTestFile(allTests: TestInfo[]) {266 let failedTestCount = 0;267 const testCases = new Array<string>();268 allTests.forEach((testCase, i, arr) => {269 let testName = testCase.testName;270 let duration = (testCase.duration / 1000).toFixed(2);271 testCases.push(`<testcase classname="${platform.device.os}" name="${testName}" time="${duration}">`)272 if (!testCase.isPassed) {273 failedTestCount++;274 testCases.push(`<failure type="exceptions.AssertionError"><![CDATA[${testCase.errorMessage}]]></failure>`)275 }276 testCases.push(`</testcase>`);277 });278 const totalTime = (TKUnit.time() - startTime).toFixed(2);279 const result = [280 "<testsuites>",281 `<testsuite name="NativeScript Tests" timestamp="${new Date()}" hostname="hostname" time="${totalTime}" errors="0" tests="${allTests.length}" skipped="0" failures="${failedTestCount}">`,282 ...testCases,283 "</testsuite>",284 "</testsuites>"285 ].join("");286 return result;287}288function showReportPage(finalMessage: string) {289 const stack = new StackLayout();290 const btn = new Button();291 btn.text = "Rerun tests";292 btn.on("tap", () => runAll(testsSelector));293 stack.addChild(btn);294 const messageContainer = new TextView();295 messageContainer.editable = messageContainer.autocorrect = false;296 messageContainer.text = finalMessage;297 stack.addChild(messageContainer);298 topmost().navigate({299 create: () => {300 const page = new Page();301 page.content = stack;302 messageContainer.focus();303 page.style.fontSize = 11;304 if (platform.isAndroid) {305 page.on('navigatedTo', () => {306 messageContainer.focus();307 setTimeout(() => messageContainer.dismissSoftInput());308 });309 }310 return page;311 },312 clearHistory: true313 });314}315function startLog(): void {316 let testsName: string = this.name;317 TKUnit.write("START " + testsName + " TESTS.", messageType.info);318 this.start = TKUnit.time();319}320function log(): void {321 let testsName: string = this.name;322 let duration = TKUnit.time() - this.start;323 TKUnit.write(testsName + " COMPLETED for " + duration.toFixed(2) + " BACKSTACK DEPTH: " + topmost().backStack.length, messageType.info);324}325let testsSelector: string326export function runAll(testSelector?: string) {327 testsSelector = testSelector;328 if (running) {329 // TODO: We may schedule pending run requests330 return;331 }332 let singleModuleName, singleTestName;333 if (testSelector) {334 const pair = testSelector.split(".");335 singleModuleName = pair[0];336 if (singleModuleName) {337 if (singleModuleName.length === 0) {338 singleModuleName = undefined;339 } else {340 singleModuleName = singleModuleName.toLowerCase();341 }342 }343 singleTestName = pair[1];344 if (singleTestName) {345 if (singleTestName.length === 0) {346 singleTestName = undefined;347 } else {348 singleTestName = singleTestName.toLowerCase();349 }350 }351 }352 console.log("TESTS: " + singleModuleName ? singleModuleName : "" + " " + singleTestName ? singleTestName : "");353 testsQueue.push(new TestInfo(() => { running = true; startTime = TKUnit.time(); }));354 for (const name in allTests) {355 if (singleModuleName && (singleModuleName !== name.toLowerCase())) {356 continue;357 }358 const testModule = allTests[name];359 const test = testModule.createTestCase ? testModule.createTestCase() : testModule;360 test.name = name;361 testsQueue.push(new TestInfo(startLog, test));362 if (test.setUpModule) {363 testsQueue.push(new TestInfo(test.setUpModule, test));364 }365 for (const testName in test) {366 if (singleTestName && (singleTestName !== testName.toLowerCase())) {367 continue;368 }369 const testFunction = test[testName];370 if ((typeof (testFunction) === "function") && (testName.substring(0, 4) == "test")) {371 if (test.setUp) {372 testsQueue.push(new TestInfo(test.setUp, test));373 }374 const testTimeout = testsWithLongDelay[testName] || testsSuitesWithLongDelay[name];375 testsQueue.push(new TestInfo(testFunction, test, true, name + "." + testName, false, null, testTimeout));376 if (test.tearDown) {377 testsQueue.push(new TestInfo(test.tearDown, test));378 }379 }380 }381 if (test.tearDownModule) {382 testsQueue.push(new TestInfo(test.tearDownModule, test));383 }384 testsQueue.push(new TestInfo(log, test));385 }386 testsQueue.push(new TestInfo(printRunTestStats));387 testsQueue.push(new TestInfo(function () { testsQueue = []; running = false; }));388 TKUnit.runTests(testsQueue, 0);389}390class TestInfo implements TKUnit.TestInfoEntry {391 testFunc: () => void;392 instance: any;393 isTest: boolean;394 testName: string;395 isPassed: boolean;396 errorMessage: string;397 testTimeout: number;398 duration: number;399 constructor(testFunc, testInstance?: any, isTest?, testName?, isPassed?, errorMessage?, testTimeout?, duration?) {400 this.testFunc = testFunc;401 this.instance = testInstance || null;402 this.isTest = isTest || false;403 this.testName = testName || "";404 this.isPassed = isPassed || false;405 this.errorMessage = errorMessage || "";406 this.testTimeout = testTimeout;407 this.duration = duration;408 }...

Full Screen

Full Screen

testRunner.ts

Source:testRunner.ts Github

copy

Full Screen

1/* tslint:disable */2import * as TKUnit from "./TKUnit";3import { messageType } from "trace";4import { topmost, Frame } from "ui/frame";5import { TextView } from "ui/text-view";6import { Button } from "ui/button";7import { StackLayout } from "ui/layouts/stack-layout";8import * as platform from "platform";9import "./ui-test";10import fs = require("file-system");11Frame.defaultAnimatedNavigation = false;12export function isRunningOnEmulator(): boolean {13 // This checks are not good enough to be added to modules but keeps unittests green.14 if (platform.device.os === platform.platformNames.android) {15 return android.os.Build.FINGERPRINT.indexOf("generic") > -1 ||16 android.os.Build.HARDWARE.toLowerCase() === "goldfish" ||17 android.os.Build.HARDWARE.toLowerCase() === "donatello" || // VS Emulator18 android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("sdk") > -1 ||19 android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("emulator") > -1; // VS Emulator20 }21 else if (platform.device.os === platform.platformNames.ios) {22 //return platform.device.model === "iPhone Simulator";23 return (__dirname.search("Simulator") > -1);24 }25}26export var allTests = {};27allTests["PLATFORM"] = require("./platform-tests");28allTests["FILE SYSTEM"] = require("./file-system-tests");29allTests["HTTP"] = require("./http-tests");30allTests["XHR"] = require("./xhr-tests");31allTests["FETCH"] = require("./fetch-tests");32allTests["APPLICATION SETTINGS"] = require("./application-settings-tests");33allTests["APPLICATION"] = require("./application-tests");34allTests["IMAGE SOURCE"] = require("./image-source-tests");35allTests["OBSERVABLE-ARRAY"] = require("./data/observable-array-tests");36allTests["VIRTUAL-ARRAY"] = require("./data/virtual-array-tests");37allTests["OBSERVABLE"] = require("./data/observable-tests");38allTests["TIMER"] = require("./timer-tests");39allTests["COLOR"] = require("./color-tests");40allTests["DEPENDENCY-OBSERVABLE"] = require("./ui/dependency-observable-tests");41allTests["BINDABLE"] = require("./ui/bindable-tests");42allTests["BINDING-EXPRESSIONS"] = require("./ui/binding-expressions-tests");43allTests["XML-PARSER"] = require("./xml-parser-tests/xml-parser-tests");44allTests["FORMATTEDSTRING"] = require("./text/formatted-string-tests");45allTests["FILE-SYSTEM-ACCESS"] = require("./file-system-access-tests/file-system-access-tests");46allTests["FILE-NAME-RESOLVER"] = require("./file-name-resolver-tests/file-name-resolver-tests");47allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests");48allTests["CONNECTIVITY"] = require("./connectivity-tests");49allTests["PROXY-VIEW-CONTAINER"] = require("./ui/proxy-view-container/proxy-view-container-tests")50allTests["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests");51allTests["ACTION-BAR"] = require("./ui/action-bar/action-bar-tests");52allTests["XML-DECLARATION"] = require("./xml-declaration/xml-declaration-tests");53allTests["DOCKLAYOUT"] = require("./ui/layouts/dock-layout-tests");54allTests["WRAPLAYOUT"] = require("./ui/layouts/wrap-layout-tests");55allTests["ABSOLUTELAYOUT"] = require("./ui/layouts/absolute-layout-tests");56allTests["GRIDLAYOUT"] = require("./ui/layouts/grid-layout-tests");57allTests["STACKLAYOUT"] = require("./ui/layouts/stack-layout-tests");58allTests["FLEXBOXLAYOUT"] = require("./ui/layouts/flexbox-layout-tests");59allTests["STYLE-PROPERTIES"] = require("./ui/styling/style-properties-tests");60allTests["FRAME"] = require("./ui/frame/frame-tests");61allTests["VIEW"] = require("./ui/view/view-tests");62allTests["STYLE"] = require("./ui/styling/style-tests");63allTests["VISUAL-STATE"] = require("./ui/styling/visual-state-tests");64allTests["VALUE-SOURCE"] = require("./ui/styling/value-source-tests");65allTests["CSS-SELECTOR-PARSER"] = require("./ui/styling/css-selector-parser");66allTests["CSS-SELECTOR"] = require("./ui/styling/css-selector");67allTests["BUTTON"] = require("./ui/button/button-tests");68allTests["BORDER"] = require("./ui/border/border-tests");69allTests["LABEL"] = require("./ui/label/label-tests");70allTests["TAB-VIEW"] = require("./ui/tab-view/tab-view-tests");71allTests["TAB-VIEW-NAVIGATION"] = require("./ui/tab-view/tab-view-navigation-tests");72allTests["IMAGE"] = require("./ui/image/image-tests");73allTests["SLIDER"] = require("./ui/slider/slider-tests");74allTests["SWITCH"] = require("./ui/switch/switch-tests");75allTests["PROGRESS"] = require("./ui/progress/progress-tests");76allTests["PLACEHOLDER"] = require("./ui/placeholder/placeholder-tests");77allTests["PAGE"] = require("./ui/page/page-tests");78allTests["LISTVIEW"] = require("./ui/list-view/list-view-tests");79allTests["ACTIVITY-INDICATOR"] = require("./ui/activity-indicator/activity-indicator-tests");80allTests["TEXT-FIELD"] = require("./ui/text-field/text-field-tests");81allTests["TEXT-VIEW"] = require("./ui/text-view/text-view-tests");82allTests["LIST-PICKER"] = require("./ui/list-picker/list-picker-tests");83allTests["DATE-PICKER"] = require("./ui/date-picker/date-picker-tests");84allTests["TIME-PICKER"] = require("./ui/time-picker/time-picker-tests");85allTests["WEB-VIEW"] = require("./ui/web-view/web-view-tests");86allTests["HTML-VIEW"] = require("./ui/html-view/html-view-tests");87allTests["REPEATER"] = require("./ui/repeater/repeater-tests");88allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests');89allTests["SEGMENTED-BAR"] = require("./ui/segmented-bar/segmented-bar-tests");90allTests["ANIMATION"] = require("./ui/animation/animation-tests");91allTests["CSS-ANIMATION"] = require("./ui/animation/css-animation-tests");92// Skip transitions on android emulators with API 2393if (!(platform.device.os === platform.platformNames.android && parseInt(platform.device.sdkVersion) === 23 && isRunningOnEmulator())) {94 allTests["TANSITIONS"] = require("./navigation/transition-tests");95}96allTests["NAVIGATION"] = require("./navigation/navigation-tests");97var testsWithLongDelay = {98 test_Transitions: 3 * 60 * 1000,99 testLocation: 10000,100 testLocationOnce: 10000,101 testLocationOnceMaximumAge: 10000,102 //web-view-tests103 testLoadExistingUrl: 10000 * 5,104 testLoadLocalFile: 10000 * 5,105 testLoadInvalidUrl: 10000,106 testLoadUpperCaseSrc: 10000 * 5,107 test_SettingImageSrc: 30 * 1000,108 test_ChainingAnimations: 30 * 1000,109 test_AnimatingProperties: 30 * 1000,110 test_AnimateBackgroundColor_FromString: 10 * 1000111}112var startTime;113var running = false;114var testsQueue = new Array<TestInfo>();115function printRunTestStats() {116 let testFileContent = new Array<string>();117 let testCases = new Array<string>();118 var j;119 var failedTestCount = 0;120 var failedTestInfo = [];121 let allTests = testsQueue.filter(t => t.isTest);122 testFileContent.push("<testsuites>");123 for (j = 0; j < allTests.length; j++) {124 let testName = allTests[j].testName;125 let duration = (allTests[j].duration / 1000).toFixed(2);126 if (!allTests[j].isPassed) {127 failedTestCount++;128 let errorMessage = allTests[j].errorMessage;129 failedTestInfo.push(allTests[j].testName + " FAILED: " + allTests[j].errorMessage);130 testCases.push(`<testcase classname="${platform.device.os}" name="${testName}" time="${duration}"><failure type="exceptions.AssertionError"><![CDATA[${errorMessage}]]></failure></testcase>`);131 } else {132 testCases.push(`<testcase classname="${platform.device.os}" name="${testName}" time="${duration}"></testcase>`);133 }134 }135 var totalTime = (TKUnit.time() - startTime).toFixed(2);136 testFileContent.push(`<testsuite name="NativeScript Tests" timestamp="${new Date()}" hostname="hostname" time="${totalTime}" errors="0" tests="${allTests.length}" skipped="0" failures="${failedTestCount}">`);137 testFileContent = testFileContent.concat(testCases);138 let finalMessage = `\n=== ALL TESTS COMPLETE ===\n` +139 `${(allTests.length - failedTestCount)} OK, ${failedTestCount} failed\n` +140 `DURATION: ${totalTime} ms\n`;141 TKUnit.write(finalMessage, messageType.info);142 for (j = 0; j < failedTestInfo.length; j++) {143 let failureMessage = failedTestInfo[j];144 TKUnit.write(failureMessage, messageType.error);145 finalMessage += "\n" + failureMessage;146 }147 // DO NOT CHANGE THE FIRST ROW! Used as an indicator for test run pass detection.148 TKUnit.write(`Tests EOF!`, messageType.info);149 testFileContent.push("</testsuite>");150 testFileContent.push("</testsuites>");151 let testFilePath: string;152 let testResultsFileName = "test-results.xml";153 if (platform.isIOS) {154 testFilePath = fs.path.join(fs.knownFolders.documents().path, testResultsFileName); 155 } else {156 testFilePath = fs.path.join(android.os.Environment.getExternalStorageDirectory().getAbsolutePath(), "Documents", testResultsFileName);157 }158 let testFile = fs.File.fromPath(testFilePath);159 testFile.writeTextSync(testFileContent.join(""));160 finalMessage += "\n" + "Test results: " + testFilePath;161 let stack = new StackLayout();162 let btn = new Button();163 btn.text = "Rerun tests";164 btn.on("tap", () => runAll(testsSelector));165 stack.addChild(btn);166 let messageContainer = new TextView();167 messageContainer.text = finalMessage;168 stack.addChild(messageContainer);169 topmost().currentPage.content = stack;170}171function startLog(): void {172 let testsName: string = this.name;173 TKUnit.write("START " + testsName + " TESTS.", messageType.info);174 this.start = TKUnit.time();175}176function log(): void {177 let testsName: string = this.name;178 let duration = TKUnit.time() - this.start;179 TKUnit.write(testsName + " COMPLETED for " + duration + " BACKSTACK DEPTH: " + topmost().backStack.length, messageType.info);180}181let testsSelector: string182export var runAll = function (testSelector?: string) {183 testsSelector = testSelector;184 if (running) {185 // TODO: We may schedule pending run requests186 return;187 }188 var singleModuleName, singleTestName;189 if (testSelector) {190 var pair = testSelector.split(".");191 singleModuleName = pair[0];192 if (singleModuleName) {193 if (singleModuleName.length === 0) {194 singleModuleName = undefined;195 } else {196 singleModuleName = singleModuleName.toLowerCase();197 }198 }199 singleTestName = pair[1];200 if (singleTestName) {201 if (singleTestName.length === 0) {202 singleTestName = undefined;203 } else {204 singleTestName = singleTestName.toLowerCase();205 }206 }207 }208 console.log("TESTS: " + singleModuleName + " " + singleTestName);209 var totalSuccess = 0;210 var totalFailed: Array<TKUnit.TestFailure> = [];211 testsQueue.push(new TestInfo(() => { running = true; startTime = TKUnit.time(); }));212 for (var name in allTests) {213 if (singleModuleName && (singleModuleName !== name.toLowerCase())) {214 continue;215 }216 var testModule = allTests[name];217 var test = testModule.createTestCase ? testModule.createTestCase() : testModule;218 test.name = name;219 testsQueue.push(new TestInfo(startLog, test));220 if (test.setUpModule) {221 testsQueue.push(new TestInfo(test.setUpModule, test));222 }223 for (var testName in test) {224 if (singleTestName && (singleTestName !== testName.toLowerCase())) {225 continue;226 }227 var testFunction = test[testName];228 if ((typeof (testFunction) === "function") && (testName.substring(0, 4) == "test")) {229 if (test.setUp) {230 testsQueue.push(new TestInfo(test.setUp, test));231 }232 var testTimeout = testsWithLongDelay[testName];233 testsQueue.push(new TestInfo(testFunction, test, true, name + "." + testName, false, null, testTimeout));234 if (test.tearDown) {235 testsQueue.push(new TestInfo(test.tearDown, test));236 }237 }238 }239 if (test.tearDownModule) {240 testsQueue.push(new TestInfo(test.tearDownModule, test));241 }242 testsQueue.push(new TestInfo(log, test));243 }244 testsQueue.push(new TestInfo(printRunTestStats));245 testsQueue.push(new TestInfo(function () { testsQueue = []; running = false; }));246 TKUnit.runTests(testsQueue, 0);247}248class TestInfo implements TKUnit.TestInfoEntry {249 testFunc: () => void;250 instance: any;251 isTest: boolean;252 testName: string;253 isPassed: boolean;254 errorMessage: string;255 testTimeout: number;256 duration: number;257 constructor(testFunc, testInstance?: any, isTest?, testName?, isPassed?, errorMessage?, testTimeout?, duration?) {258 this.testFunc = testFunc;259 this.instance = testInstance || null;260 this.isTest = isTest || false;261 this.testName = testName || "";262 this.isPassed = isPassed || false;263 this.errorMessage = errorMessage || "";264 this.testTimeout = testTimeout;265 this.duration = duration;266 }...

Full Screen

Full Screen

AllTests.js

Source:AllTests.js Github

copy

Full Screen

1/*23 Version: MPL 1.1/GPL 2.0/LGPL 2.14 5 The contents of this file are subject to the Mozilla Public License Version6 1.1 (the "License"); you may not use this file except in compliance with7 the License. You may obtain a copy of the License at 8 9 http://www.mozilla.org/MPL/ 10 11 Software distributed under the License is distributed on an "AS IS" basis,12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License13 for the specific language governing rights and limitations under the License. 14 15 The Original Code is VEGAS Framework.16 17 The Initial Developer of the Original Code is18 ALCARAZ Marc (aka eKameleon) <ekameleon@gmail.com>.19 Portions created by the Initial Developer are Copyright (C) 2004-201020 the Initial Developer. All Rights Reserved.21 22 Contributor(s) :23 24 Alternatively, the contents of this file may be used under the terms of25 either the GNU General Public License Version 2 or later (the "GPL"), or26 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),27 in which case the provisions of the GPL or the LGPL are applicable instead28 of those above. If you wish to allow use of your version of this file only29 under the terms of either the GPL or the LGPL, and not to allow others to30 use your version of this file under the terms of the MPL, indicate your31 decision by deleting the provisions above and replace them with the notice32 and other provisions required by the LGPL or the GPL. If you do not delete33 the provisions above, a recipient may use your version of this file under34 the terms of any one of the MPL, the GPL or the LGPL.35 36*/3738/////////////////3940getPackage("system.data") ;41getPackage("system.errors") ;42getPackage("system.evaluators") ;43getPackage("system.events") ;44getPackage("system.formatters") ;45getPackage("system.logging") ;46getPackage("system.numeric") ;47getPackage("system.process") ;48getPackage("system.signals") ;4950load("unittests/system/CloneableTest.js") ;51load("unittests/system/ComparableTest.js") ;52load("unittests/system/ComparatorTest.js") ;53load("unittests/system/EnumTest.js") ;54load("unittests/system/EquatableTest.js") ;55load("unittests/system/SerializableTest.js") ;56load("unittests/system/SerializerTest.js") ;57load("unittests/system/SortableTest.js") ;5859load("unittests/system/data/AllTests.js") ;60load("unittests/system/errors/AllTests.js") ;61load("unittests/system/evaluators/AllTests.js") ;62load("unittests/system/events/AllTests.js") ;63load("unittests/system/formatters/AllTests.js") ;64load("unittests/system/ioc/AllTests.js") ;65load("unittests/system/logging/AllTests.js") ;66load("unittests/system/numeric/AllTests.js") ;67load("unittests/system/process/AllTests.js") ;68load("unittests/system/signals/AllTests.js") ;6970/////////////////7172system.AllTests = {} ;7374system.AllTests.suite = function() 75{76 var TestSuite = buRRRn.ASTUce.TestSuite;77 78 var suite = new TestSuite( "system unit tests" );79 80 suite.addTest( new TestSuite( system.CloneableTest ) );81 suite.addTest( new TestSuite( system.ComparableTest ) );82 suite.addTest( new TestSuite( system.ComparatorTest ) );83 suite.addTest( new TestSuite( system.EnumTest ) );84 suite.addTest( new TestSuite( system.EquatableTest ) );85 suite.addTest( new TestSuite( system.SerializableTest ) );86 suite.addTest( new TestSuite( system.SerializerTest ) );87 suite.addTest( new TestSuite( system.SortableTest ) );88 89 suite.addTest( system.data.AllTests.suite() );90 suite.addTest( system.errors.AllTests.suite() );91 suite.addTest( system.evaluators.AllTests.suite() );92 suite.addTest( system.events.AllTests.suite() );93 suite.addTest( system.formatters.AllTests.suite() );94 suite.addTest( system.ioc.AllTests.suite() );95 suite.addTest( system.logging.AllTests.suite() );96 suite.addTest( system.numeric.AllTests.suite() );97 suite.addTest( system.process.AllTests.suite() );98 suite.addTest( system.signals.AllTests.suite() );99 100 return suite; ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');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('webpagetest');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('webpagetest');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('webpagetest');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('webpagetest');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('webpagetest');42var wpt = new WebPageTest('www.webpagetest.org');43 if (err) {44 console.log(err);45 } else {46 console.log(data);47 }48});

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.allTests(function(err, data) {2 if (err) {3 console.log(err);4 } else {5 console.log(data);6 }7});8wpt.getTest(1000, function(err, data) {9 if (err) {10 console.log(err);11 } else {12 console.log(data);13 }14});15wpt.getTestResults(1000, function(err, data) {16 if (err) {17 console.log(err);18 } else {19 console.log(data);20 }21});22wpt.getTestStatus(1000, function(err, data) {23 if (err) {24 console.log(err);25 } else {26 console.log(data);27 }28});29wpt.getTestLocations(function(err, data) {30 if (err) {31 console.log(err);32 } else {33 console.log(data);34 }35});36wpt.getTestLocation('Dulles:Chrome', function(err, data) {37 if (err) {38 console.log(err);39 } else {40 console.log(data);41 }42});43wpt.getTestLocation('Dulles:Chrome', function(err, data) {44 if (err) {45 console.log(err);46 } else {47 console.log(data);48 }49});50wpt.getTestLocation('Dulles:Chrome', function(err, data) {51 if (err) {52 console.log(err);53 } else {54 console.log(data);55 }56});57wpt.getTestLocation('Dulles:Chrome', function(err, data) {58 if (err) {59 console.log(err);60 } else {61 console.log(data);62 }63});

Full Screen

Using AI Code Generation

copy

Full Screen

1var WPT = require('wpt-api');2var wpt = new WPT('API_KEY');3wpt.allTests(function(err, data) {4 if(err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var WPT = require('wpt-api');11var wpt = new WPT('API_KEY');12wpt.getTest('testID', function(err, data) {13 if(err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var WPT = require('wpt-api');20var wpt = new WPT('API_KEY');21wpt.getLocations(function(err, data) {22 if(err) {23 console.log(err);24 } else {25 console.log(data);26 }27});28var WPT = require('wpt-api');29var wpt = new WPT('API_KEY');30wpt.getTesters(function(err, data) {31 if(err) {32 console.log(err);33 } else {34 console.log(data);35 }36});37var WPT = require('wpt-api');38var wpt = new WPT('API_KEY');39wpt.getTesters(function(err, data) {40 if(err) {41 console.log(err);42 } else {43 console.log(data);44 }45});46var WPT = require('wpt-api');47var wpt = new WPT('API_KEY');48wpt.getLocations(function(err, data) {49 if(err) {50 console.log(err);51 } else {52 console.log(data);53 }54});55var WPT = require('wpt-api');56var wpt = new WPT('API_KEY');57wpt.getTesters(function(err, data) {58 if(err) {59 console.log(err);60 } else {61 console.log(data);62 }63});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org');3var options = {4};5client.runTest(testURL, options, function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11});12var request = require('request');13var querystring = require('querystring');14var fs = require('fs');15var util = require('util');16var EventEmitter = require('events').EventEmitter;17var WPT = function(apiKey, server) {18 this.apiKey = apiKey;19 this.server = server;20 this.videoPath = './';21};22util.inherits(WPT, EventEmitter);23WPT.prototype.runTest = function(url, options, callback) {24 var self = this;25 var postData = {26 };27 if (typeof options === 'function') {28 callback = options;29 } else {30 for (var option in options) {31 postData[option] = options[option];32 }33 }34 request.post({35 }, function(err, response, body) {36 if (err) {37 self.emit('error', err);38 callback(err);39 } else {40 var data = JSON.parse(body);41 if (data.statusCode === 200) {42 self.emit('testStart', data);43 self.checkTestStatus(data.data.testId, function(err, result) {44 if (err) {45 self.emit('error', err);46 callback(err);47 } else {48 self.emit('testComplete', result);49 callback(null, result);50 }51 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var allTests = wpt.allTests;3var test = allTests('test');4test.run(function(err, result) {5 if (err) {6 console.log(err);7 } else {8 console.log(result);9 }10});11var wpt = require('wpt');12var test = wpt.test('test');13test.run(function(err, result) {14 if (err) {15 console.log(err);16 } else {17 console.log(result);18 }19});20var wpt = require('wpt');21var test = wpt.test('test');22test.run(function(err, result) {23 if (err) {24 console.log(err);25 } else {26 console.log(result);27 }28});29var wpt = require('wpt');30var test = wpt.test('test');31test.run(function(err, result) {32 if (err) {33 console.log(err);34 } else {35 console.log(result);36 }37});38var wpt = require('wpt');39var test = wpt.test('test');40test.run(function(err, result) {41 if (err) {42 console.log(err);43 } else {44 console.log(result);45 }46});47var wpt = require('wpt');48var test = wpt.test('test');49test.run(function(err, result) {50 if (err) {51 console.log(err);52 } else {53 console.log(result);54 }55});56var wpt = require('wpt');57var test = wpt.test('test');58test.run(function(err, result) {59 if (err) {60 console.log(err);61 } else {62 console.log(result);63 }64});65var wpt = require('wpt');66var test = wpt.test('test');

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 wpt 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