How to use runTests method in Testcafe

Best JavaScript code snippet using testcafe

Run Testcafe automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

constants.js

Source: constants.js Github

copy
1const RUNTESTS_NAME = "RUNTESTS_NAME";
2const RUNTESTS_ENVIRONMENT_ID = "RUNTESTS_ENVIRONMENT_ID";
3const RUNTESTS_ENVIRONMENT_NAME = "RUNTESTS_ENVIRONMENT_NAME";
4const RUNTESTS_TESTING_ENVIRONMENT_ID = "RUNTESTS_TESTING_ENVIRONMENT_ID";
5const RUNTESTS_TESTING_ENVIRONMENT_NAME = "RUNTESTS_TESTING_ENVIRONMENT_NAME";
6const RUNTESTS_USER_ROLE_ID = "RUNTESTS_USER_ROLE_ID";
7const RUNTESTS_USER_ROLE_NAME = "RUNTESTS_USER_ROLE_NAME";
8const RUNTESTS_THREAD = "RUNTESTS_THREAD";
9const RUNTESTS_DATE = "RUNTESTS_DATE";
10const RUNTESTS_TIME = "RUNTESTS_TIME";
11const RUNTESTS_SELECTED_DATA = "RUNTESTS_SELECTED_DATA"
12const IS_BACK_TO_RUNTESTS = "IS_BACK_TO_RUNTESTS"
13
14const EDIT_TESTCASE = "EDIT_TESTCASE"
15// const RUNTESTS_SELECTED_APPLICATIONS_ID = "RUNTESTS_SELECTED_APPLICATIONS_ID"
16// const RUNTESTS_SELECTED_TESTCASES_ID = "RUNTESTS_SELECTED_TESTCASES_ID"
17
18// const RUNTESTS_SELECTED_TESTCASES_NAME = "RUNTESTS_SELECTED_TESTCASES_NAME"
19// const RUNTESTS_SELECTED_APPLICATIONS_NAME = "RUNTESTS_SELECTED_APPLICATIONS_NAME"
20
21const TESTBUCKET_EXECUTION_NAME = "TESTBUCKET_EXECUTION_NAME"
22const TESTBUCKET_TESTING_ENVIRONMENT_ID = "TESTBUCKET_TESTING_ENVIRONMENT_ID"
23const TESTBUCKET_TESTING_ENVIRONMENT_NAME = "TESTBUCKET_TESTING_ENVIRONMENT_NAME"
24const TESTBUCKET_SCHEDULE_DATE = "TESTBUCKET_SCHEDULE_DATE"
25const TESTBUCKET_SCHEDULE_TIME = "TESTBUCKET_SCHEDULE_TIME"
26  
27
28const MESSAGE_ENTER_VALID_EXECUTION_NAME = "Please enter execution name without space"
29const MESSAGE_ENTER_VALID_ENVIRONMENT = "Please enter valid environment"
30const MESSAGE_ENTER_VALID_TESTING_ENVIRONMENT = "Please enter valid Browser"
31const MESSAGE_ENTER_VALID_USERROLE = "Please enter valid user role"
32const MESSAGE_ENTER_VALID_THREAD = "Please enter valid thread"
33const MESSAGE_ENTER_VALID_DATE = "Please enter valid date"
34const MESSAGE_ENTER_VALID_TIME = "Please enter valid time"
35const MESSAGE_ENTER_VALID_TESTCASES = "Please enter valid testcases"
36const MESSAGE_ENTER_VALID_TEST_BUCKET_NAME = "Please enter valid test logical group name"
37
38const QUEUED = "QUEUED"
39const PASSED = "PASSED"
40const FAILED = "FAILED"
41
42
43
Full Screen

test.js

Source: test.js Github

