Best Python code snippet using unittest-xml-reporting_python
test.js
Source:test.js
...3const DEFAULT_RUN_OPTIONS = { selectorTimeout: DEFAULT_SELECTOR_TIMEOUT };4const DEFAULT_CHROME_RUN_OPTIONS = { only: 'chrome', selectorTimeout: DEFAULT_SELECTOR_TIMEOUT };5describe('[API] Selector', function () {6 it('Should provide basic properties in HTMLElement snapshots', function () {7 return runTests('./testcafe-fixtures/selector-test.js', 'HTMLElement snapshot basic properties', DEFAULT_RUN_OPTIONS);8 });9 it('Should provide basic properties in SVGElement snapshots', function () {10 return runTests('./testcafe-fixtures/selector-test.js', 'SVGElement snapshot basic properties', DEFAULT_RUN_OPTIONS);11 });12 it('Should provide input-specific properties in element snapshots', function () {13 return runTests('./testcafe-fixtures/selector-test.js', 'Input-specific element snapshot properties', DEFAULT_RUN_OPTIONS);14 });15 it('Should provide `innerText` property in element snapshots', function () {16 return runTests('./testcafe-fixtures/selector-test.js', '`innerText` element snapshot property', DEFAULT_RUN_OPTIONS);17 });18 it('Should provide node snapshots for non-element nodes', function () {19 return runTests('./testcafe-fixtures/selector-test.js', 'Non-element node snapshots', DEFAULT_RUN_OPTIONS);20 });21 it('Should accept string as constructor argument', function () {22 return runTests('./testcafe-fixtures/selector-test.js', 'String ctor argument', DEFAULT_RUN_OPTIONS);23 });24 it('Should wait for element to appear in DOM', function () {25 return runTests('./testcafe-fixtures/selector-test.js', 'Wait for element in DOM', DEFAULT_RUN_OPTIONS);26 });27 it('Should return `null` if element does not appear within given time', function () {28 return runTests('./testcafe-fixtures/selector-test.js', 'Element does not appear', { selectorTimeout: 300 });29 });30 it('Should check element visibility if option is enabled', function () {31 return runTests('./testcafe-fixtures/selector-test.js', 'Visibility check', DEFAULT_RUN_OPTIONS);32 });33 it('Should use timeout specified via property', function () {34 return runTests('./testcafe-fixtures/selector-test.js', 'Timeout', { selectorTimeout: 4000 });35 });36 it('Should provide "selector" method in node snapshot', function () {37 return runTests('./testcafe-fixtures/selector-test.js', 'Snapshot `selector` method', DEFAULT_RUN_OPTIONS);38 });39 it('Should provide "hasClass" method in node snapshot', function () {40 return runTests('./testcafe-fixtures/selector-test.js', 'Snapshot `hasClass` method', DEFAULT_RUN_OPTIONS);41 });42 it('Should provide "addCustomDOMProperties" method in node snapshot', function () {43 return runTests('./testcafe-fixtures/selector-test.js', 'Selector `addCustomDOMProperties` method', DEFAULT_RUN_OPTIONS);44 });45 it('Should provide "addCustomMethods" method in node snapshot', function () {46 return runTests('./testcafe-fixtures/selector-test.js', 'Selector `addCustomMethods` method', DEFAULT_RUN_OPTIONS);47 });48 it('Selector `addCustomMethods` method - Selector mode', function () {49 return runTests('./testcafe-fixtures/selector-test.js', 'Selector `addCustomMethods` method - Selector mode', DEFAULT_RUN_OPTIONS);50 });51 it('Should wait for element to appear on new page', function () {52 return runTests('./testcafe-fixtures/selector-test.js', 'Element on new page', DEFAULT_RUN_OPTIONS);53 });54 it('Should provide snapshot property shorthands on selector', function () {55 return runTests('./testcafe-fixtures/selector-test.js', 'Snapshot properties shorthands on selector', DEFAULT_CHROME_RUN_OPTIONS);56 });57 it('Should filter results with `nth()` method', function () {58 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "nth()" method', DEFAULT_CHROME_RUN_OPTIONS);59 });60 it('Should filter results with `withText()` method', function () {61 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "withText" method', DEFAULT_CHROME_RUN_OPTIONS);62 });63 it('Should filter results with `withExactText()` method', function () {64 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "withExactText" method', DEFAULT_CHROME_RUN_OPTIONS);65 });66 it('Should filter results with `withAttribute()` method', function () {67 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "withAttribute" method', DEFAULT_CHROME_RUN_OPTIONS);68 });69 it('Should filter results with `filter()` method', function () {70 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "filter" method', DEFAULT_CHROME_RUN_OPTIONS);71 });72 it('Should filter using combination of filter methods', function () {73 return runTests('./testcafe-fixtures/selector-test.js', 'Combination of filter methods', DEFAULT_CHROME_RUN_OPTIONS);74 });75 it('Should provide methods for filtering by visibility for plain structure of HTML elements', function () {76 return runTests('./testcafe-fixtures/selector-test.js', 'Selector `filterVisible/filterHidden` methods with plain structure', DEFAULT_RUN_OPTIONS);77 });78 it('Should provide methods for filtering by visibility for hierarchical structure of HTML elements', function () {79 return runTests('./testcafe-fixtures/selector-test.js', 'Selector `filterVisible/filterHidden` methods with hierarchical structure', DEFAULT_RUN_OPTIONS);80 });81 it('Should provide .find() method', function () {82 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "find" method', DEFAULT_RUN_OPTIONS);83 });84 it('Should provide .parent() method', function () {85 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "parent" method', DEFAULT_RUN_OPTIONS);86 });87 it('Should provide .child() method', function () {88 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "child" method', DEFAULT_RUN_OPTIONS);89 });90 it('Should provide .sibling() method', function () {91 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "sibling" method', DEFAULT_RUN_OPTIONS);92 });93 it('Should provide .nextSibling() method', function () {94 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "nextSibling" method', DEFAULT_RUN_OPTIONS);95 });96 it('Should provide .prevSibling() method', function () {97 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "prevSibling" method', DEFAULT_RUN_OPTIONS);98 });99 it('Should provide "exists" and "count" properties', function () {100 return runTests('./testcafe-fixtures/selector-test.js', 'Selector "count" and "exists" properties', DEFAULT_RUN_OPTIONS);101 });102 it('Should provide dependencies and index argument to selector filter', function () {103 return runTests('./testcafe-fixtures/selector-test.js', 'Selector filter dependencies and index argument', DEFAULT_CHROME_RUN_OPTIONS);104 });105 it('Should provide filter origin argument', function () {106 return runTests('./testcafe-fixtures/selector-test.js', 'Selector filter origin node argument', DEFAULT_CHROME_RUN_OPTIONS);107 });108 it('Should provide hasAttribute method', function () {109 return runTests('./testcafe-fixtures/selector-test.js', 'hasAttribute method', DEFAULT_RUN_OPTIONS);110 });111 describe('Errors', function () {112 it('Should handle errors in Selector code', function () {113 return runTests('./testcafe-fixtures/selector-error-test.js', 'Error in code', { shouldFail: true })114 .catch(function (errs) {115 expect(errs[0]).contains('An error occurred in Selector code:');116 expect(errs[0]).contains('Error: Hey ya!');117 expect(errs[0]).contains('> 11 | await selector();');118 });119 });120 it('Should raise error if non-DOM node returned', function () {121 return runTests('./testcafe-fixtures/selector-error-test.js', 'Return non-DOM node', { shouldFail: true })122 .catch(function (errs) {123 expect(errs[0]).contains(124 'Function that specifies a selector can only return a DOM node, an array of nodes, ' +125 'NodeList, HTMLCollection, null or undefined. Use ClientFunction to return other values.'126 );127 expect(errs[0]).contains("> 15 | await Selector(() => 'hey')();");128 });129 });130 it('Should raise an error if Selector ctor argument is not a function or string', function () {131 return runTests('./testcafe-fixtures/selector-error-test.js', 'Selector fn is not a function or string', {132 shouldFail: true,133 only: 'chrome'134 }).catch(function (errs) {135 expect(errs[0].indexOf(136 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +137 'node snapshot or a Promise returned by a Selector, but number was passed.'138 )).eql(0);139 expect(errs[0]).contains('> 19 | await Selector(123)();');140 });141 });142 it("Should raise error if snapshot property shorthand can't find element in DOM tree", function () {143 return runTests('./testcafe-fixtures/selector-error-test.js', "Snapshot property shorthand - selector doesn't match any element", {144 shouldFail: true,145 only: 'chrome'146 })147 .catch(function (errs) {148 expect(errs[0]).contains(149 'Cannot obtain information about the node because the specified selector does not match any node in the DOM tree.' +150 ' > | Selector(\'#someUnknownElement\')'151 );152 expect(errs[0]).contains("> 23 | await Selector('#someUnknownElement').tagName;");153 });154 });155 it("Should raise error if snapshot shorthand method can't find element in DOM tree", function () {156 return runTests('./testcafe-fixtures/selector-error-test.js', "Snapshot shorthand method - selector doesn't match any element", {157 shouldFail: true,158 only: 'chrome'159 })160 .catch(function (errs) {161 expect(errs[0]).contains(162 'Cannot obtain information about the node because the specified selector does not match any node in the DOM tree.' +163 ' > | Selector(\'#someUnknownElement\')'164 );165 expect(errs[0]).contains("> 27 | await Selector('#someUnknownElement').getStyleProperty('width');");166 });167 });168 it('Should raise error if error occurs in selector during shorthand property evaluation', function () {169 return runTests('./testcafe-fixtures/selector-error-test.js', 'Snapshot property shorthand - selector error', {170 shouldFail: true,171 only: 'chrome'172 })173 .catch(function (errs) {174 expect(errs[0]).contains(175 'An error occurred in Selector code:'176 );177 expect(errs[0]).contains('> 31 | await Selector(() => [].someUndefMethod()).nodeType;');178 });179 });180 it('Should raise error if error occurs in selector during shorthand method evaluation', function () {181 return runTests('./testcafe-fixtures/selector-error-test.js', 'Snapshot shorthand method - selector error', {182 shouldFail: true,183 only: 'chrome'184 })185 .catch(function (errs) {186 expect(errs[0]).contains(187 'An error occurred in Selector code:'188 );189 expect(errs[0]).contains("> 35 | await Selector(() => [].someUndefMethod()).hasClass('yo');");190 });191 });192 it('Should raise error if error occurs in selector during "count" property evaluation', function () {193 return runTests('./testcafe-fixtures/selector-error-test.js', 'Snapshot "count" property - selector error', {194 shouldFail: true,195 only: 'chrome'196 })197 .catch(function (errs) {198 expect(errs[0]).contains(199 'An error occurred in Selector code:'200 );201 expect(errs[0]).contains('> 39 | await Selector(() => [].someUndefMethod()).count;');202 });203 });204 it('Should raise error if error occurs in selector during "exists" property evaluation', function () {205 return runTests('./testcafe-fixtures/selector-error-test.js', 'Snapshot "exists" property - selector error', {206 shouldFail: true,207 only: 'chrome'208 })209 .catch(function (errs) {210 expect(errs[0]).contains(211 'An error occurred in Selector code:'212 );213 expect(errs[0]).contains('> 43 | await Selector(() => [].someUndefMethod()).exists;');214 });215 });216 it('Should raise error if custom DOM property throws an error',217 function () {218 return runTests('./testcafe-fixtures/selector-error-test.js', 'Add custom DOM properties method - property throws an error', {219 shouldFail: true,220 only: 'chrome'221 })222 .catch(function (errs) {223 expect(errs[0]).contains(224 'An error occurred when trying to calculate a custom Selector property "prop": Error: test'225 );226 expect(errs[0]).contains('> 53 | await el();');227 });228 }229 );230 it('Should raise error if custom method throws an error',231 function () {232 return runTests('./testcafe-fixtures/selector-error-test.js', 'Add custom method - method throws an error', {233 shouldFail: true,234 only: 'chrome'235 })236 .catch(function (errs) {237 expect(errs[0]).contains(238 'An error occurred in customMethod code: Error: test'239 );240 expect(errs[0]).contains('> 63 | await el.customMethod();');241 });242 }243 );244 it('Should raise error if custom method throws an error - Selector mode',245 function () {246 return runTests('./testcafe-fixtures/selector-error-test.js', 'Add custom method - method throws an error - Selector mode', {247 shouldFail: true,248 only: 'chrome'249 })250 .catch(function (errs) {251 expect(errs[0]).contains(252 'An error occurred in Selector code: Error: test'253 );254 expect(errs[0]).contains('> 73 | await el.customMethod()();');255 });256 }257 );258 });259 describe('Regression', function () {260 it("Should execute successfully if derivative selector doesn't have options (GH-716)", function () {261 return runTests('./testcafe-fixtures/selector-test.js', 'Derivative selector without options', DEFAULT_CHROME_RUN_OPTIONS);262 });263 it('Should select <option> element by text in Firefox (GH-861)', function () {264 return runTests('./testcafe-fixtures/selector-test.js', '<option> text selector', {265 only: 'firefox',266 selectorTimeout: 3000267 });268 });269 });...
unit-tests.js
Source:unit-tests.js
...14 * steps have already been performed.15 *16 * @param testName17 */18function runTests(testName){19 it(testName + '(runJalangi)', function (done) { /* subtest 1: run the Jalangi-instrumented code */20 this.timeout(10000);21 common.runJalangi(testName, INPUT_DIR, ACTUAL_OUTPUT_DIR);22 done();23 });24 it(testName + '(checkoutput)', function (done) { /* subtest 2: check that the expected output is computed */25 common.checkGeneratedCode(testName, ACTUAL_OUTPUT_DIR, EXPECTED_OUTPUT_DIR);26 done();27 });28 it(testName + 'checkGraph', function (done) {29 common.checkGeneratedGraph(testName, ACTUAL_OUTPUT_DIR, EXPECTED_OUTPUT_DIR);30 done();31 });32}33/**34 * The test suite. Runs all the sub-tests on all the test cases.35 */36describe('unit-tests', function() {37 // note: need to keep the "describe" here so that the WebStorm IDE will let us re-run individual tests.38 describe('NewPromiseImmediateResolve', function() { runTests('NewPromiseImmediateResolve'); }); // new Promise, resolve39 describe('NewPromiseImmediateReject', function() { runTests('NewPromiseImmediateReject'); }); // new Promise, reject40 describe('NewPromiseResolveThen1', function() { runTests('NewPromiseResolveThen1'); }); // new Promise, resolve, then (anon function)41 describe('NewPromiseResolveThen2', function() { runTests('NewPromiseResolveThen2'); }); // new Promise, resolve, then (named function)42 describe('PromiseResolveThen', function() { runTests('PromiseResolveThen'); }); // Promise.resolve(), then43 describe('NewPromiseThenThen', function() { runTests('NewPromiseThenThen'); }); // new Promise, then, then44 describe('NewPromiseResolveTwoArgThenThen', function() { runTests('NewPromiseResolveTwoArgThenThen'); }); // new Promise, resolve, two-arg then, then45 describe('NewPromiseRejectTwoArgThenCatch', function() { runTests('NewPromiseRejectTwoArgThenCatch'); }); // new Promise, reject, two-arg then, catch46 describe('NewPromiseResolveTwoArgThenCatch', function() { runTests('NewPromiseResolveTwoArgThenCatch'); }); // new Promise, resolve, two-arg then, catch (not triggered)47 describe('NewPromiseRejectTwoArgThenThen', function() { runTests('NewPromiseRejectTwoArgThenThen'); }); // new Promise, reject, two-arg then, then48 describe('PromiseChain1', function() { runTests('PromiseChain1'); }); // new Promise, resolve, then, then, catch49 describe('PromiseChain2', function() { runTests('PromiseChain2'); }); // new Promise, resolve, then, then, catch50 describe('PromiseChain3', function() { runTests('PromiseChain3'); }); // new Promise, resolve, then, then, catch51 describe('PromiseChain4', function() { runTests('PromiseChain4'); }); // new Promise, resolve, then, catch52 describe('PromiseChain5', function() { runTests('PromiseChain5'); }); // Promise.resolve, then, skip several thens, catch53 describe('PromiseChain6', function() { runTests('PromiseChain6'); }); // Promise.resolve, then, skip several thens, catch54 describe('BypassCatch', function() { runTests('BypassCatch'); }); // Promise.resolve, catch, using default catch onResolve55 describe('NewPromiseThenImplicitReturns', function() { runTests('NewPromiseThenImplicitReturns'); }); // new Promise, resolve, then (implicit return), then (implicit return)56 describe('NewPromiseBranchingThens1', function() { runTests('NewPromiseBranchingThens1'); }); // two then reactions on the same promise57 describe('NewPromiseBranchingThens2', function() { runTests('NewPromiseBranchingThens2'); }); // two then reactions on the same promise58 describe('NewPromiseBranchingThens3', function() { runTests('NewPromiseBranchingThens3'); }); // two then reactions on the same promise59 describe('NewPromiseResolveLater1', function() { runTests('NewPromiseResolveLater1'); }); // assign resolve fun to variable, invoke later60 describe('NewPromiseResolveLater2', function() { runTests('NewPromiseResolveLater2'); }); // assign resolve fun to variable, invoke later61 describe('NewPromiseResolveAsync', function() { runTests('NewPromiseResolveAsync'); }); // new Promise, resolve asynchronously via setTimeout62 describe('NewPromiseRejectAsync', function() { runTests('NewPromiseRejectAsync'); }); // new Promise, reject asynchronously via setTimeout63 describe('LinkedPromises1', function() { runTests('LinkedPromises1'); }); // example of linked promises64 describe('LinkedPromises2', function() { runTests('LinkedPromises2'); }); // example of linked promises with setTimeOut resolve65 describe('LinkedPromises3', function() { runTests('LinkedPromises3'); }); // example of linked promises with explicit then onReject66 describe('LinkedPromises4', function() { runTests('LinkedPromises4'); }); // example of linked promises with default then onReject67 describe('LinkedPromises5', function() { runTests('LinkedPromises5'); }); // example of linked promises with default then onReject and catch68 describe('LinkedPromises6', function() { runTests('LinkedPromises6'); }); // example of linked promises with setTimeOut reject69 describe('LinkedByResolve', function() { runTests('LinkedByResolve'); });70 describe('LinkedByResolve2', function() { runTests('LinkedByResolve2'); });71 describe('PromiseReturnObjReject', function() { runTests('PromiseReturnObjReject'); });72 describe('PromiseReturnObjResolve', function() { runTests('PromiseReturnObjResolve'); });73 describe('PromiseReturnObjLinking1', function() { runTests('PromiseReturnObjLinking1'); });74 describe('PromiseReturnObjLinking2', function() { runTests('PromiseReturnObjLinking2'); });75 describe('PromiseReturnObjChain1', function() { runTests('PromiseReturnObjChain1'); });76 describe('PromiseReturnObjChain2', function() { runTests('PromiseReturnObjChain2'); });77 describe('PromiseReturnObjChain3', function() { runTests('PromiseReturnObjChain3'); });78 describe('PromiseReturnFunReject', function() { runTests('PromiseReturnFunReject'); });79 describe('PromiseReturnFunResolve', function() { runTests('PromiseReturnFunResolve'); });80 describe('PromiseReturnFunAsync1', function() { runTests('PromiseReturnFunAsync1'); });81 describe('PromiseReturnFunAsync2', function() { runTests('PromiseReturnFunAsync2'); });82 describe('PromiseReturnArrReject', function() { runTests('PromiseReturnArrReject'); });83 describe('PromiseReturnArrResolve', function() { runTests('PromiseReturnArrResolve'); });84 describe('PromiseReturnArrCatch1', function() { runTests('PromiseReturnArrCatch1'); });85 describe('PromiseReturnArrCatch2', function() { runTests('PromiseReturnArrCatch2'); });86 describe('AllResolve', function() { runTests('AllResolve'); }); // resolved Promise.all()87 describe('AllResolveAndReject', function() { runTests('AllResolveAndReject'); }); // rejected Promise.all()88 describe('AllAsyncResolve', function() { runTests('AllAsyncResolve'); }); // Promise.all() asynchronously resolved (most cases)89 describe('AllAsyncReject', function() { runTests('AllAsyncReject'); }); // Promise.all() asynchronously rejected90 describe('AllSyncResolve', function() { runTests('AllSyncResolve'); }); // Promise.all() synchronously resolved (only with an empty input array)91 describe('AllFailFirstBehaviour', function() { runTests('AllFailFirstBehaviour'); }); // Promise.all() immediately rejected after first rejected input92 describe('AllPendingFulfillment', function() { runTests('AllPendingFulfillment'); }); // Promise.all() pending fulfillment when an argument is never fulfilled (and nothing is rejected)93 describe('AllRejectedWhilePending', function() { runTests('AllRejectedWhilePending'); }); // Promise.all() rejected (one input promise is never fulfilled)94 describe('RacePrimitivesOnly', function() { runTests('RacePrimitivesOnly'); });95 describe('RaceResolve1', function() { runTests('RaceResolve1'); });96 describe('RaceResolve2', function() { runTests('RaceResolve2'); });97 describe('RaceReject1', function() { runTests('RaceReject1'); });98 describe('RaceReject2', function() { runTests('RaceReject2'); });99 describe('RacePend', function() { runTests('RacePend'); });100 describe('RaceMultipleReject1', function() { runTests('RaceMultipleReject1'); });101 describe('RaceMultipleResolve1', function() { runTests('RaceMultipleResolve1'); });102 describe('MultipleFulfillPrim1', function() { runTests('MultipleFulfillPrim1'); });103 describe('MultipleFulfillPrim2', function() { runTests('MultipleFulfillPrim2'); });104 describe('MultipleFulfillFunc1', function() { runTests('MultipleFulfillFunc1'); });105 describe('MultipleFulfillFunc2', function() { runTests('MultipleFulfillFunc2'); });106 describe('MultipleFulfillObj1', function() { runTests('MultipleFulfillObj1'); });107 describe('MultipleFulfillObj2', function() { runTests('MultipleFulfillObj2'); });108 describe('PromiseBranch0', function() { runTests('PromiseBranch0'); });109 describe('PromiseBranch', function() { runTests('PromiseBranch'); });110 describe('PromiseBranch2', function() { runTests('PromiseBranch2'); });111 describe('PromiseBranch3', function() { runTests('PromiseBranch3'); });112 describe('PromiseBranch4', function() { runTests('PromiseBranch4'); });113 describe('PromiseProxyThen', function() { runTests('PromiseProxyThen'); });114 describe('ReturnNewBluebirdPromise', function() { runTests('ReturnNewBluebirdPromise'); }); // new bluebird Promise115 describe('ReturnNewBluebirdPromiseThen', function() { runTests('ReturnNewBluebirdPromiseThen'); }); // call then on new bluebird Promise116 describe('BluebirdPromiseChain', function() { runTests('BluebirdPromiseChain'); });117 describe('BluebirdPromiseReject', function() { runTests('BluebirdPromiseReject'); });118 describe('PosterExample', function() { runTests('PosterExample'); }); //git di119 // examples of buggy promise-based programs120 describe('BugDeadPromise1', function() { runTests('BugDeadPromise1'); }); //121 describe('BugDeadPromise2', function() { runTests('BugDeadPromise2'); }); //122 describe('BugDeadPromise3', function() { runTests('BugDeadPromise3'); }); //123 describe('BugDoubleSettle1', function() { runTests('BugDoubleSettle1'); }); //124 describe('BugDoubleSettle2', function() { runTests('BugDoubleSettle2'); }); //125 describe('BugMissingReturn1', function() { runTests('BugMissingReturn1'); }); //126 describe('BugMissingReturn2', function() { runTests('BugMissingReturn2'); }); //127 describe('BugMissingReturn3', function() { runTests('BugMissingReturn3'); }); //128 describe('BugMissingReturn4', function() { runTests('BugMissingReturn4'); }); //129 describe('BrokenPromiseChain', function() { runTests('BrokenPromiseChain'); }); //130 describe('BrokenPromiseChain2', function() { runTests('BrokenPromiseChain2'); }); //131 describe('PromiseCallbackHell', function() { runTests('PromiseCallbackHell'); });132 describe('MultipleThens1', function() { runTests('MultipleThens1'); }); // new Promise, resolve133 describe('MultipleThensError1', function() { runTests('MultipleThensError1'); }); // new Promise, resolve134 describe('MultipleThensError2', function() { runTests('MultipleThensError2'); }); // new Promise, resolve135 describe('PromisesInLoop1', function() { runTests('PromisesInLoop1'); }); // new Promise, resolve136 describe('PromisesInLoop2', function() { runTests('PromisesInLoop2'); }); // new Promise, resolve137 describe('MissingExceptionalReject2', function() { runTests('MissingExceptionalReject2'); }); //138 describe('MissingExceptionalReject3', function() { runTests('MissingExceptionalReject3'); }); //139 describe('MissingExceptionalRejectCaughtLater', function() { runTests('MissingExceptionalRejectCaughtLater'); }); //140 describe('MissingExceptionalRejectCaughtLater2', function() { runTests('MissingExceptionalRejectCaughtLater2'); }); //141 describe('ExplicitConstructionAntiPattern', function() { runTests('ExplicitConstructionAntiPattern'); });142 // several cases where a non-function argument is passed to "then" or "catch"143 // rename them to something more appropriate144 describe('BugOther1', function() { runTests('BugOther1'); }); //145 describe('BugOther2', function() { runTests('BugOther2'); }); //146 describe('BugOther3', function() { runTests('BugOther3'); }); //147 describe('BugOther4', function() { runTests('BugOther4'); }); //148 // bug patterns149 describe('DeadPromise', function() { runTests('DeadPromise'); }); //150 describe('MissingResolveOrReject', function() { runTests('MissingResolveOrReject'); }); //151 describe('MissingExceptionalReject', function() { runTests('MissingExceptionalReject'); }); //152 // create many promises in a loop153 describe('Loop1', function() { runTests('Loop1'); }); //154 // use the same function as a reaction for multiple promises155 describe('SharedReaction', function() { runTests('SharedReaction'); }); //156 describe('SharedReactionFunction', function() { runTests('SharedReactionFunction'); });157 // throwing a promise in a reaction TODO test doesn't exist158 // describe('ThrowPromise', function() { runTests('ThrowPromise'); }); //...
runTests.js
Source:runTests.js
1// REGISTER module path FOR PLUGINS2dojo.registerModulePath("plugins","../../plugins"); 3dojo.registerModulePath("t","../../t/unit"); 4// DOJO TEST MODULES5dojo.require("doh.runner");6//dojo.require("dojoc.util.loader");7// Agua TEST MODULES8dojo.require("t.doh.util");9// TESTED MODULES10dojo.require("plugins.dojox.Timer");11var Agua;12var Data;13var data;14var runStatus;15dojo.addOnLoad(function(){16 17doh.registerGroup("plugins.dojox.timing",18[19// TEST attenuate20{21 name: "attenuate",22 timeout : 30000,23 runTest: function() {24 25 console.log("runTests attenuate");26 27 // SET DEFERRED OBJECT28 var deferred = new doh.Deferred({29 timeout: 40000});30 // FLAG31 var flag = false;32 var counter = 0;33 var checkFlag = function (object) {34 counter++;35 console.log("runTests checkFlag " + counter + " onTick: " + new Date().toTimeString());36 return flag;37 };38 // SET TIMER39 var timer = new plugins.dojox.Timer({40 poll: checkFlag,41 interval: 1000,42 attenuate : true43 });44 timer.start();45 46 // TEST AFTER FIRST queryStatus47 setTimeout(function() {48 try {49 console.log("runTests FIRST TIMEOUT");50 console.log("runTests timer.completed IS FALSE");51 doh.assertFalse(timer.completed);52 console.log("runTests flag NOT NULL");53 doh.assertFalse(flag == null);54 console.log("runTests flag NOT TRUE");55 doh.assertFalse(flag == true);56 console.log("runTests timer.polling IS TRUE");57 doh.assertTrue(timer.polling == true);58 59 //deferred.callback(true);60 61 } catch(e) {62 deferred.errback(e);63 }64 }, 5000);65 66 // TEST AFTER FIRST queryStatus67 setTimeout(function() {68 try {69 console.log("runTests SECOND TIMEOUT");70 console.log("runTests timer.completed IS FALSE")71 doh.assertFalse(timer.completed);72 console.log("runTests flag NOT NULL")73 doh.assertFalse(flag == null);74 console.log("runTests flag NOT TRUE")75 doh.assertFalse(flag == true);76 flag = true;77 console.log("runTests flag IS TRUE")78 doh.assertTrue(flag == true);79 console.log("runTests timer.polling IS TRUE");80 doh.assertTrue(timer.polling == true);81 82 //deferred.callback(true);83 84 } catch(e) {}85 }, 10000);86 87 // TEST AFTER FIRST queryStatus88 setTimeout(function() {89 try {90 console.log("runTests THIRD TIMEOUT");91 console.log("runTests flag IS NOT FALSE")92 doh.assertFalse(flag == false);93 console.dir({timer:timer});94 console.log("runTests timer.polling IS FALSE");95 doh.assertTrue(timer.polling == false);96 console.log("runTests counter IS CORRECT");97 doh.assertTrue(counter == 4);98 99 100 deferred.callback(true);101 102 103 } catch(e) {104 deferred.errback(e);105 }106 }, 18000);107 return deferred;108 }109}110//,111//// TEST interval112//{113// name: "interval",114// timeout: 30000,115// runTest: function() {116//117// // FLAG118// var flag = false;119// var counter = 0;120// var checkFlag = function (object) {121// counter++;122// console.log("runTests checkFlag " + counter + " onTick: " + new Date().toTimeString());123// return flag;124// };125//126// // SET TIMER127// var timer = new plugins.dojox.Timer({ poll: checkFlag, interval: 1000 });128// timer.start();129// 130// // SET DEFERRED OBJECT131// var deferred = new doh.Deferred();132// 133// // TEST AFTER FIRST queryStatus134// setTimeout(function() {135// try {136// console.log("runTests FIRST TIMEOUT");137// console.log("runTests timer.completed IS FALSE");138// doh.assertFalse(timer.completed);139// console.log("runTests flag NOT NULL");140// doh.assertFalse(flag == null);141// console.log("runTests flag NOT TRUE");142// doh.assertFalse(flag == true);143// console.log("runTests timer.polling IS TRUE");144// doh.assertTrue(timer.polling == true);145// } catch(e) {146// deferred.errback(e);147// }148// }, 5000);149//150// // TEST AFTER FIRST queryStatus151// setTimeout(function() {152// try {153// console.log("runTests SECOND TIMEOUT");154// console.log("runTests timer.completed IS FALSE")155// doh.assertFalse(timer.completed);156// console.log("runTests flag NOT NULL")157// doh.assertFalse(flag == null);158// console.log("runTests flag NOT TRUE")159// doh.assertFalse(flag == true);160// console.log("runTests ***** SETTING flag TO TRUE *****")161// flag = true;162// console.log("runTests flag IS TRUE")163// doh.assertTrue(flag == true);164// console.log("runTests timer.polling IS TRUE");165// doh.assertTrue(timer.polling == true);166// } catch(e) {167// }168// }, 10000);169//170// // TEST AFTER FIRST queryStatus171// setTimeout(function() {172// try {173// console.log("runTests THIRD TIMEOUT");174// console.log("runTests flag IS NOT FALSE")175// doh.assertFalse(flag == false);176// console.log("runTests timer.polling IS FALSE");177// doh.assertTrue(timer.polling == false);178// console.log("runTests counter IS CORRECT");179// doh.assertTrue(counter == 10);180//181// //deferred.callback(true); 182//183// } catch(e) {184// deferred.errback(e);185// }186// }, 12000);187//188// //deferred.callback(true); 189// return deferred;190// }191//}192//,193//194//// TEST arguments195//{196// name: "arguments",197// timeout: 30000,198// runTest: function() {199// 200// // FLAG201// var flag = false;202// var counter = 0 ;203// var checkFlag = function (timerObject) {204// timerObject.counter++;205// counter++;206// console.log("runTests checkFlag " + timerObject.counter207// + " onTick: (counter: " + counter + "): "208// + new Date().toTimeString());209// doh.assertTrue(timerObject.counter == counter);210// return flag;211// };212// 213// // SET TIMER214// var timer = new plugins.dojox.Timer({ poll: checkFlag, interval: 1000 });215// timer.counter = 0;216// timer.start();217// 218// // SET DEFERRED OBJECT219// var deferred = new doh.Deferred();220// 221// // TEST AFTER FIRST queryStatus222// setTimeout(function() {223// try {224// console.log("runTests FIRST TIMEOUT");225// console.log("runTests timer.completed IS FALSE");226// doh.assertFalse(timer.completed);227// console.log("runTests flag NOT NULL");228// doh.assertFalse(flag == null);229// console.log("runTests flag NOT TRUE");230// doh.assertFalse(flag == true);231// console.log("runTests timer.polling IS TRUE");232// doh.assertTrue(timer.polling == true);233// 234// timer.stop();235// console.log("runTests timer.counter: " + timer.counter);236// console.log("runTests counter: " + counter);237// 238// doh.assertTrue(timer.counter == 4);239// 240// deferred.callback(true); 241// 242// } catch(e) {243// deferred.errback(e);244// }245// }, 5000);246// 247// return deferred;248// }249//}250]); // doh.register251////]}}252//Execute D.O.H. in this remote file.253doh.run();254}); // dojo.addOnLoad...
businessDashboard.visual.js
Source:businessDashboard.visual.js
1import React from 'react';2import businessDashboardTheme from '../BusinessDashboard';3import { runTests as ButtonTests } from '../../../Button/test/Button.visual';4import { runTests as CircularProgressBarTests } from '../../../CircularProgressBar/test/CircularProgressBar.visual';5import { runTests as LinearProgressBarTests } from '../../../LinearProgressBar/test/LinearProgressBar.visual';6import { runTests as HeadingTests } from '../../../Heading/test/Heading.visual';7import { runTests as TextTests } from '../../../Text/test/Text.visual';8import { runTests as TextButtonTests } from '../../../TextButton/test/TextButton.visual';9import { runTests as IconButtonTests } from '../../../IconButton/test/IconButton.visual';10import { runTests as ListItemSelectTests } from '../../../ListItemSelect/test/ListItemSelect.visual';11import { runTests as SidebarTests } from '../../../Sidebar/test/Sidebar.visual';12import { runTests as SidebarBackButtonTests } from '../../../SidebarBackButton/test/SidebarBackButton.visual';13import { runTests as SidebarDividerTests } from '../../../SidebarDivider/test/SidebarDivider.visual';14import { runTests as SidebarHeaderTests } from '../../../SidebarHeader/test/SidebarHeader.visual';15import { runTests as SidebarSectionItemTests } from '../../../SidebarSectionItem/test/SidebarSectionItem.visual';16import { runTests as SidebarSectionTitleTests } from '../../../SidebarSectionTitle/test/SidebarSectionTitle.visual';17import { runTests as CardTests } from '../../../Card/Card.visual';18import { runTests as ListItemActionTests } from '../../../ListItemAction/test/ListItemAction.visual';19import { runTests as CarouselTests } from '../../../Carousel/test/Carousel.visual';20import { runTests as BadgeTests } from '../../../Badge/test/Badge.visual';21import { runTests as LoaderTests } from '../../../Loader/test/Loader.visual';22import { runTests as InputTests } from '../../../Input/test/Input.visual';23import { runTests as EmptyStateTests } from '../../../EmptyState/test/EmptyState.visual';24import { runTests as TrendIndicator } from '../../../TrendIndicator/test/TrendIndicator.visual';25import { runTests as CloseButtonTests } from '../../../CloseButton/test/CloseButton.visual';26import { runTests as TagTests } from '../../../Tag/test/Tag.visual';27import { runTests as CheckboxTests } from '../../../Checkbox/test/Checkbox.visual';28import { runTests as ThumbnailTests } from '../../../Thumbnail/test/Thumbnail.visual';29import { runTests as VerticalTabsItemTests } from '../../../VerticalTabsItem/test/VerticalTabsItem.visual';30import { runTests as CustomModalLayoutTests } from '../../../CustomModalLayout/test/CustomModalLayout.visual';31import { ThemeProvider } from '../../..';32const themeName = 'Business Dashboard';33const testWithTheme = test => {34 return (35 <ThemeProvider theme={businessDashboardTheme()}>36 <>{test}</>37 </ThemeProvider>38 );39};40ButtonTests({ themeName, testWithTheme });41CircularProgressBarTests({ themeName, testWithTheme });42LinearProgressBarTests({ themeName, testWithTheme });43HeadingTests({ themeName, testWithTheme });44TextTests({ themeName, testWithTheme });45TextButtonTests({ themeName, testWithTheme });46IconButtonTests({ themeName, testWithTheme });47CardTests({ themeName, testWithTheme });48CarouselTests({ themeName, testWithTheme });49SidebarTests({ themeName, testWithTheme });50SidebarBackButtonTests({ themeName, testWithTheme });51SidebarDividerTests({ themeName, testWithTheme });52SidebarHeaderTests({ themeName, testWithTheme });53SidebarSectionItemTests({ themeName, testWithTheme });54SidebarSectionTitleTests({ themeName, testWithTheme });55ListItemActionTests({ themeName, testWithTheme });56ListItemSelectTests({ themeName, testWithTheme });57BadgeTests({ themeName, testWithTheme });58LoaderTests({ themeName, testWithTheme });59InputTests({ themeName, testWithTheme });60EmptyStateTests({ themeName, testWithTheme });61TrendIndicator({ themeName, testWithTheme });62CloseButtonTests({ themeName, testWithTheme });63TagTests({ themeName, testWithTheme });64CheckboxTests({ themeName, testWithTheme });65ThumbnailTests({ themeName, testWithTheme });66VerticalTabsItemTests({ themeName, testWithTheme });...
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!!