copy
1const expect = require('chai').expect;
2
3const DEFAULT_SELECTOR_TIMEOUT   = 3000;
4const DEFAULT_RUN_OPTIONS        = { selectorTimeout: DEFAULT_SELECTOR_TIMEOUT };
5const DEFAULT_CHROME_RUN_OPTIONS = { only: 'chrome', selectorTimeout: DEFAULT_SELECTOR_TIMEOUT };
6
7describe('[API] Selector', function () {
8    it('Should provide basic properties in HTMLElement snapshots', function () {
9        return runTests('./testcafe-fixtures/selector-test.js', 'HTMLElement snapshot basic properties', DEFAULT_RUN_OPTIONS);
10    });
11
12    it('Should provide basic properties in SVGElement snapshots', function () {
13        return runTests('./testcafe-fixtures/selector-test.js', 'SVGElement snapshot basic properties', DEFAULT_RUN_OPTIONS);
14    });
15
16    it('Should provide input-specific properties in element snapshots', function () {
17        return runTests('./testcafe-fixtures/selector-test.js', 'Input-specific element snapshot properties', DEFAULT_RUN_OPTIONS);
18    });
19
20    it('Should provide `innerText` property in element snapshots', function () {
21        return runTests('./testcafe-fixtures/selector-test.js', '`innerText` element snapshot property', DEFAULT_RUN_OPTIONS);
22    });
23
24    it('Should provide node snapshots for non-element nodes', function () {
25        return runTests('./testcafe-fixtures/selector-test.js', 'Non-element node snapshots', DEFAULT_RUN_OPTIONS);
26    });
27
28    it('Should accept string as constructor argument', function () {
29        return runTests('./testcafe-fixtures/selector-test.js', 'String ctor argument', DEFAULT_RUN_OPTIONS);
30    });
31
32    it('Should wait for element to appear in DOM', function () {
33        return runTests('./testcafe-fixtures/selector-test.js', 'Wait for element in DOM', DEFAULT_RUN_OPTIONS);
34    });
35
36    it('Should return `null` if element does not appear within given time', function () {
37        return runTests('./testcafe-fixtures/selector-test.js', 'Element does not appear', { selectorTimeout: 300 });
38    });
39
40    it('Should check element visibility if option is enabled', function () {
41        return runTests('./testcafe-fixtures/selector-test.js', 'Visibility check', DEFAULT_RUN_OPTIONS);
42    });
43
44    it('Should use timeout specified via property', function () {
45        return runTests('./testcafe-fixtures/selector-test.js', 'Timeout', { selectorTimeout: 4000 });
46    });
47
48    it('Should provide "selector" method in node snapshot', function () {
49        return runTests('./testcafe-fixtures/selector-test.js', 'Snapshot `selector` method', DEFAULT_RUN_OPTIONS);
50    });
51
52    it('Should provide "hasClass" method in node snapshot', function () {
53        return runTests('./testcafe-fixtures/selector-test.js', 'Snapshot `hasClass` method', DEFAULT_RUN_OPTIONS);
54    });
55
56    it('Should provide "addCustomDOMProperties" method in node snapshot', function () {
57        return runTests('./testcafe-fixtures/selector-test.js', 'Selector `addCustomDOMProperties` method', DEFAULT_RUN_OPTIONS);
58    });
59
60    it('Should provide "addCustomMethods" method in node snapshot', function () {
61        return runTests('./testcafe-fixtures/selector-test.js', 'Selector `addCustomMethods` method', DEFAULT_RUN_OPTIONS);
62    });
63
64    it('Selector `addCustomMethods` method - Selector mode', function () {
65        return runTests('./testcafe-fixtures/selector-test.js', 'Selector `addCustomMethods` method - Selector mode', DEFAULT_RUN_OPTIONS);
66    });
67
68    it('Should wait for element to appear on new page', function () {
69        return runTests('./testcafe-fixtures/selector-test.js', 'Element on new page', DEFAULT_RUN_OPTIONS);
70    });
71
72    it('Should provide snapshot property shorthands on selector', function () {
73        return runTests('./testcafe-fixtures/selector-test.js', 'Snapshot properties shorthands on selector', DEFAULT_CHROME_RUN_OPTIONS);
74    });
75
76    it('Should filter results with `nth()` method', function () {
77        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "nth()" method', DEFAULT_CHROME_RUN_OPTIONS);
78    });
79
80    it('Should filter results with `withText()` method', function () {
81        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "withText" method', DEFAULT_CHROME_RUN_OPTIONS);
82    });
83
84    it('Should filter results with `withExactText()` method', function () {
85        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "withExactText" method', DEFAULT_CHROME_RUN_OPTIONS);
86    });
87
88    it('Should filter results with `withAttribute()` method', function () {
89        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "withAttribute" method', DEFAULT_CHROME_RUN_OPTIONS);
90    });
91
92    it('Should filter results with `filter()` method', function () {
93        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "filter" method', DEFAULT_CHROME_RUN_OPTIONS);
94    });
95
96    it('Should filter using combination of filter methods', function () {
97        return runTests('./testcafe-fixtures/selector-test.js', 'Combination of filter methods', DEFAULT_CHROME_RUN_OPTIONS);
98    });
99
100    it('Should provide methods for filtering by visibility for plain structure of HTML elements', function () {
101        return runTests('./testcafe-fixtures/selector-test.js', 'Selector `filterVisible/filterHidden` methods with plain structure', DEFAULT_RUN_OPTIONS);
102    });
103
104    it('Should provide methods for filtering by visibility for hierarchical structure of HTML elements', function () {
105        return runTests('./testcafe-fixtures/selector-test.js', 'Selector `filterVisible/filterHidden` methods with hierarchical structure', DEFAULT_RUN_OPTIONS);
106    });
107
108    it('Should provide .find() method', function () {
109        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "find" method', DEFAULT_RUN_OPTIONS);
110    });
111
112    it('Should provide .parent() method', function () {
113        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "parent" method', DEFAULT_RUN_OPTIONS);
114    });
115
116    it('Should provide .child() method', function () {
117        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "child" method', DEFAULT_RUN_OPTIONS);
118    });
119
120    it('Should provide .sibling() method', function () {
121        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "sibling" method', DEFAULT_RUN_OPTIONS);
122    });
123
124    it('Should provide .nextSibling() method', function () {
125        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "nextSibling" method', DEFAULT_RUN_OPTIONS);
126    });
127
128    it('Should provide .prevSibling() method', function () {
129        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "prevSibling" method', DEFAULT_RUN_OPTIONS);
130    });
131
132    it('Should provide "exists" and "count" properties', function () {
133        return runTests('./testcafe-fixtures/selector-test.js', 'Selector "count" and "exists" properties', DEFAULT_RUN_OPTIONS);
134    });
135
136    it('Should provide dependencies and index argument to selector filter', function () {
137        return runTests('./testcafe-fixtures/selector-test.js', 'Selector filter dependencies and index argument', DEFAULT_CHROME_RUN_OPTIONS);
138    });
139
140    it('Should provide filter origin argument', function () {
141        return runTests('./testcafe-fixtures/selector-test.js', 'Selector filter origin node argument', DEFAULT_CHROME_RUN_OPTIONS);
142    });
143
144    it('Should provide hasAttribute method', function () {
145        return runTests('./testcafe-fixtures/selector-test.js', 'hasAttribute method', DEFAULT_RUN_OPTIONS);
146    });
147
148    describe('Errors', function () {
149        it('Should handle errors in Selector code', function () {
150            return runTests('./testcafe-fixtures/selector-error-test.js', 'Error in code', { shouldFail: true })
151                .catch(function (errs) {
152                    expect(errs[0]).contains('An error occurred in Selector code:');
153                    expect(errs[0]).contains('Error: Hey ya!');
154                    expect(errs[0]).contains('> 11 |    await selector();');
155                });
156        });
157
158        it('Should raise error if non-DOM node returned', function () {
159            return runTests('./testcafe-fixtures/selector-error-test.js', 'Return non-DOM node', { shouldFail: true })
160                .catch(function (errs) {
161                    expect(errs[0]).contains(
162                        'Function that specifies a selector can only return a DOM node, an array of nodes, ' +
163                        'NodeList, HTMLCollection, null or undefined. Use ClientFunction to return other values.'
164                    );
165                    expect(errs[0]).contains("> 15 |    await Selector(() => 'hey')();");
166                });
167        });
168
169        it('Should raise an error if Selector ctor argument is not a function or string', function () {
170            return runTests('./testcafe-fixtures/selector-error-test.js', 'Selector fn is not a function or string', {
171                shouldFail: true,
172                only:       'chrome'
173            }).catch(function (errs) {
174                expect(errs[0].indexOf(
175                    'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +
176                    'node snapshot or a Promise returned by a Selector, but number was passed.'
177                )).eql(0);
178
179                expect(errs[0]).contains('> 19 |    await Selector(123)();');
180            });
181        });
182
183        it("Should raise error if snapshot property shorthand can't find element in DOM tree", function () {
184            return runTests('./testcafe-fixtures/selector-error-test.js', "Snapshot property shorthand - selector doesn't match any element", {
185                shouldFail: true,
186                only:       'chrome'
187            })
188                .catch(function (errs) {
189                    expect(errs[0]).contains(
190                        'Cannot obtain information about the node because the specified selector does not match any node in the DOM tree.' +
191                        '  > | Selector(\'#someUnknownElement\')'
192                    );
193                    expect(errs[0]).contains("> 23 |    await Selector('#someUnknownElement').tagName;");
194                });
195        });
196
197        it("Should raise error if snapshot shorthand method can't find element in DOM tree", function () {
198            return runTests('./testcafe-fixtures/selector-error-test.js', "Snapshot shorthand method - selector doesn't match any element", {
199                shouldFail: true,
200                only:       'chrome'
201            })
202                .catch(function (errs) {
203                    expect(errs[0]).contains(
204                        'Cannot obtain information about the node because the specified selector does not match any node in the DOM tree.' +
205                        '  > | Selector(\'#someUnknownElement\')'
206                    );
207                    expect(errs[0]).contains("> 27 |    await Selector('#someUnknownElement').getStyleProperty('width');");
208                });
209        });
210
211        it('Should raise error if error occurs in selector during shorthand property evaluation', function () {
212            return runTests('./testcafe-fixtures/selector-error-test.js', 'Snapshot property shorthand - selector error', {
213                shouldFail: true,
214                only:       'chrome'
215            })
216                .catch(function (errs) {
217                    expect(errs[0]).contains(
218                        'An error occurred in Selector code:'
219                    );
220                    expect(errs[0]).contains('> 31 |    await Selector(() => [].someUndefMethod()).nodeType;');
221                });
222        });
223
224        it('Should raise error if error occurs in selector during shorthand method evaluation', function () {
225            return runTests('./testcafe-fixtures/selector-error-test.js', 'Snapshot shorthand method - selector error', {
226                shouldFail: true,
227                only:       'chrome'
228            })
229                .catch(function (errs) {
230                    expect(errs[0]).contains(
231                        'An error occurred in Selector code:'
232                    );
233                    expect(errs[0]).contains("> 35 |    await Selector(() => [].someUndefMethod()).hasClass('yo');");
234                });
235        });
236
237        it('Should raise error if error occurs in selector during "count" property evaluation', function () {
238            return runTests('./testcafe-fixtures/selector-error-test.js', 'Snapshot "count" property - selector error', {
239                shouldFail: true,
240                only:       'chrome'
241            })
242                .catch(function (errs) {
243                    expect(errs[0]).contains(
244                        'An error occurred in Selector code:'
245                    );
246
247                    expect(errs[0]).contains('> 39 |    await Selector(() => [].someUndefMethod()).count;');
248                });
249        });
250
251        it('Should raise error if error occurs in selector during "exists" property evaluation', function () {
252            return runTests('./testcafe-fixtures/selector-error-test.js', 'Snapshot "exists" property - selector error', {
253                shouldFail: true,
254                only:       'chrome'
255            })
256                .catch(function (errs) {
257                    expect(errs[0]).contains(
258                        'An error occurred in Selector code:'
259                    );
260                    expect(errs[0]).contains('> 43 |    await Selector(() => [].someUndefMethod()).exists;');
261                });
262        });
263
264        it('Should raise error if custom DOM property throws an error',
265            function () {
266                return runTests('./testcafe-fixtures/selector-error-test.js', 'Add custom DOM properties method - property throws an error', {
267                    shouldFail: true,
268                    only:       'chrome'
269                })
270                    .catch(function (errs) {
271                        expect(errs[0]).contains(
272                            'An error occurred when trying to calculate a custom Selector property "prop":  Error: test'
273                        );
274                        expect(errs[0]).contains('> 53 |    await el();');
275                    });
276            }
277        );
278
279        it('Should raise error if custom method throws an error',
280            function () {
281                return runTests('./testcafe-fixtures/selector-error-test.js', 'Add custom method - method throws an error', {
282                    shouldFail: true,
283                    only:       'chrome'
284                })
285                    .catch(function (errs) {
286                        expect(errs[0]).contains(
287                            'An error occurred in customMethod code:  Error: test'
288                        );
289                        expect(errs[0]).contains('> 63 |    await el.customMethod();');
290                    });
291            }
292        );
293
294        it('Should raise error if custom method throws an error - Selector mode',
295            function () {
296                return runTests('./testcafe-fixtures/selector-error-test.js', 'Add custom method - method throws an error - Selector mode', {
297                    shouldFail: true,
298                    only:       'chrome'
299                })
300                    .catch(function (errs) {
301                        expect(errs[0]).contains(
302                            'An error occurred in Selector code:  Error: test'
303                        );
304                        expect(errs[0]).contains('> 73 |    await el.customMethod()();');
305                    });
306            }
307        );
308    });
309
310    describe('Regression', function () {
311        it("Should execute successfully if derivative selector doesn't have options (GH-716)", function () {
312            return runTests('./testcafe-fixtures/selector-test.js', 'Derivative selector without options', DEFAULT_CHROME_RUN_OPTIONS);
313        });
314
315        it('Should select <option> element by text in Firefox (GH-861)', function () {
316            return runTests('./testcafe-fixtures/selector-test.js', '<option> text selector', {
317                only:            'firefox',
318                selectorTimeout: 3000
319            });
320        });
321    });
322});
323
Full Screen

unit-tests.js

Source: unit-tests.js Github

copy
1var assert = require('assert');
2var shell=require('shelljs');
3var fs = require('fs');
4var common = require('./common');
5const path = require('path');
6
7var INPUT_DIR = common.TOOL_HOME + path.sep + 'tests-unit' + path.sep + 'input';
8var ACTUAL_OUTPUT_DIR = common.TOOL_HOME + path.sep + 'tests-unit' + path.sep + 'output-actual';
9var EXPECTED_OUTPUT_DIR = common.TOOL_HOME + path.sep + 'tests-unit'+ path.sep + 'output-expected';
10
11/**
12 * Perform the following steps for each test case:
13 *   1) run Jalangi
14 *   2) check if the actually generated code matches the expected generated code
15 * Each of these steps is performed by a separate sub-test, and expects that the preceeding
16 * steps have already been performed.
17 *
18 * @param testName
19 */
20
21function runTests(testName){
22    it(testName + '(runJalangi)', function (done) {                                     /* subtest 1: run the Jalangi-instrumented code */
23        this.timeout(10000);
24        common.runJalangi(testName, INPUT_DIR, ACTUAL_OUTPUT_DIR);
25        done();
26    });
27    it(testName + '(checkoutput)', function (done) {                                    /* subtest 2: check that the expected output is computed */
28        common.checkGeneratedCode(testName, ACTUAL_OUTPUT_DIR, EXPECTED_OUTPUT_DIR);
29        done();
30    });
31    it(testName + 'checkGraph', function (done) {
32        common.checkGeneratedGraph(testName, ACTUAL_OUTPUT_DIR, EXPECTED_OUTPUT_DIR);
33        done();
34    });
35}
36
37/**
38 * The test suite. Runs all the sub-tests on all the test cases.
39 */
40describe('unit-tests', function() {
41    // note: need to keep the "describe" here so that the WebStorm IDE will let us re-run individual tests.
42
43    describe('NewPromiseImmediateResolve', function() { runTests('NewPromiseImmediateResolve'); }); // new Promise, resolve
44    describe('NewPromiseImmediateReject', function() { runTests('NewPromiseImmediateReject'); }); // new Promise, reject
45    describe('NewPromiseResolveThen1', function() { runTests('NewPromiseResolveThen1'); }); // new Promise, resolve, then (anon function)
46    describe('NewPromiseResolveThen2', function() { runTests('NewPromiseResolveThen2'); }); // new Promise, resolve, then (named function)
47    describe('PromiseResolveThen', function() { runTests('PromiseResolveThen'); }); // Promise.resolve(), then
48    describe('NewPromiseThenThen', function() { runTests('NewPromiseThenThen'); }); // new Promise, then, then
49    describe('NewPromiseResolveTwoArgThenThen', function() { runTests('NewPromiseResolveTwoArgThenThen'); });  // new Promise, resolve, two-arg then, then
50    describe('NewPromiseRejectTwoArgThenCatch', function() { runTests('NewPromiseRejectTwoArgThenCatch'); });  // new Promise, reject, two-arg then, catch
51    describe('NewPromiseResolveTwoArgThenCatch', function() { runTests('NewPromiseResolveTwoArgThenCatch'); });  // new Promise, resolve, two-arg then, catch (not triggered)
52    describe('NewPromiseRejectTwoArgThenThen', function() { runTests('NewPromiseRejectTwoArgThenThen'); });    // new Promise, reject, two-arg then, then
53    describe('PromiseChain1', function() { runTests('PromiseChain1'); }); // new Promise, resolve, then, then, catch
54    describe('PromiseChain2', function() { runTests('PromiseChain2'); }); // new Promise, resolve, then, then, catch
55    describe('PromiseChain3', function() { runTests('PromiseChain3'); }); // new Promise, resolve, then, then, catch
56    describe('PromiseChain4', function() { runTests('PromiseChain4'); }); // new Promise, resolve, then, catch
57    describe('PromiseChain5', function() { runTests('PromiseChain5'); }); // Promise.resolve, then, skip several thens, catch
58    describe('PromiseChain6', function() { runTests('PromiseChain6'); }); // Promise.resolve, then, skip several thens, catch
59    describe('BypassCatch', function() { runTests('BypassCatch'); }); // Promise.resolve, catch, using default catch onResolve
60    describe('NewPromiseThenImplicitReturns', function() { runTests('NewPromiseThenImplicitReturns'); }); // new Promise, resolve, then (implicit return), then (implicit return)
61    describe('NewPromiseBranchingThens1', function() { runTests('NewPromiseBranchingThens1'); }); // two then reactions on the same promise
62    describe('NewPromiseBranchingThens2', function() { runTests('NewPromiseBranchingThens2'); }); // two then reactions on the same promise
63    describe('NewPromiseBranchingThens3', function() { runTests('NewPromiseBranchingThens3'); }); // two then reactions on the same promise
64    describe('NewPromiseResolveLater1', function() { runTests('NewPromiseResolveLater1'); }); // assign resolve fun to variable, invoke later
65    describe('NewPromiseResolveLater2', function() { runTests('NewPromiseResolveLater2'); }); // assign resolve fun to variable, invoke later
66    describe('NewPromiseResolveAsync', function() { runTests('NewPromiseResolveAsync'); }); // new Promise, resolve asynchronously via setTimeout
67    describe('NewPromiseRejectAsync', function() { runTests('NewPromiseRejectAsync'); }); // new Promise, reject asynchronously via setTimeout
68    describe('LinkedPromises1', function() { runTests('LinkedPromises1'); }); // example of linked promises
69    describe('LinkedPromises2', function() { runTests('LinkedPromises2'); }); // example of linked promises with setTimeOut resolve
70    describe('LinkedPromises3', function() { runTests('LinkedPromises3'); }); // example of linked promises with explicit then onReject
71    describe('LinkedPromises4', function() { runTests('LinkedPromises4'); }); // example of linked promises with default then onReject
72    describe('LinkedPromises5', function() { runTests('LinkedPromises5'); }); // example of linked promises with default then onReject and catch
73    describe('LinkedPromises6', function() { runTests('LinkedPromises6'); }); // example of linked promises with setTimeOut reject
74    describe('LinkedByResolve', function() { runTests('LinkedByResolve'); });
75    describe('LinkedByResolve2', function() { runTests('LinkedByResolve2'); });
76    describe('PromiseReturnObjReject', function() { runTests('PromiseReturnObjReject'); });
77    describe('PromiseReturnObjResolve', function() { runTests('PromiseReturnObjResolve'); });
78    describe('PromiseReturnObjLinking1', function() { runTests('PromiseReturnObjLinking1'); });
79    describe('PromiseReturnObjLinking2', function() { runTests('PromiseReturnObjLinking2'); });
80    describe('PromiseReturnObjChain1', function() { runTests('PromiseReturnObjChain1'); });
81    describe('PromiseReturnObjChain2', function() { runTests('PromiseReturnObjChain2'); });
82    describe('PromiseReturnObjChain3', function() { runTests('PromiseReturnObjChain3'); });
83    describe('PromiseReturnFunReject', function() { runTests('PromiseReturnFunReject'); });
84    describe('PromiseReturnFunResolve', function() { runTests('PromiseReturnFunResolve'); });
85    describe('PromiseReturnFunAsync1', function() { runTests('PromiseReturnFunAsync1'); });
86    describe('PromiseReturnFunAsync2', function() { runTests('PromiseReturnFunAsync2'); });
87    describe('PromiseReturnArrReject', function() { runTests('PromiseReturnArrReject'); });
88    describe('PromiseReturnArrResolve', function() { runTests('PromiseReturnArrResolve'); });
89    describe('PromiseReturnArrCatch1', function() { runTests('PromiseReturnArrCatch1'); });
90    describe('PromiseReturnArrCatch2', function() { runTests('PromiseReturnArrCatch2'); });
91    describe('AllResolve', function() { runTests('AllResolve'); });   // resolved Promise.all()
92    describe('AllResolveAndReject', function() { runTests('AllResolveAndReject'); });   // rejected Promise.all()
93    describe('AllAsyncResolve', function() { runTests('AllAsyncResolve'); });   // Promise.all() asynchronously resolved (most cases)
94    describe('AllAsyncReject', function() { runTests('AllAsyncReject'); });   // Promise.all() asynchronously rejected
95    describe('AllSyncResolve', function() { runTests('AllSyncResolve'); });   // Promise.all() synchronously resolved (only with an empty input array)
96    describe('AllFailFirstBehaviour', function() { runTests('AllFailFirstBehaviour'); });   // Promise.all() immediately rejected after first rejected input
97    describe('AllPendingFulfillment', function() { runTests('AllPendingFulfillment'); });   // Promise.all() pending fulfillment when an argument is never fulfilled (and nothing is rejected)
98    describe('AllRejectedWhilePending', function() { runTests('AllRejectedWhilePending'); });   // Promise.all() rejected (one input promise is never fulfilled)
99    describe('RacePrimitivesOnly', function() { runTests('RacePrimitivesOnly'); });
100    describe('RaceResolve1', function() { runTests('RaceResolve1'); });
101    describe('RaceResolve2', function() { runTests('RaceResolve2'); });
102    describe('RaceReject1', function() { runTests('RaceReject1'); });
103    describe('RaceReject2', function() { runTests('RaceReject2'); });
104    describe('RacePend', function() { runTests('RacePend'); });
105    describe('RaceMultipleReject1', function() { runTests('RaceMultipleReject1'); });
106    describe('RaceMultipleResolve1', function() { runTests('RaceMultipleResolve1'); });
107    describe('MultipleFulfillPrim1', function() { runTests('MultipleFulfillPrim1'); });
108    describe('MultipleFulfillPrim2', function() { runTests('MultipleFulfillPrim2'); });
109    describe('MultipleFulfillFunc1', function() { runTests('MultipleFulfillFunc1'); });
110    describe('MultipleFulfillFunc2', function() { runTests('MultipleFulfillFunc2'); });
111    describe('MultipleFulfillObj1', function() { runTests('MultipleFulfillObj1'); });
112    describe('MultipleFulfillObj2', function() { runTests('MultipleFulfillObj2'); });
113    describe('PromiseBranch0', function() { runTests('PromiseBranch0'); });
114    describe('PromiseBranch', function() { runTests('PromiseBranch'); });
115    describe('PromiseBranch2', function() { runTests('PromiseBranch2'); });
116    describe('PromiseBranch3', function() { runTests('PromiseBranch3'); });
117    describe('PromiseBranch4', function() { runTests('PromiseBranch4'); });
118    describe('PromiseProxyThen', function() { runTests('PromiseProxyThen'); });
119    describe('ReturnNewBluebirdPromise', function() { runTests('ReturnNewBluebirdPromise'); }); // new bluebird Promise
120    describe('ReturnNewBluebirdPromiseThen', function() { runTests('ReturnNewBluebirdPromiseThen'); }); // call then on new bluebird Promise
121    describe('BluebirdPromiseChain', function() { runTests('BluebirdPromiseChain'); });
122    describe('BluebirdPromiseReject', function() { runTests('BluebirdPromiseReject'); });
123    describe('PosterExample', function() { runTests('PosterExample'); }); //git di
124
125    // examples of buggy promise-based programs
126    describe('BugDeadPromise1', function() { runTests('BugDeadPromise1'); }); //
127    describe('BugDeadPromise2', function() { runTests('BugDeadPromise2'); }); //
128    describe('BugDeadPromise3', function() { runTests('BugDeadPromise3'); }); //
129    describe('BugDoubleSettle1', function() { runTests('BugDoubleSettle1'); }); //
130    describe('BugDoubleSettle2', function() { runTests('BugDoubleSettle2'); }); //
131    describe('BugMissingReturn1', function() { runTests('BugMissingReturn1'); }); //
132    describe('BugMissingReturn2', function() { runTests('BugMissingReturn2'); }); //
133    describe('BugMissingReturn3', function() { runTests('BugMissingReturn3'); }); //
134    describe('BugMissingReturn4', function() { runTests('BugMissingReturn4'); }); //
135    describe('BrokenPromiseChain', function() { runTests('BrokenPromiseChain'); }); //
136    describe('BrokenPromiseChain2', function() { runTests('BrokenPromiseChain2'); }); //
137    describe('PromiseCallbackHell', function() { runTests('PromiseCallbackHell'); });
138    describe('MultipleThens1', function() { runTests('MultipleThens1'); }); // new Promise, resolve
139    describe('MultipleThensError1', function() { runTests('MultipleThensError1'); }); // new Promise, resolve
140    describe('MultipleThensError2', function() { runTests('MultipleThensError2'); }); // new Promise, resolve
141    describe('PromisesInLoop1', function() { runTests('PromisesInLoop1'); }); // new Promise, resolve
142    describe('PromisesInLoop2', function() { runTests('PromisesInLoop2'); }); // new Promise, resolve
143    describe('MissingExceptionalReject2', function() { runTests('MissingExceptionalReject2'); }); //
144    describe('MissingExceptionalReject3', function() { runTests('MissingExceptionalReject3'); }); //
145    describe('MissingExceptionalRejectCaughtLater', function() { runTests('MissingExceptionalRejectCaughtLater'); }); //
146    describe('MissingExceptionalRejectCaughtLater2', function() { runTests('MissingExceptionalRejectCaughtLater2'); }); //
147    describe('ExplicitConstructionAntiPattern', function() { runTests('ExplicitConstructionAntiPattern'); });
148
149    // several cases where a non-function argument is passed to "then" or "catch"
150    // rename them to something more appropriate
151    describe('BugOther1', function() { runTests('BugOther1'); }); //
152    describe('BugOther2', function() { runTests('BugOther2'); }); //
153    describe('BugOther3', function() { runTests('BugOther3'); }); //
154    describe('BugOther4', function() { runTests('BugOther4'); }); //
155
156    // bug patterns
157    describe('DeadPromise', function() { runTests('DeadPromise'); }); //
158    describe('MissingResolveOrReject', function() { runTests('MissingResolveOrReject'); }); //
159    describe('MissingExceptionalReject', function() { runTests('MissingExceptionalReject'); }); //
160
161    // create many promises in a loop
162    describe('Loop1', function() { runTests('Loop1'); }); //
163
164    // use the same function as a reaction for multiple promises
165    describe('SharedReaction', function() { runTests('SharedReaction'); }); //
166    describe('SharedReactionFunction', function() { runTests('SharedReactionFunction'); });
167
168    // throwing a promise in a reaction TODO test doesn't exist
169    // describe('ThrowPromise', function() { runTests('ThrowPromise'); }); //
170});
171
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Testcafe on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)