How to use assertAPIError method in Testcafe

Best JavaScript code snippet using testcafe

api-test.js

Source:api-test.js Github

copy

Full Screen

...18 .then(function () {19 throw new Error('Promise rejection expected');20 })21 .catch(function (err) {22 assertAPIError(err, {23 stackTop: testfile,24 message: 'Cannot prepare tests due to an error.\n\n' +25 'The fixture name is expected to be a string, but it was object.',26 callsite: ' 2 |// (to treat a file as a test, it requires at least one fixture definition\n' +27 ' 3 |// with the string argument).\n' +28 ' 4 |\n' +29 ' 5 |fixture `Yo`;\n' +30 ' 6 |\n' +31 ' > 7 |fixture({ answer: 42 });\n' +32 ' 8 |\n' +33 " 9 |test('Test', () => {\n" +34 " 10 | return 'yo';\n" +35 ' 11 |});\n' +36 ' 12 |'37 });38 });39 });40 it('Should raise an error if fixture page is not a string', function () {41 const testfile = resolve('test/server/data/test-suites/fixture-page-is-not-a-string/testfile.js');42 return compile(testfile)43 .then(function () {44 throw new Error('Promise rejection expected');45 })46 .catch(function (err) {47 assertAPIError(err, {48 stackTop: testfile,49 message: 'Cannot prepare tests due to an error.\n\n' +50 'The page URL is expected to be a string, but it was object.',51 callsite: ' 1 |fixture `Yo`\n' +52 ' > 2 | .page({ answer: 42 });\n' +53 ' 3 |\n' +54 " 4 |test('Test', () => {\n" +55 " 5 | return 'yo';\n" +56 ' 6 |});\n' +57 ' 7 |'58 });59 });60 });61 it('Should raise an error if beforeEach is not a function', function () {62 const testfile = resolve('test/server/data/test-suites/before-each-is-not-a-function/testfile.js');63 return compile(testfile)64 .then(function () {65 throw new Error('Promise rejection expected');66 })67 .catch(function (err) {68 assertAPIError(err, {69 stackTop: testfile,70 message: 'Cannot prepare tests due to an error.\n\n' +71 'fixture.beforeEach hook is expected to be a function, but it was string.',72 callsite: ' 1 |fixture `beforeEach is not a function`\n' +73 " > 2 | .beforeEach('yo');\n" +74 ' 3 |\n' +75 " 4 |test('Some test', () => {\n" +76 ' 5 |\n' +77 ' 6 |});\n' +78 ' 7 |'79 });80 });81 });82 it('Should raise an error if afterEach is not a function', function () {83 const testfile = resolve('test/server/data/test-suites/after-each-is-not-a-function/testfile.js');84 return compile(testfile)85 .then(function () {86 throw new Error('Promise rejection expected');87 })88 .catch(function (err) {89 assertAPIError(err, {90 stackTop: testfile,91 message: 'Cannot prepare tests due to an error.\n\n' +92 'fixture.afterEach hook is expected to be a function, but it was string.',93 callsite: ' 1 |fixture `afterEach is not a function`\n' +94 " > 2 | .afterEach('yo');\n" +95 ' 3 |\n' +96 " 4 |test('Some test', () => {\n" +97 ' 5 |\n' +98 ' 6 |});\n' +99 ' 7 |'100 });101 });102 });103 it('Should raise an error if fixture.before is not a function', function () {104 const testfile = resolve('test/server/data/test-suites/fixture-before-is-not-a-function/testfile.js');105 return compile(testfile)106 .then(function () {107 throw new Error('Promise rejection expected');108 })109 .catch(function (err) {110 assertAPIError(err, {111 stackTop: testfile,112 message: 'Cannot prepare tests due to an error.\n\n' +113 'fixture.before hook is expected to be a function, but it was string.',114 callsite: ' 1 |fixture `before is not a function`\n' +115 " > 2 | .before('yo');\n" +116 ' 3 |\n' +117 " 4 |test('Some test', () => {\n" +118 ' 5 |\n' +119 ' 6 |});\n' +120 ' 7 |'121 });122 });123 });124 it('Should raise an error if fixture.after is not a function', function () {125 const testfile = resolve('test/server/data/test-suites/fixture-after-is-not-a-function/testfile.js');126 return compile(testfile)127 .then(function () {128 throw new Error('Promise rejection expected');129 })130 .catch(function (err) {131 assertAPIError(err, {132 stackTop: testfile,133 message: 'Cannot prepare tests due to an error.\n\n' +134 'fixture.after hook is expected to be a function, but it was string.',135 callsite: ' 1 |fixture `after is not a function`\n' +136 " > 2 | .after('yo');\n" +137 ' 3 |\n' +138 " 4 |test('Some test', () => {\n" +139 ' 5 |\n' +140 ' 6 |});\n' +141 ' 7 |'142 });143 });144 });145 it('Should raise an error if httpAuth takes a wrong argument', function () {146 const credentialsInNotObject = resolve('test/server/data/test-suites/http-auth/credentials-is-not-an-object.js');147 const passIsNotString = resolve('test/server/data/test-suites/http-auth/password-is-not-a-string.js');148 const usernameIsNotDefined = resolve('test/server/data/test-suites/http-auth/username-is-not-defined.js');149 return compile(credentialsInNotObject)150 .then(function () {151 throw new Error('Promise rejection expected');152 })153 .catch(function (err) {154 assertAPIError(err, {155 stackTop: credentialsInNotObject,156 message: 'Cannot prepare tests due to an error.\n\n' +157 'credentials is expected to be a non-null object, but it was string.',158 callsite: ' 1 |fixture `Credentials is not an object`\n' +159 " > 2 | .httpAuth('');\n" +160 ' 3 |\n' +161 " 4 |test('Some test', () => {\n" +162 ' 5 |\n' +163 ' 6 |});\n' +164 ' 7 |'165 });166 return compile(passIsNotString);167 })168 .then(function () {169 throw new Error('Promise rejection expected');170 })171 .catch(function (err) {172 assertAPIError(err, {173 stackTop: passIsNotString,174 message: 'Cannot prepare tests due to an error.\n\n' +175 'credentials.password is expected to be a string, but it was object.',176 callsite: ' 1 |fixture `Password is not a string`\n' +177 ' > 2 | .httpAuth({ username: \'username\', password: {} });\n' +178 ' 3 |\n' +179 " 4 |test('Some test', () => {\n" +180 ' 5 |\n' +181 ' 6 |});\n' +182 ' 7 |'183 });184 return compile(usernameIsNotDefined);185 })186 .then(function () {187 throw new Error('Promise rejection expected');188 })189 .catch(function (err) {190 assertAPIError(err, {191 stackTop: usernameIsNotDefined,192 message: 'Cannot prepare tests due to an error.\n\n' +193 'credentials.username is expected to be a string, but it was undefined.',194 callsite: ' 1 |fixture `Username is not defined`\n' +195 " > 2 | .httpAuth({ password: 'password' });\n" +196 ' 3 |\n' +197 " 4 |test('Some test', () => {\n" +198 ' 5 |\n' +199 ' 6 |});\n' +200 ' 7 |'201 });202 });203 });204 it('Should raise an error if requestHooks takes a wrong argument', function () {205 const fixtureHookHasWrongType = resolve('test/server/data/test-suites/request-hooks/fixture-hook-has-wrong-type.js');206 return compile(fixtureHookHasWrongType)207 .then(() => {208 throw new Error('Promise rejection expected');209 })210 .catch(err => {211 assertAPIError(err, {212 stackTop: fixtureHookHasWrongType,213 message: 'Cannot prepare tests due to an error.\n\n' +214 'Hook is expected to be a RequestHook subclass, but it was string.',215 callsite: ' 1 |fixture `RequestHook is undefined`\n' +216 ' > 2 | .requestHooks(\'string\');\n' +217 ' 3 |\n' +218 ' 4 |test(\'test\', async t => {\n' +219 ' 5 |});\n' +220 ' 6 |'221 });222 });223 });224 it('Should collect meta data', function () {225 return compile('test/server/data/test-suites/meta/testfile.js')226 .then(function (compiled) {227 expect(compiled.tests[0].fixture.meta.metaField1).eql('fixtureMetaValue1');228 expect(compiled.tests[0].fixture.meta.metaField2).eql('fixtureMetaUpdatedValue2');229 expect(compiled.tests[0].fixture.meta.metaField3).eql('fixtureMetaValue3');230 expect(compiled.tests[1].fixture.meta.emptyField).eql(void 0);231 });232 });233 it('Should raise an error if fixture.meta is undefined', function () {234 const file = resolve('test/server/data/test-suites/meta/incorrect-fixture-meta.js');235 return compile(file)236 .then(function () {237 throw new Error('Promise rejection expected');238 })239 .catch(function (err) {240 assertAPIError(err, {241 stackTop: file,242 message: 'Cannot prepare tests due to an error.\n\n' +243 'fixture.meta is expected to be a string or a non-null object, but it was undefined.',244 callsite: ' 1 |fixture(\'Fixture1\')\n' +245 ' 2 | .page(\'http://example.com\')\n' +246 ' > 3 | .meta();\n' +247 ' 4 |\n' +248 ' 5 |test\n' +249 ' 6 | (\'Fixture1Test1\', async () => {\n' +250 ' 7 | // do nothing\n' +251 ' 8 | });'252 });253 });254 });255 });256 describe('test', function () {257 it('Should raise an error if test name is not a string', function () {258 const testfile = resolve('test/server/data/test-suites/test-name-is-not-a-string/testfile.js');259 return compile(testfile)260 .then(function () {261 throw new Error('Promise rejection expected');262 })263 .catch(function (err) {264 assertAPIError(err, {265 stackTop: testfile,266 message: 'Cannot prepare tests due to an error.\n\n' +267 'The test name is expected to be a string, but it was number.',268 callsite: ' 4 |// (to treat a file as a test, it requires at least one fixture definition\n' +269 ' 5 |// with the string argument).\n' +270 " 6 |test('TheAnswer', () => {\n 7 |});\n" +271 ' 8 |\n' +272 ' > 9 |test(42, () => {\n' +273 ' 10 |});\n' +274 ' 11 |'275 });276 });277 });278 it('Should raise an error if test body is not a function', function () {279 const testfile = resolve('test/server/data/test-suites/test-body-is-not-a-function/testfile.js');280 return compile(testfile)281 .then(function () {282 throw new Error('Promise rejection expected');283 })284 .catch(function (err) {285 assertAPIError(err, {286 stackTop: testfile,287 message: 'Cannot prepare tests due to an error.\n\n' +288 'The test body is expected to be a function, but it was string.',289 callsite: ' 1 |fixture `Test body is not a function`;\n' +290 ' 2 |\n' +291 " > 3 |test('Test', 'Yo');\n" +292 ' 4 |'293 });294 });295 });296 it('Should raise an error if test.before is not a function', function () {297 const testfile = resolve('test/server/data/test-suites/test-before-is-not-a-function/testfile.js');298 return compile(testfile)299 .then(function () {300 throw new Error('Promise rejection expected');301 })302 .catch(function (err) {303 assertAPIError(err, {304 stackTop: testfile,305 message: 'Cannot prepare tests due to an error.\n\n' +306 'test.before hook is expected to be a function, but it was number.',307 callsite: ' 1 |fixture `Fixture`;\n' +308 ' 2 |\n' +309 " > 3 |test.before(123)('Some test', () => {\n" +310 ' 4 |\n' +311 ' 5 |});\n' +312 ' 6 |'313 });314 });315 });316 it('Should raise an error if test.after is not a function', function () {317 const testfile = resolve('test/server/data/test-suites/test-after-is-not-a-function/testfile.js');318 return compile(testfile)319 .then(function () {320 throw new Error('Promise rejection expected');321 })322 .catch(function (err) {323 assertAPIError(err, {324 stackTop: testfile,325 message: 'Cannot prepare tests due to an error.\n\n' +326 'test.after hook is expected to be a function, but it was number.',327 callsite: ' 1 |fixture `Fixture`;\n' +328 ' 2 |\n' +329 " > 3 |test.after(123)('Some test', () => {\n" +330 ' 4 |\n' +331 ' 5 |});\n' +332 ' 6 |'333 });334 });335 });336 it('Should raise an error if requestHooks takes a wrong argument', function () {337 const testHookArrayContainsNotRequestHookInheritor = resolve('test/server/data/test-suites/request-hooks/test-hook-array-contains-not-request-hook-inheritor.js');338 return compile(testHookArrayContainsNotRequestHookInheritor)339 .then(() => {340 throw new Error('Promise rejection expected');341 })342 .catch(err => {343 assertAPIError(err, {344 stackTop: testHookArrayContainsNotRequestHookInheritor,345 message: 'Cannot prepare tests due to an error.\n\n' +346 'Hook is expected to be a RequestHook subclass, but it was number.',347 callsite: " 1 |import { RequestMock } from 'testcafe';\n" +348 ' 2 |\n' +349 ' 3 |fixture `Hook array contains not RequestHook inheritor`;\n' +350 ' 4 |\n' +351 " > 5 |test.requestHooks([RequestMock(), 1])('test', async t => {\n" +352 ' 6 |});\n' +353 ' 7 |\n'354 });355 });356 });357 it('Should clone request hooks from fixture to test', () => {358 const cloneHooksFromFixtureToTest = resolve('test/server/data/test-suites/request-hooks/clone-hooks-from-fixture-to-test.js');359 return compile(cloneHooksFromFixtureToTest)360 .then(compiledData => {361 const fixture = compiledData.fixtures[0];362 const test = compiledData.tests[0];363 expect(fixture.requestHooks.length).eql(2);364 expect(test.requestHooks.length).eql(3);365 });366 });367 it('Should not clone the same request hook from fixture to test twice', () => {368 const shouldNotCloneSameRequestHookFromFixtureToTest = resolve('test/server/data/test-suites/request-hooks/should-not-clone-same-request-hook-from-fixture-to-test.js');369 return compile(shouldNotCloneSameRequestHookFromFixtureToTest)370 .then(compiledData => {371 const fixture = compiledData.fixtures[0];372 const test = compiledData.tests[0];373 expect(fixture.requestHooks.length).eql(2);374 expect(test.requestHooks.length).eql(3);375 });376 });377 it('Should collect meta data', function () {378 return compile('test/server/data/test-suites/meta/testfile.js')379 .then(function (compiled) {380 expect(compiled.tests[0].meta.metaField1).eql('testMetaValue1');381 expect(compiled.tests[0].meta.metaField4).eql('testMetaUpdatedValue4');382 expect(compiled.tests[0].meta.metaField5).eql('testMetaValue5');383 expect(compiled.tests[1].meta.emptyField).eql(void 0);384 });385 });386 it('Should raise an error if test.meta is null', function () {387 const file = resolve('test/server/data/test-suites/meta/incorrect-test-meta.js');388 return compile(file)389 .then(function () {390 throw new Error('Promise rejection expected');391 })392 .catch(function (err) {393 assertAPIError(err, {394 stackTop: file,395 message: 'Cannot prepare tests due to an error.\n\n' +396 'test.meta is expected to be a string or a non-null object, but it was null.',397 callsite: ' 1 |fixture(\'Fixture1\')\n' +398 ' 2 | .page(\'http://example.com\');\n' +399 ' 3 |\n' +400 ' 4 |test\n' +401 ' > 5 | .meta(null)\n' +402 ' 6 | (\'Fixture1Test1\', async () => {\n' +403 ' 7 | // do nothing\n' +404 ' 8 | });'405 });406 });407 });408 it('Should raise an error if fixture is missing', function () {409 const file = resolve('test/server/data/test-suites/fixture-is-missing/testfile.js');410 return compile(file)411 .then(function () {412 throw new Error('Promise rejection expected');413 })414 .catch(function (err) {415 assertAPIError(err, {416 stackTop: file,417 message: 'Cannot prepare tests due to an error.\n\n' +418 'The fixture of \'Test\' test is expected to be a non-null object, but it was null.',419 callsite: ' 1 |// fixture `Fixture`\n' +420 ' 2 |\n' +421 ' > 3 |test(\'Test\', () => {\n' +422 ' 4 | return \'yo\';\n' +423 ' 5 |});'424 });425 });426 });427 });428 describe('Selector', function () {429 it('Should raise an error if Selector initialized with wrong type', function () {430 const testfile = resolve('test/server/data/test-suites/selector-arg-is-not-a-function-or-string/testfile.js');431 return compile(testfile)432 .then(function () {433 throw new Error('Promise rejection expected');434 })435 .catch(function (err) {436 assertAPIError(err, {437 stackTop: testfile,438 message: 'Cannot prepare tests due to an error.\n\n' +439 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +440 'node snapshot or a Promise returned by a Selector, but number was passed.',441 callsite: " 1 |import { Selector } from 'testcafe';\n" +442 ' 2 |\n' +443 ' 3 |fixture `Test`;\n' +444 ' 4 |\n' +445 ' > 5 |Selector(123);\n' +446 ' 6 |\n' +447 " 7 |test('yo', () => {\n" +448 ' 8 |});\n' +449 ' 9 |'450 });451 });452 });453 it('Should raise an error if Selector `visibilityCheck` option is not a boolean value', function () {454 const testfile = resolve('test/server/data/test-suites/selector-visibility-check-opt-not-bool/testfile.js');455 return compile(testfile)456 .then(function () {457 throw new Error('Promise rejection expected');458 })459 .catch(function (err) {460 assertAPIError(err, {461 stackTop: testfile,462 message: 'Cannot prepare tests due to an error.\n\n' +463 '"visibilityCheck" option is expected to be a boolean, but it was number.',464 callsite: " 1 |import { Selector } from 'testcafe';\n" +465 ' 2 |\n' +466 ' 3 |fixture `Test`;\n' +467 ' 4 |\n' +468 ' > 5 |Selector(() => {}).with({ visibilityCheck: 42 });\n' +469 ' 6 |\n' +470 " 7 |test('yo', () => {\n" +471 ' 8 |});'472 });473 });474 });475 it('Should raise an error if Selector `timeout` option is not a non-negative number', function () {476 const testfile = resolve('test/server/data/test-suites/selector-timeout-is-not-non-negative-value/testfile.js');477 return compile(testfile)478 .then(function () {479 throw new Error('Promise rejection expected');480 })481 .catch(function (err) {482 assertAPIError(err, {483 stackTop: testfile,484 message: 'Cannot prepare tests due to an error.\n\n' +485 '"timeout" option is expected to be a non-negative number, but it was -5.',486 callsite: " 1 |import { Selector } from 'testcafe';\n" +487 ' 2 |\n' +488 ' 3 |fixture `Test`;\n' +489 ' 4 |\n' +490 ' > 5 |Selector(() => {}).with({ timeout: -5 });\n' +491 ' 6 |\n' +492 " 7 |test('yo', () => {\n" +493 ' 8 |});'494 });495 });496 });497 it('Should raise `it was NaN` error if Selector.nth() `index` argument is NaN', function () {498 const testfile = resolve('test/server/data/test-suites/selector-nth-arg-is-nan-value/testfile.js');499 return compile(testfile)500 .then(function () {501 throw new Error('Promise rejection expected');502 })503 .catch(function (err) {504 assertAPIError(err, {505 stackTop: testfile,506 message: 'Cannot prepare tests due to an error.\n\n' +507 '"index" argument is expected to be a number, but it was NaN.',508 callsite: " 1 |import { Selector } from 'testcafe';\n" +509 ' 2 |\n' +510 ' 3 |fixture `Test`;\n' +511 ' 4 |\n' +512 ' > 5 |Selector(() => {}).nth(NaN);\n' +513 ' 6 |\n' +514 " 7 |test('yo', () => {\n" +515 ' 8 |});'516 });517 });518 });519 it('Should raise `it was Infinity` error if Selector.nth() `index` argument is Infinity', function () {520 const testfile = resolve('test/server/data/test-suites/selector-nth-arg-is-infinity-value/testfile.js');521 return compile(testfile)522 .then(function () {523 throw new Error('Promise rejection expected');524 })525 .catch(function (err) {526 assertAPIError(err, {527 stackTop: testfile,528 message: 'Cannot prepare tests due to an error.\n\n' +529 '"index" argument is expected to be a number, but it was Infinity.',530 callsite: " 1 |import { Selector } from 'testcafe';\n" +531 ' 2 |\n' +532 ' 3 |fixture `Test`;\n' +533 ' 4 |\n' +534 ' > 5 |Selector(() => {}).nth(Infinity);\n' +535 ' 6 |\n' +536 " 7 |test('yo', () => {\n" +537 ' 8 |});'538 });539 });540 });541 it('Should raise an error if Selector.nth() `index` argument is not a number', function () {542 const testfile = resolve('test/server/data/test-suites/selector-nth-arg-is-a-number-value/testfile.js');543 return compile(testfile)544 .then(function () {545 throw new Error('Promise rejection expected');546 })547 .catch(function (err) {548 assertAPIError(err, {549 stackTop: testfile,550 message: 'Cannot prepare tests due to an error.\n\n' +551 '"index" argument is expected to be a number, but it was string.',552 callsite: " 1 |import { Selector } from 'testcafe';\n" +553 ' 2 |\n' +554 ' 3 |fixture `Test`;\n' +555 ' 4 |\n' +556 ' > 5 |Selector(() => {}).nth(\'hey\');\n' +557 ' 6 |\n' +558 " 7 |test('yo', () => {\n" +559 ' 8 |});'560 });561 });562 });563 it('Should raise an error if Selector.withText `text` argument is not a RegExp or string', function () {564 const testfile = resolve('test/server/data/test-suites/selector-with-text-arg-is-not-regexp-or-string/testfile.js');565 return compile(testfile)566 .then(function () {567 throw new Error('Promise rejection expected');568 })569 .catch(function (err) {570 assertAPIError(err, {571 stackTop: testfile,572 message: 'Cannot prepare tests due to an error.\n\n' +573 '"text" argument is expected to be a string or a regular expression, but it was object.',574 callsite: " 1 |import { Selector } from 'testcafe';\n" +575 ' 2 |\n' +576 ' 3 |fixture `Test`;\n' +577 ' 4 |\n' +578 ' > 5 |Selector(() => {}).withText({});\n' +579 ' 6 |\n' +580 " 7 |test('yo', () => {\n" +581 ' 8 |});'582 });583 });584 });585 it('Should raise an error if Selector.withAttribute `attrName` argument is not a RegExp or string', function () {586 const testfile = resolve('test/server/data/test-suites/selector-with-attr-arg-is-not-regexp-or-string/attrName.js');587 return compile(testfile)588 .then(function () {589 throw new Error('Promise rejection expected');590 })591 .catch(function (err) {592 assertAPIError(err, {593 stackTop: testfile,594 message: 'Cannot prepare tests due to an error.\n\n' +595 '"attrName" argument is expected to be a string or a regular expression, but it was object.',596 callsite: " 1 |import { Selector } from 'testcafe';\n" +597 ' 2 |\n' +598 ' 3 |fixture `Test`;\n' +599 ' 4 |\n' +600 ' > 5 |Selector(() => {}).withAttribute(null);\n' +601 ' 6 |\n' +602 " 7 |test('yo', () => {\n" +603 ' 8 |});'604 });605 });606 });607 it('Should raise an error if Selector.withAttribute `attrValue` argument is not a RegExp or string', function () {608 const testfile = resolve('test/server/data/test-suites/selector-with-attr-arg-is-not-regexp-or-string/attrValue.js');609 return compile(testfile)610 .then(function () {611 throw new Error('Promise rejection expected');612 })613 .catch(function (err) {614 assertAPIError(err, {615 stackTop: testfile,616 message: 'Cannot prepare tests due to an error.\n\n' +617 '"attrValue" argument is expected to be a string or a regular expression, but it was number.',618 callsite: " 1 |import { Selector } from 'testcafe';\n" +619 ' 2 |\n' +620 ' 3 |fixture `Test`;\n' +621 ' 4 |\n' +622 ' > 5 |Selector(() => {}).withAttribute(/class/, -100);\n' +623 ' 6 |\n' +624 " 7 |test('yo', () => {\n" +625 ' 8 |});'626 });627 });628 });629 it('Should raise an error if Selector.filter `filter` argument is not a function or string', function () {630 const testfile = resolve('test/server/data/test-suites/selector-filter-arg-is-not-a-function-or-string/testfile.js');631 return compile(testfile)632 .then(function () {633 throw new Error('Promise rejection expected');634 })635 .catch(function (err) {636 assertAPIError(err, {637 stackTop: testfile,638 message: 'Cannot prepare tests due to an error.\n\n' +639 '"filter" argument is expected to be a string or a function, but it was object.',640 callsite: " 1 |import { Selector } from 'testcafe';\n" +641 ' 2 |\n' +642 ' 3 |fixture `Test`;\n' +643 ' 4 |\n' +644 " > 5 |Selector('span').filter({});\n" +645 ' 6 |\n' +646 " 7 |test('yo', () => {\n" +647 ' 8 |});'648 });649 });650 });651 it('Should raise an error if Selector.find `filter` argument is not a function or string', function () {652 const testfile = resolve('test/server/data/test-suites/selector-find-arg-is-not-a-string-or-function/testfile.js');653 return compile(testfile)654 .then(function () {655 throw new Error('Promise rejection expected');656 })657 .catch(function (err) {658 assertAPIError(err, {659 stackTop: testfile,660 message: 'Cannot prepare tests due to an error.\n\n' +661 '"filter" argument is expected to be a string or a function, but it was object.',662 callsite: " 1 |import { Selector } from 'testcafe';\n" +663 ' 2 |\n' +664 ' 3 |fixture `Test`;\n' +665 ' 4 |\n' +666 ' > 5 |Selector(\'span\').find({});\n' +667 ' 6 |\n' +668 " 7 |test('yo', () => {\n" +669 ' 8 |});'670 });671 });672 });673 it('Should raise an error if Selector.parent `filter` argument is not a function or string', function () {674 const testfile = resolve('test/server/data/test-suites/selector-parent-incorrect-arg-type/testfile.js');675 return compile(testfile)676 .then(function () {677 throw new Error('Promise rejection expected');678 })679 .catch(function (err) {680 assertAPIError(err, {681 stackTop: testfile,682 message: 'Cannot prepare tests due to an error.\n\n' +683 '"filter" argument is expected to be a string, function or a number, but it was object.',684 callsite: " 1 |import { Selector } from 'testcafe';\n" +685 ' 2 |\n' +686 ' 3 |fixture `Test`;\n' +687 ' 4 |Selector(\'span\').parent();\n' +688 ' > 5 |Selector(\'span\').parent({});\n' +689 ' 6 |\n' +690 " 7 |test('yo', () => {\n" +691 ' 8 |});'692 });693 });694 });695 it('Should raise an error if Selector.child `filter` argument is not a function or string', function () {696 const testfile = resolve('test/server/data/test-suites/selector-child-incorrect-arg-type/testfile.js');697 return compile(testfile)698 .then(function () {699 throw new Error('Promise rejection expected');700 })701 .catch(function (err) {702 assertAPIError(err, {703 stackTop: testfile,704 message: 'Cannot prepare tests due to an error.\n\n' +705 '"filter" argument is expected to be a string, function or a number, but it was object.',706 callsite: " 1 |import { Selector } from 'testcafe';\n" +707 ' 2 |\n' +708 ' 3 |fixture `Test`;\n' +709 ' 4 |Selector(\'span\').child();\n' +710 ' > 5 |Selector(\'span\').child({});\n' +711 ' 6 |\n' +712 " 7 |test('yo', () => {\n" +713 ' 8 |});'714 });715 });716 });717 it('Should raise an error if Selector.sibling `filter` argument is not a function or string', function () {718 const testfile = resolve('test/server/data/test-suites/selector-sibling-incorrect-arg-type/testfile.js');719 return compile(testfile)720 .then(function () {721 throw new Error('Promise rejection expected');722 })723 .catch(function (err) {724 assertAPIError(err, {725 stackTop: testfile,726 message: 'Cannot prepare tests due to an error.\n\n' +727 '"filter" argument is expected to be a string, function or a number, but it was object.',728 callsite: " 1 |import { Selector } from 'testcafe';\n" +729 ' 2 |\n' +730 ' 3 |fixture `Test`;\n' +731 ' 4 |Selector(\'span\').sibling();\n' +732 ' > 5 |Selector(\'span\').sibling({});\n' +733 ' 6 |\n' +734 " 7 |test('yo', () => {\n" +735 ' 8 |});'736 });737 });738 });739 it('Should raise an error if Selector.nextSibling `filter` argument is not a function or string', function () {740 const testfile = resolve('test/server/data/test-suites/selector-next-sibling-incorrect-arg-type/testfile.js');741 return compile(testfile)742 .then(function () {743 throw new Error('Promise rejection expected');744 })745 .catch(function (err) {746 assertAPIError(err, {747 stackTop: testfile,748 message: 'Cannot prepare tests due to an error.\n\n' +749 '"filter" argument is expected to be a string, function or a number, but it was object.',750 callsite: " 1 |import { Selector } from 'testcafe';\n" +751 ' 2 |\n' +752 ' 3 |fixture `Test`;\n' +753 ' 4 |Selector(\'span\').nextSibling();\n' +754 ' > 5 |Selector(\'span\').nextSibling({});\n' +755 ' 6 |\n' +756 " 7 |test('yo', () => {\n" +757 ' 8 |});'758 });759 });760 });761 it('Should raise an error if Selector.prevSibling `filter` argument is not a function or string', function () {762 const testfile = resolve('test/server/data/test-suites/selector-prev-sibling-incorrect-arg-type/testfile.js');763 return compile(testfile)764 .then(function () {765 throw new Error('Promise rejection expected');766 })767 .catch(function (err) {768 assertAPIError(err, {769 stackTop: testfile,770 message: 'Cannot prepare tests due to an error.\n\n' +771 '"filter" argument is expected to be a string, function or a number, but it was object.',772 callsite: " 1 |import { Selector } from 'testcafe';\n" +773 ' 2 |\n' +774 ' 3 |fixture `Test`;\n' +775 ' 4 |Selector(\'span\').prevSibling();\n' +776 ' > 5 |Selector(\'span\').prevSibling({});\n' +777 ' 6 |\n' +778 " 7 |test('yo', () => {\n" +779 ' 8 |});'780 });781 });782 });783 it('Should raise an error if Selector.addCustomDOMProperties argument is not object', function () {784 const testfile = resolve('test/server/data/test-suites/selector-add-custom-dom-properties-incorrect-arg-type/testfile.js');785 return compile(testfile)786 .then(function () {787 throw new Error('Promise rejection expected');788 })789 .catch(function (err) {790 assertAPIError(err, {791 stackTop: testfile,792 message: 'Cannot prepare tests due to an error.\n\n' +793 '"addCustomDOMProperties" option is expected to be a non-null object, but it was number.',794 callsite: " 1 |import { Selector } from 'testcafe';\n" +795 ' 2 |\n' +796 ' 3 |fixture `Test`;\n' +797 " 4 |Selector('span').addCustomDOMProperties({a: () => {}});\n" +798 " > 5 |Selector('span').addCustomDOMProperties(42);\n" +799 ' 6 |\n' +800 " 7 |test('yo', () => {\n" +801 ' 8 |});\n' +802 ' 9 |'803 });804 });805 });806 it('Should raise error if at least one of Selector custom DOM properties is not function', function () {807 const testfile = resolve('test/server/data/test-suites/selector-custom-dom-property-incorrect-arg-type/testfile.js');808 return compile(testfile)809 .then(function () {810 throw new Error('Promise rejection expected');811 })812 .catch(function (err) {813 assertAPIError(err, {814 stackTop: testfile,815 message: 'Cannot prepare tests due to an error.\n\n' +816 "Custom DOM properties method 'prop1' is expected to be a function, but it was number.",817 callsite: " 1 |import { Selector } from 'testcafe';\n" +818 ' 2 |\n' +819 ' 3 |fixture `Test`;\n' +820 " > 4 |Selector('rect').addCustomDOMProperties({ prop1: 1, prop2: () => 42 });\n" +821 ' 5 |\n' +822 " 6 |test('yo', () => {\n" +823 ' 7 |});\n' +824 ' 8 |'825 });826 });827 });828 it('Should raise error if Selector.addCustomMethods argument is not object', function () {829 const testfile = resolve('test/server/data/test-suites/selector-add-custom-methods-incorrect-arg-type/testfile.js');830 return compile(testfile)831 .then(function () {832 throw new Error('Promise rejection expected');833 })834 .catch(function (err) {835 assertAPIError(err, {836 stackTop: testfile,837 message: 'Cannot prepare tests due to an error.\n\n' +838 '"addCustomMethods" option is expected to be a non-null object, but it was number.',839 callsite: " 1 |import { Selector } from 'testcafe';\n" +840 ' 2 |\n' +841 ' 3 |fixture `Test`;\n' +842 " 4 |Selector('span').addCustomMethods({a: () => {}});\n" +843 " > 5 |Selector('span').addCustomMethods(42);\n" +844 ' 6 |\n' +845 " 7 |test('yo', () => {\n" +846 ' 8 |});\n' +847 ' 9 |'848 });849 });850 });851 it('Should raise error if at least one of custom methods is not function', function () {852 const testfile = resolve('test/server/data/test-suites/selector-custom-dom-method-incorrect-arg-type/testfile.js');853 return compile(testfile)854 .then(function () {855 throw new Error('Promise rejection expected');856 })857 .catch(function (err) {858 assertAPIError(err, {859 stackTop: testfile,860 message: 'Cannot prepare tests due to an error.\n\n' +861 "Custom method 'prop1' is expected to be a function, but it was number.",862 callsite: " 1 |import { Selector } from 'testcafe';\n" +863 ' 2 |\n' +864 ' 3 |fixture `Test`;\n' +865 " > 4 |Selector('span').addCustomMethods({ prop1: 1, prop2: () => 42 });\n" +866 ' 5 |\n' +867 " 6 |test('yo', () => {\n" +868 ' 7 |});\n' +869 ' 8 |'870 });871 });872 });873 });874 describe('ClientFunction', function () {875 it('Should raise an error if ClientFunction argument is not a function', function () {876 const testfile = resolve('test/server/data/test-suites/client-fn-arg-is-not-a-function/testfile.js');877 return compile(testfile)878 .then(function () {879 throw new Error('Promise rejection expected');880 })881 .catch(function (err) {882 assertAPIError(err, {883 stackTop: testfile,884 message: 'Cannot prepare tests due to an error.\n\n' +885 'ClientFunction code is expected to be specified as a function, but number was passed.',886 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +887 ' 2 |\n' +888 ' 3 |fixture `Test`;\n' +889 ' 4 |\n' +890 ' > 5 |ClientFunction(123);\n' +891 ' 6 |\n' +892 " 7 |test('yo', () => {\n" +893 ' 8 |});\n' +894 ' 9 |'895 });896 });897 });898 it('Should raise an error if ClientFunction argument is not a function (if called as ctor)', function () {899 const testfile = resolve('test/server/data/test-suites/client-fn-arg-is-not-a-function-as-ctor/testfile.js');900 return compile(testfile)901 .then(function () {902 throw new Error('Promise rejection expected');903 })904 .catch(function (err) {905 assertAPIError(err, {906 stackTop: testfile,907 message: 'Cannot prepare tests due to an error.\n\n' +908 'ClientFunction code is expected to be specified as a function, but number was passed.',909 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +910 ' 2 |\n' +911 ' 3 |fixture `Test`;\n' +912 ' 4 |\n' +913 ' > 5 |var h = new ClientFunction(123);\n' +914 ' 6 |\n' +915 " 7 |test('yo', () => {\n" +916 ' 8 |});\n' +917 ' 9 |'918 });919 });920 });921 it('Should raise an error if ClientFunction uses async function', function () {922 const testfile = resolve('test/server/data/test-suites/async-function-in-client-fn/testfile.js');923 return compile(testfile)924 .then(function () {925 throw new Error('Promise rejection expected');926 })927 .catch(function (err) {928 assertAPIError(err, {929 stackTop: testfile,930 message: 'Cannot prepare tests due to an error.\n\n' +931 'ClientFunction code, arguments or dependencies cannot contain generators or "async/await" syntax (use Promises instead).',932 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +933 ' 2 |\n' +934 ' 3 |fixture `Test`;\n' +935 ' 4 |\n' +936 ' > 5 |ClientFunction(async function () {\n' +937 ' 6 |});\n' +938 ' 7 |\n' +939 " 8 |test('yo', () => {\n" +940 ' 9 |});\n'941 });942 });943 });944 it('Should raise an error if ClientFunction uses generator', function () {945 const testfile = resolve('test/server/data/test-suites/generator-in-client-fn/testfile.js');946 return compile(testfile)947 .then(function () {948 throw new Error('Promise rejection expected');949 })950 .catch(function (err) {951 assertAPIError(err, {952 stackTop: testfile,953 message: 'Cannot prepare tests due to an error.\n\n' +954 'ClientFunction code, arguments or dependencies cannot contain generators or "async/await" syntax (use Promises instead).',955 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +956 ' 2 |\n' +957 ' 3 |fixture `Test`;\n' +958 ' 4 |\n' +959 ' > 5 |ClientFunction(function* () {\n' +960 ' 6 | yield 1;\n' +961 ' 7 |});\n' +962 ' 8 |\n' +963 " 9 |test('yo', () => {\n" +964 ' 10 |});'965 });966 });967 });968 it('Should raise an error if ClientFunction options is not an object', function () {969 const testfile = resolve('test/server/data/test-suites/client-fn-options-not-object/testfile.js');970 return compile(testfile)971 .then(function () {972 throw new Error('Promise rejection expected');973 })974 .catch(function (err) {975 assertAPIError(err, {976 stackTop: testfile,977 message: 'Cannot prepare tests due to an error.\n\n' +978 '"options" argument is expected to be a non-null object, but it was number.',979 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +980 ' 2 |\n' +981 ' 3 |fixture `Test`;\n' +982 ' 4 |\n' +983 ' > 5 |ClientFunction(() => {}).with(123);\n' +984 ' 6 |\n' +985 " 7 |test('yo', () => {\n" +986 ' 8 |});\n'987 });988 });989 });990 it('Should raise an error if ClientFunction "dependencies" is not an object', function () {991 const testfile = resolve('test/server/data/test-suites/client-fn-dependencies-not-object/testfile.js');992 return compile(testfile)993 .then(function () {994 throw new Error('Promise rejection expected');995 })996 .catch(function (err) {997 assertAPIError(err, {998 stackTop: testfile,999 message: 'Cannot prepare tests due to an error.\n\n' +1000 '"dependencies" option is expected to be a non-null object, but it was string.',1001 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +1002 ' 2 |\n' +1003 ' 3 |fixture `Test`;\n' +1004 ' 4 |\n' +1005 " > 5 |var selectYo = ClientFunction(() => document.querySelector('#yo'), { dependencies: '42' });\n"1006 });1007 });1008 });1009 it('Should raise an error if ClientFunction `boundTestRun` option is not TestController', function () {1010 const testfile = resolve('test/server/data/test-suites/client-fn-bound-test-run-not-t/testfile.js');1011 return compile(testfile)1012 .then(function () {1013 throw new Error('Promise rejection expected');1014 })1015 .catch(function (err) {1016 assertAPIError(err, {1017 stackTop: testfile,1018 message: 'Cannot prepare tests due to an error.\n\n' +1019 'The "boundTestRun" option value is expected to be a test controller.',1020 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +1021 ' 2 |\n' +1022 ' 3 |fixture `Test`;\n' +1023 ' 4 |\n' +1024 " > 5 |ClientFunction(() => {}).with({ boundTestRun: 'yo' });\n" +1025 ' 6 |\n' +1026 " 7 |test('yo', () => {\n" +1027 ' 8 |});'1028 });1029 });1030 });1031 });1032 describe('Role', function () {1033 it('Should raise an error if Role "loginPage" is not a string', function () {1034 const testfile = resolve('test/server/data/test-suites/role-login-page-is-not-a-string/testfile.js');1035 return compile(testfile)1036 .then(function () {1037 throw new Error('Promise rejection expected');1038 })1039 .catch(function (err) {1040 assertAPIError(err, {1041 stackTop: testfile,1042 message: 'Cannot prepare tests due to an error.\n\n' +1043 '"loginPage" argument is expected to be a string, but it was number.',1044 callsite: " 1 |import { Role } from 'testcafe';\n" +1045 ' 2 |\n' +1046 ' 3 |fixture `Test`;\n' +1047 ' 4 |\n' +1048 ' > 5 |Role(123, () => {});\n' +1049 ' 6 |\n' +1050 " 7 |test('yo', () => {\n" +1051 ' 8 |});\n' +1052 ' 9 |'1053 });1054 });1055 });1056 it('Should raise an error if Role "initFn" is not a string', function () {1057 const testfile = resolve('test/server/data/test-suites/role-init-fn-is-not-a-function/testfile.js');1058 return compile(testfile)1059 .then(function () {1060 throw new Error('Promise rejection expected');1061 })1062 .catch(function (err) {1063 assertAPIError(err, {1064 stackTop: testfile,1065 message: 'Cannot prepare tests due to an error.\n\n' +1066 '"initFn" argument is expected to be a function, but it was number.',1067 callsite: " 1 |import { Role } from 'testcafe';\n" +1068 ' 2 |\n' +1069 ' 3 |fixture `Test`;\n' +1070 ' 4 |\n' +1071 " > 5 |Role('exampe.com', 123);\n" +1072 ' 6 |\n' +1073 " 7 |test('yo', () => {\n" +1074 ' 8 |});\n' +1075 ' 9 |'1076 });1077 });1078 });1079 it('Should raise an error if Role "options" is not an object', function () {1080 const testfile = resolve('test/server/data/test-suites/role-options-is-not-an-object/testfile.js');1081 return compile(testfile)1082 .then(function () {1083 throw new Error('Promise rejection expected');1084 })1085 .catch(function (err) {1086 assertAPIError(err, {1087 stackTop: testfile,1088 message: 'Cannot prepare tests due to an error.\n\n' +1089 '"options" argument is expected to be a non-null object, but it was string.',1090 callsite: " 1 |import { Role } from 'testcafe';\n" +1091 ' 2 |\n' +1092 ' 3 |fixture `Test`;\n' +1093 ' 4 |\n' +1094 " > 5 |Role('http://example.com', () => {}, 'hey');\n" +1095 ' 6 |\n' +1096 " 7 |test('yo', () => {\n" +1097 ' 8 |});\n' +1098 ' 9 |'1099 });1100 });1101 });1102 it('Should raise an error if Role "option.preserveUrl" is not a boolean', function () {1103 const testfile = resolve('test/server/data/test-suites/role-preserve-url-option-is-not-a-boolean/testfile.js');1104 return compile(testfile)1105 .then(function () {1106 throw new Error('Promise rejection expected');1107 })1108 .catch(function (err) {1109 assertAPIError(err, {1110 stackTop: testfile,1111 message: 'Cannot prepare tests due to an error.\n\n' +1112 '"preserveUrl" option is expected to be a boolean, but it was object.',1113 callsite: " 1 |import { Role } from 'testcafe';\n" +1114 ' 2 |\n' +1115 ' 3 |fixture `Test`;\n' +1116 ' 4 |\n' +1117 " > 5 |Role('http://example.com', () => {}, { preserveUrl: [] });\n" +1118 ' 6 |\n' +1119 " 7 |test('yo', () => {\n" +1120 ' 8 |});\n' +1121 ' 9 |'1122 });1123 });1124 });1125 });1126 describe('TestController import', function () {1127 it('Should raise an error if TestControllerProxy cannot resolve test run', function () {1128 const testfile = resolve('test/server/data/test-suites/cannot-resolve-test-run-proxy-context/testfile.js');1129 return compile(testfile)1130 .then(function () {1131 throw new Error('Promise rejection expected');1132 })1133 .catch(function (err) {1134 assertAPIError(err, {1135 stackTop: testfile,1136 message: 'Cannot prepare tests due to an error.\n\n' +1137 "Cannot implicitly resolve the test run in the context of which the test controller action should be executed. Use test function's 't' argument instead.",1138 callsite: ' 1 |import { t } from \'testcafe\';\n' +1139 ' 2 |\n' +1140 ' 3 |fixture `Some fixture`;\n' +1141 ' 4 |\n' +1142 ' > 5 |t.click(\'div\');\n' +1143 ' 6 |\n' +1144 ' 7 |test(\'Some test\', async () => {\n' +1145 ' 8 |\n' +1146 ' 9 |});'1147 });1148 });1149 });1150 });1151 describe('Request Hooks', () => {1152 describe('Should raise errors for wrong RequestLogger construction', () => {1153 it('Cannot stringify the request body', () => {1154 const testFile = resolve('test/server/data/test-suites/request-hooks/request-logger/cannot-stringify-request-body.js');1155 return compile(testFile)1156 .then(() => {1157 throw new Error('Promise rejection expected');1158 })1159 .catch(err => {1160 assertAPIError(err, {1161 stackTop: testFile,1162 message: 'Cannot prepare tests due to an error.\n\n' +1163 'There was an error while configuring the request hook:\n\n' +1164 'RequestLogger: Cannot stringify the request body because it is not logged. Specify { logRequestBody: true } in log options.',1165 callsite: ' 1 |import { RequestLogger } from \'testcafe\';\n' +1166 ' 2 |\n' +1167 ' 3 |fixture `Fixture`;\n' +1168 ' 4 |\n' +1169 " > 5 |const logger = new RequestLogger('', {\n" +1170 ' 6 | logRequestBody: false,\n' +1171 ' 7 | stringifyRequestBody: true\n' +1172 ' 8 |});'1173 });1174 });1175 });1176 it('Cannot stringify the response body', () => {1177 const testFile = resolve('test/server/data/test-suites/request-hooks/request-logger/cannot-stringify-response-body.js');1178 return compile(testFile)1179 .then(() => {1180 throw new Error('Promise rejection expected');1181 })1182 .catch(err => {1183 assertAPIError(err, {1184 stackTop: testFile,1185 message: 'Cannot prepare tests due to an error.\n\n' +1186 'There was an error while configuring the request hook:\n\n' +1187 'RequestLogger: Cannot stringify the response body because it is not logged. Specify { logResponseBody: true } in log options.',1188 callsite: ' 1 |import { RequestLogger } from \'testcafe\';\n' +1189 ' 2 |\n' +1190 ' 3 |fixture `Fixture`;\n' +1191 ' 4 |\n' +1192 " > 5 |const logger = new RequestLogger('', {\n" +1193 ' 6 | logResponseBody: false,\n' +1194 ' 7 | stringifyResponseBody: true\n' +1195 ' 8 |});'1196 });1197 });1198 });1199 });1200 describe('Should raise errors for wrong RequestMock api order call', () => {1201 it("The 'respond' method was not called after 'onRequestTo'", () => {1202 const testFile = resolve('test/server/data/test-suites/request-hooks/request-mock/respond-was-not-called-after-on-request-to.js');1203 return compile(testFile)1204 .then(() => {1205 throw new Error('Promise rejection expected');1206 })1207 .catch(err => {1208 assertAPIError(err, {1209 stackTop: testFile,1210 message: 'Cannot prepare tests due to an error.\n\n' +1211 'There was an error while configuring the request hook:\n\n' +1212 "RequestMock: The 'respond' method was not called after 'onRequestTo'. You must call the 'respond' method to provide the mocked response.",1213 callsite: ' 1 |import { RequestMock } from \'testcafe\';\n' +1214 ' 2 |\n' +1215 ' 3 |fixture `Fixture`;\n' +1216 ' 4 |\n' +1217 ' > 5 |const mock = RequestMock().onRequestTo({}).onRequestTo({});\n' +1218 ' 6 |\n' +1219 ' 7 |test(\'test\', async t => {});\n' +1220 ' 8 |\n'1221 });1222 });1223 });1224 it("The 'onRequestTo' method was not called before 'respond'", () => {1225 const testFile = resolve('test/server/data/test-suites/request-hooks/request-mock/on-request-to-was-not-called-before-respond.js');1226 return compile(testFile)1227 .then(() => {1228 throw new Error('Promise rejection expected');1229 })1230 .catch(err => {1231 assertAPIError(err, {1232 stackTop: testFile,1233 message: 'Cannot prepare tests due to an error.\n\n' +1234 'There was an error while configuring the request hook:\n\n' +1235 "RequestMock: The 'onRequestTo' method was not called before 'respond'. You must call the 'onRequestTo' method to provide the URL requests to which are mocked.",1236 callsite: ' 1 |import { RequestMock } from \'testcafe\';\n' +1237 ' 2 |\n' +1238 ' 3 |fixture `Fixture`;\n' +1239 ' 4 |\n' +1240 ' > 5 |const mock = RequestMock().respond(() => {}).onRequestTo({});\n' +1241 ' 6 |\n' +1242 ' 7 |test(\'test\', async t => {});\n' +1243 ' 8 |'1244 });1245 });...

Full Screen

Full Screen

compiler-test.js

Source:compiler-test.js Github

copy

Full Screen

...321 .then(function () {322 throw new Error('Promise rejection expected');323 })324 .catch(function (err) {325 assertAPIError(err, {326 stackTop: testfile,327 message: 'Cannot prepare tests due to an error.\n\n' +328 'The fixture name is expected to be a string, but it was object.',329 callsite: ' 2 |// (to treat a file as a test, it requires at least one fixture definition\n' +330 ' 3 |// with the string argument).\n' +331 ' 4 |\n' +332 ' 5 |fixture `Yo`;\n' +333 ' 6 |\n' +334 ' > 7 |fixture({ answer: 42 });\n' +335 ' 8 |\n' +336 " 9 |test('Test', () => {\n" +337 " 10 | return 'yo';\n" +338 ' 11 |});\n' +339 ' 12 |'340 });341 });342 });343 it('Should raise an error if fixture page is not a string', function () {344 var testfile = resolve('test/server/data/test-suites/fixture-page-is-not-a-string/testfile.js');345 return compile(testfile)346 .then(function () {347 throw new Error('Promise rejection expected');348 })349 .catch(function (err) {350 assertAPIError(err, {351 stackTop: testfile,352 message: 'Cannot prepare tests due to an error.\n\n' +353 'The page URL is expected to be a string, but it was object.',354 callsite: ' 1 |fixture `Yo`\n' +355 ' > 2 | .page({ answer: 42 });\n' +356 ' 3 |\n' +357 " 4 |test('Test', () => {\n" +358 " 5 | return 'yo';\n" +359 ' 6 |});\n' +360 ' 7 |'361 });362 });363 });364 it('Should raise an error if test name is not a string', function () {365 var testfile = resolve('test/server/data/test-suites/test-name-is-not-a-string/testfile.js');366 return compile(testfile)367 .then(function () {368 throw new Error('Promise rejection expected');369 })370 .catch(function (err) {371 assertAPIError(err, {372 stackTop: testfile,373 message: 'Cannot prepare tests due to an error.\n\n' +374 'The test name is expected to be a string, but it was number.',375 callsite: ' 4 |// (to treat a file as a test, it requires at least one fixture definition\n' +376 ' 5 |// with the string argument).\n' +377 " 6 |test('TheAnswer', () => {\n 7 |});\n" +378 ' 8 |\n' +379 ' > 9 |test(42, () => {\n' +380 ' 10 |});\n' +381 ' 11 |'382 });383 });384 });385 it('Should raise an error if test body is not a function', function () {386 var testfile = resolve('test/server/data/test-suites/test-body-is-not-a-function/testfile.js');387 return compile(testfile)388 .then(function () {389 throw new Error('Promise rejection expected');390 })391 .catch(function (err) {392 assertAPIError(err, {393 stackTop: testfile,394 message: 'Cannot prepare tests due to an error.\n\n' +395 'The test body is expected to be a function, but it was string.',396 callsite: ' 1 |fixture `Test body is not a function`;\n' +397 ' 2 |\n' +398 " > 3 |test('Test', 'Yo');\n" +399 ' 4 |'400 });401 });402 });403 it('Should raise an error if beforeEach is not a function', function () {404 var testfile = resolve('test/server/data/test-suites/before-each-is-not-a-function/testfile.js');405 return compile(testfile)406 .then(function () {407 throw new Error('Promise rejection expected');408 })409 .catch(function (err) {410 assertAPIError(err, {411 stackTop: testfile,412 message: 'Cannot prepare tests due to an error.\n\n' +413 'fixture.beforeEach hook is expected to be a function, but it was string.',414 callsite: ' 1 |fixture `beforeEach is not a function`\n' +415 " > 2 | .beforeEach('yo');\n" +416 ' 3 |\n' +417 " 4 |test('Some test', () => {\n" +418 ' 5 |\n' +419 ' 6 |});\n' +420 ' 7 |'421 });422 });423 });424 it('Should raise an error if fixture.before is not a function', function () {425 var testfile = resolve('test/server/data/test-suites/fixture-before-is-not-a-function/testfile.js');426 return compile(testfile)427 .then(function () {428 throw new Error('Promise rejection expected');429 })430 .catch(function (err) {431 assertAPIError(err, {432 stackTop: testfile,433 message: 'Cannot prepare tests due to an error.\n\n' +434 'fixture.before hook is expected to be a function, but it was string.',435 callsite: ' 1 |fixture `before is not a function`\n' +436 " > 2 | .before('yo');\n" +437 ' 3 |\n' +438 " 4 |test('Some test', () => {\n" +439 ' 5 |\n' +440 ' 6 |});\n' +441 ' 7 |'442 });443 });444 });445 it('Should raise an error if test.before is not a function', function () {446 var testfile = resolve('test/server/data/test-suites/test-before-is-not-a-function/testfile.js');447 return compile(testfile)448 .then(function () {449 throw new Error('Promise rejection expected');450 })451 .catch(function (err) {452 assertAPIError(err, {453 stackTop: testfile,454 message: 'Cannot prepare tests due to an error.\n\n' +455 'test.before hook is expected to be a function, but it was number.',456 callsite: ' 1 |fixture `Fixture`;\n' +457 ' 2 |\n' +458 " > 3 |test.before(123)('Some test', () => {\n" +459 ' 4 |\n' +460 ' 5 |});\n' +461 ' 6 |'462 });463 });464 });465 it('Should raise an error if test.after is not a function', function () {466 var testfile = resolve('test/server/data/test-suites/test-after-is-not-a-function/testfile.js');467 return compile(testfile)468 .then(function () {469 throw new Error('Promise rejection expected');470 })471 .catch(function (err) {472 assertAPIError(err, {473 stackTop: testfile,474 message: 'Cannot prepare tests due to an error.\n\n' +475 'test.after hook is expected to be a function, but it was number.',476 callsite: ' 1 |fixture `Fixture`;\n' +477 ' 2 |\n' +478 " > 3 |test.after(123)('Some test', () => {\n" +479 ' 4 |\n' +480 ' 5 |});\n' +481 ' 6 |'482 });483 });484 });485 it('Should raise an error if httpAuth takes a wrong argument', function () {486 var credentialsInNotObject = resolve('test/server/data/test-suites/http-auth/credentials-is-not-an-object.js');487 var passIsNotString = resolve('test/server/data/test-suites/http-auth/password-is-not-a-string.js');488 var usernameIsNotDefined = resolve('test/server/data/test-suites/http-auth/username-is-not-defined.js');489 return compile(credentialsInNotObject)490 .then(function () {491 throw new Error('Promise rejection expected');492 })493 .catch(function (err) {494 assertAPIError(err, {495 stackTop: credentialsInNotObject,496 message: 'Cannot prepare tests due to an error.\n\n' +497 'credentials is expected to be a non-null object, but it was string.',498 callsite: ' 1 |fixture `Credentials is not an object`\n' +499 " > 2 | .httpAuth('');\n" +500 ' 3 |\n' +501 " 4 |test('Some test', () => {\n" +502 ' 5 |\n' +503 ' 6 |});\n' +504 ' 7 |'505 });506 return compile(passIsNotString);507 })508 .then(function () {509 throw new Error('Promise rejection expected');510 })511 .catch(function (err) {512 assertAPIError(err, {513 stackTop: passIsNotString,514 message: 'Cannot prepare tests due to an error.\n\n' +515 'credentials.password is expected to be a string, but it was object.',516 callsite: ' 1 |fixture `Password is not a string`\n' +517 ' > 2 | .httpAuth({ username: \'username\', password: {} });\n' +518 ' 3 |\n' +519 " 4 |test('Some test', () => {\n" +520 ' 5 |\n' +521 ' 6 |});\n' +522 ' 7 |'523 });524 return compile(usernameIsNotDefined);525 })526 .then(function () {527 throw new Error('Promise rejection expected');528 })529 .catch(function (err) {530 assertAPIError(err, {531 stackTop: usernameIsNotDefined,532 message: 'Cannot prepare tests due to an error.\n\n' +533 'credentials.username is expected to be a string, but it was undefined.',534 callsite: ' 1 |fixture `Username is not defined`\n' +535 " > 2 | .httpAuth({ password: 'password' });\n" +536 ' 3 |\n' +537 " 4 |test('Some test', () => {\n" +538 ' 5 |\n' +539 ' 6 |});\n' +540 ' 7 |'541 });542 });543 });544 it('Should raise an error if afterEach is not a function', function () {545 var testfile = resolve('test/server/data/test-suites/after-each-is-not-a-function/testfile.js');546 return compile(testfile)547 .then(function () {548 throw new Error('Promise rejection expected');549 })550 .catch(function (err) {551 assertAPIError(err, {552 stackTop: testfile,553 message: 'Cannot prepare tests due to an error.\n\n' +554 'fixture.afterEach hook is expected to be a function, but it was string.',555 callsite: ' 1 |fixture `afterEach is not a function`\n' +556 " > 2 | .afterEach('yo');\n" +557 ' 3 |\n' +558 " 4 |test('Some test', () => {\n" +559 ' 5 |\n' +560 ' 6 |});\n' +561 ' 7 |'562 });563 });564 });565 it('Should raise an error if fixture.after is not a function', function () {566 var testfile = resolve('test/server/data/test-suites/fixture-after-is-not-a-function/testfile.js');567 return compile(testfile)568 .then(function () {569 throw new Error('Promise rejection expected');570 })571 .catch(function (err) {572 assertAPIError(err, {573 stackTop: testfile,574 message: 'Cannot prepare tests due to an error.\n\n' +575 'fixture.after hook is expected to be a function, but it was string.',576 callsite: ' 1 |fixture `after is not a function`\n' +577 " > 2 | .after('yo');\n" +578 ' 3 |\n' +579 " 4 |test('Some test', () => {\n" +580 ' 5 |\n' +581 ' 6 |});\n' +582 ' 7 |'583 });584 });585 });586 it('Should raise an error if ClientFunction argument is not a function', function () {587 var testfile = resolve('test/server/data/test-suites/client-fn-arg-is-not-a-function/testfile.js');588 return compile(testfile)589 .then(function () {590 throw new Error('Promise rejection expected');591 })592 .catch(function (err) {593 assertAPIError(err, {594 stackTop: testfile,595 message: 'Cannot prepare tests due to an error.\n\n' +596 'ClientFunction code is expected to be specified as a function, but number was passed.',597 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +598 ' 2 |\n' +599 ' 3 |fixture `Test`;\n' +600 ' 4 |\n' +601 ' > 5 |ClientFunction(123);\n' +602 ' 6 |\n' +603 " 7 |test('yo', () => {\n" +604 ' 8 |});\n' +605 ' 9 |'606 });607 });608 });609 it('Should raise an error if Selector initialized with wrong type', function () {610 var testfile = resolve('test/server/data/test-suites/selector-arg-is-not-a-function-or-string/testfile.js');611 return compile(testfile)612 .then(function () {613 throw new Error('Promise rejection expected');614 })615 .catch(function (err) {616 assertAPIError(err, {617 stackTop: testfile,618 message: 'Cannot prepare tests due to an error.\n\n' +619 'Selector is expected to be initialized with a function, CSS selector string, another Selector, ' +620 'node snapshot or a Promise returned by a Selector, but number was passed.',621 callsite: " 1 |import { Selector } from 'testcafe';\n" +622 ' 2 |\n' +623 ' 3 |fixture `Test`;\n' +624 ' 4 |\n' +625 ' > 5 |Selector(123);\n' +626 ' 6 |\n' +627 " 7 |test('yo', () => {\n" +628 ' 8 |});\n' +629 ' 9 |'630 });631 });632 });633 it('Should raise an error if ClientFunction argument is not a function (if called as ctor)', function () {634 var testfile = resolve('test/server/data/test-suites/client-fn-arg-is-not-a-function-as-ctor/testfile.js');635 return compile(testfile)636 .then(function () {637 throw new Error('Promise rejection expected');638 })639 .catch(function (err) {640 assertAPIError(err, {641 stackTop: testfile,642 message: 'Cannot prepare tests due to an error.\n\n' +643 'ClientFunction code is expected to be specified as a function, but number was passed.',644 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +645 ' 2 |\n' +646 ' 3 |fixture `Test`;\n' +647 ' 4 |\n' +648 ' > 5 |var h = new ClientFunction(123);\n' +649 ' 6 |\n' +650 " 7 |test('yo', () => {\n" +651 ' 8 |});\n' +652 ' 9 |'653 });654 });655 });656 it('Should raise an error if ClientFunction uses async function', function () {657 var testfile = resolve('test/server/data/test-suites/async-function-in-client-fn/testfile.js');658 return compile(testfile)659 .then(function () {660 throw new Error('Promise rejection expected');661 })662 .catch(function (err) {663 assertAPIError(err, {664 stackTop: testfile,665 message: 'Cannot prepare tests due to an error.\n\n' +666 'ClientFunction code, arguments or dependencies cannot contain generators or "async/await" syntax (use Promises instead).',667 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +668 ' 2 |\n' +669 ' 3 |fixture `Test`;\n' +670 ' 4 |\n' +671 ' > 5 |ClientFunction(async function () {\n' +672 ' 6 |});\n' +673 ' 7 |\n' +674 " 8 |test('yo', () => {\n" +675 ' 9 |});\n'676 });677 });678 });679 it('Should raise an error if ClientFunction uses generator', function () {680 var testfile = resolve('test/server/data/test-suites/generator-in-client-fn/testfile.js');681 return compile(testfile)682 .then(function () {683 throw new Error('Promise rejection expected');684 })685 .catch(function (err) {686 assertAPIError(err, {687 stackTop: testfile,688 message: 'Cannot prepare tests due to an error.\n\n' +689 'ClientFunction code, arguments or dependencies cannot contain generators or "async/await" syntax (use Promises instead).',690 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +691 ' 2 |\n' +692 ' 3 |fixture `Test`;\n' +693 ' 4 |\n' +694 ' > 5 |ClientFunction(function* () {\n' +695 ' 6 | yield 1;\n' +696 ' 7 |});\n' +697 ' 8 |\n' +698 " 9 |test('yo', () => {\n" +699 ' 10 |});'700 });701 });702 });703 it('Should raise an error if ClientFunction options is not an object', function () {704 var testfile = resolve('test/server/data/test-suites/client-fn-options-not-object/testfile.js');705 return compile(testfile)706 .then(function () {707 throw new Error('Promise rejection expected');708 })709 .catch(function (err) {710 assertAPIError(err, {711 stackTop: testfile,712 message: 'Cannot prepare tests due to an error.\n\n' +713 '"options" argument is expected to be a non-null object, but it was number.',714 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +715 ' 2 |\n' +716 ' 3 |fixture `Test`;\n' +717 ' 4 |\n' +718 ' > 5 |ClientFunction(() => {}).with(123);\n' +719 ' 6 |\n' +720 " 7 |test('yo', () => {\n" +721 ' 8 |});\n'722 });723 });724 });725 it('Should raise an error if ClientFunction "dependencies" is not an object', function () {726 var testfile = resolve('test/server/data/test-suites/client-fn-dependencies-not-object/testfile.js');727 return compile(testfile)728 .then(function () {729 throw new Error('Promise rejection expected');730 })731 .catch(function (err) {732 assertAPIError(err, {733 stackTop: testfile,734 message: 'Cannot prepare tests due to an error.\n\n' +735 '"dependencies" option is expected to be a non-null object, but it was string.',736 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +737 ' 2 |\n' +738 ' 3 |fixture `Test`;\n' +739 ' 4 |\n' +740 " > 5 |var selectYo = ClientFunction(() => document.querySelector('#yo'), { dependencies: '42' });\n"741 });742 });743 });744 it('Should raise an error if ClientFunction `boundTestRun` option is not TestController', function () {745 var testfile = resolve('test/server/data/test-suites/client-fn-bound-test-run-not-t/testfile.js');746 return compile(testfile)747 .then(function () {748 throw new Error('Promise rejection expected');749 })750 .catch(function (err) {751 assertAPIError(err, {752 stackTop: testfile,753 message: 'Cannot prepare tests due to an error.\n\n' +754 'The "boundTestRun" option value is expected to be a test controller.',755 callsite: " 1 |import { ClientFunction } from 'testcafe';\n" +756 ' 2 |\n' +757 ' 3 |fixture `Test`;\n' +758 ' 4 |\n' +759 " > 5 |ClientFunction(() => {}).with({ boundTestRun: 'yo' });\n" +760 ' 6 |\n' +761 " 7 |test('yo', () => {\n" +762 ' 8 |});'763 });764 });765 });766 it('Should raise an error if TestControllerProxy can not resolve test run', function () {767 var testfile = resolve('test/server/data/test-suites/cant-resolve-test-run-proxy-context/testfile.js');768 return compile(testfile)769 .then(function () {770 throw new Error('Promise rejection expected');771 })772 .catch(function (err) {773 assertAPIError(err, {774 stackTop: testfile,775 message: 'Cannot prepare tests due to an error.\n\n' +776 "Cannot implicitly resolve the test run in the context of which the test controller action should be executed. Use test function's 't' argument instead.",777 callsite: ' 1 |import { t } from \'testcafe\';\n' +778 ' 2 |\n' +779 ' 3 |fixture `Some fixture`;\n' +780 ' 4 |\n' +781 ' > 5 |t.click(\'div\');\n' +782 ' 6 |\n' +783 ' 7 |test(\'Some test\', async () => {\n' +784 ' 8 |\n' +785 ' 9 |});'786 });787 });788 });789 it('Should raise an error if Selector `visibilityCheck` option is not a boolean value', function () {790 var testfile = resolve('test/server/data/test-suites/selector-visibility-check-opt-not-bool/testfile.js');791 return compile(testfile)792 .then(function () {793 throw new Error('Promise rejection expected');794 })795 .catch(function (err) {796 assertAPIError(err, {797 stackTop: testfile,798 message: 'Cannot prepare tests due to an error.\n\n' +799 '"visibilityCheck" option is expected to be a boolean, but it was number.',800 callsite: " 1 |import { Selector } from 'testcafe';\n" +801 ' 2 |\n' +802 ' 3 |fixture `Test`;\n' +803 ' 4 |\n' +804 ' > 5 |Selector(() => {}).with({ visibilityCheck: 42 });\n' +805 ' 6 |\n' +806 " 7 |test('yo', () => {\n" +807 ' 8 |});'808 });809 });810 });811 it('Should raise an error if Selector `timeout` option is not a non-negative number', function () {812 var testfile = resolve('test/server/data/test-suites/selector-timeout-is-not-non-negative-value/testfile.js');813 return compile(testfile)814 .then(function () {815 throw new Error('Promise rejection expected');816 })817 .catch(function (err) {818 assertAPIError(err, {819 stackTop: testfile,820 message: 'Cannot prepare tests due to an error.\n\n' +821 '"timeout" option is expected to be a non-negative number, but it was -5.',822 callsite: " 1 |import { Selector } from 'testcafe';\n" +823 ' 2 |\n' +824 ' 3 |fixture `Test`;\n' +825 ' 4 |\n' +826 ' > 5 |Selector(() => {}).with({ timeout: -5 });\n' +827 ' 6 |\n' +828 " 7 |test('yo', () => {\n" +829 ' 8 |});'830 });831 });832 });833 it('Should raise an error if Selector.nth() `index` argument is not a number', function () {834 var testfile = resolve('test/server/data/test-suites/selector-nth-arg-is-a-number-value/testfile.js');835 return compile(testfile)836 .then(function () {837 throw new Error('Promise rejection expected');838 })839 .catch(function (err) {840 assertAPIError(err, {841 stackTop: testfile,842 message: 'Cannot prepare tests due to an error.\n\n' +843 '"index" argument is expected to be a number, but it was string.',844 callsite: " 1 |import { Selector } from 'testcafe';\n" +845 ' 2 |\n' +846 ' 3 |fixture `Test`;\n' +847 ' 4 |\n' +848 ' > 5 |Selector(() => {}).nth(\'hey\');\n' +849 ' 6 |\n' +850 " 7 |test('yo', () => {\n" +851 ' 8 |});'852 });853 });854 });855 it('Should raise an error if Selector.withText `text` argument is not a RegExp or string', function () {856 var testfile = resolve('test/server/data/test-suites/selector-with-text-arg-is-not-regexp-or-string/testfile.js');857 return compile(testfile)858 .then(function () {859 throw new Error('Promise rejection expected');860 })861 .catch(function (err) {862 assertAPIError(err, {863 stackTop: testfile,864 message: 'Cannot prepare tests due to an error.\n\n' +865 '"text" argument is expected to be a string or a regular expression, but it was object.',866 callsite: " 1 |import { Selector } from 'testcafe';\n" +867 ' 2 |\n' +868 ' 3 |fixture `Test`;\n' +869 ' 4 |\n' +870 ' > 5 |Selector(() => {}).withText({});\n' +871 ' 6 |\n' +872 " 7 |test('yo', () => {\n" +873 ' 8 |});'874 });875 });876 });877 it('Should raise an error if Selector.filter `filter` argument is not a function or string', function () {878 var testfile = resolve('test/server/data/test-suites/selector-filter-arg-is-not-a-function-or-string/testfile.js');879 return compile(testfile)880 .then(function () {881 throw new Error('Promise rejection expected');882 })883 .catch(function (err) {884 assertAPIError(err, {885 stackTop: testfile,886 message: 'Cannot prepare tests due to an error.\n\n' +887 '"filter" argument is expected to be a string or a function, but it was object.',888 callsite: " 1 |import { Selector } from 'testcafe';\n" +889 ' 2 |\n' +890 ' 3 |fixture `Test`;\n' +891 ' 4 |\n' +892 " > 5 |Selector('span').filter({});\n" +893 ' 6 |\n' +894 " 7 |test('yo', () => {\n" +895 ' 8 |});'896 });897 });898 });899 it('Should raise an error if Selector.find `filter` argument is not a function or string', function () {900 var testfile = resolve('test/server/data/test-suites/selector-find-arg-is-not-a-string-or-function/testfile.js');901 return compile(testfile)902 .then(function () {903 throw new Error('Promise rejection expected');904 })905 .catch(function (err) {906 assertAPIError(err, {907 stackTop: testfile,908 message: 'Cannot prepare tests due to an error.\n\n' +909 '"filter" argument is expected to be a string or a function, but it was object.',910 callsite: " 1 |import { Selector } from 'testcafe';\n" +911 ' 2 |\n' +912 ' 3 |fixture `Test`;\n' +913 ' 4 |\n' +914 ' > 5 |Selector(\'span\').find({});\n' +915 ' 6 |\n' +916 " 7 |test('yo', () => {\n" +917 ' 8 |});'918 });919 });920 });921 it('Should raise an error if Selector.parent `filter` argument is not a function or string', function () {922 var testfile = resolve('test/server/data/test-suites/selector-parent-incorrect-arg-type/testfile.js');923 return compile(testfile)924 .then(function () {925 throw new Error('Promise rejection expected');926 })927 .catch(function (err) {928 assertAPIError(err, {929 stackTop: testfile,930 message: 'Cannot prepare tests due to an error.\n\n' +931 '"filter" argument is expected to be a string, function or a number, but it was object.',932 callsite: " 1 |import { Selector } from 'testcafe';\n" +933 ' 2 |\n' +934 ' 3 |fixture `Test`;\n' +935 ' 4 |Selector(\'span\').parent();\n' +936 ' > 5 |Selector(\'span\').parent({});\n' +937 ' 6 |\n' +938 " 7 |test('yo', () => {\n" +939 ' 8 |});'940 });941 });942 });943 it('Should raise an error if Selector.child `filter` argument is not a function or string', function () {944 var testfile = resolve('test/server/data/test-suites/selector-child-incorrect-arg-type/testfile.js');945 return compile(testfile)946 .then(function () {947 throw new Error('Promise rejection expected');948 })949 .catch(function (err) {950 assertAPIError(err, {951 stackTop: testfile,952 message: 'Cannot prepare tests due to an error.\n\n' +953 '"filter" argument is expected to be a string, function or a number, but it was object.',954 callsite: " 1 |import { Selector } from 'testcafe';\n" +955 ' 2 |\n' +956 ' 3 |fixture `Test`;\n' +957 ' 4 |Selector(\'span\').child();\n' +958 ' > 5 |Selector(\'span\').child({});\n' +959 ' 6 |\n' +960 " 7 |test('yo', () => {\n" +961 ' 8 |});'962 });963 });964 });965 it('Should raise an error if Selector.sibling `filter` argument is not a function or string', function () {966 var testfile = resolve('test/server/data/test-suites/selector-sibling-incorrect-arg-type/testfile.js');967 return compile(testfile)968 .then(function () {969 throw new Error('Promise rejection expected');970 })971 .catch(function (err) {972 assertAPIError(err, {973 stackTop: testfile,974 message: 'Cannot prepare tests due to an error.\n\n' +975 '"filter" argument is expected to be a string, function or a number, but it was object.',976 callsite: " 1 |import { Selector } from 'testcafe';\n" +977 ' 2 |\n' +978 ' 3 |fixture `Test`;\n' +979 ' 4 |Selector(\'span\').sibling();\n' +980 ' > 5 |Selector(\'span\').sibling({});\n' +981 ' 6 |\n' +982 " 7 |test('yo', () => {\n" +983 ' 8 |});'984 });985 });986 });987 it('Should raise an error if Selector.nextSibling `filter` argument is not a function or string', function () {988 var testfile = resolve('test/server/data/test-suites/selector-next-sibling-incorrect-arg-type/testfile.js');989 return compile(testfile)990 .then(function () {991 throw new Error('Promise rejection expected');992 })993 .catch(function (err) {994 assertAPIError(err, {995 stackTop: testfile,996 message: 'Cannot prepare tests due to an error.\n\n' +997 '"filter" argument is expected to be a string, function or a number, but it was object.',998 callsite: " 1 |import { Selector } from 'testcafe';\n" +999 ' 2 |\n' +1000 ' 3 |fixture `Test`;\n' +1001 ' 4 |Selector(\'span\').nextSibling();\n' +1002 ' > 5 |Selector(\'span\').nextSibling({});\n' +1003 ' 6 |\n' +1004 " 7 |test('yo', () => {\n" +1005 ' 8 |});'1006 });1007 });1008 });1009 it('Should raise an error if Selector.prevSibling `filter` argument is not a function or string', function () {1010 var testfile = resolve('test/server/data/test-suites/selector-prev-sibling-incorrect-arg-type/testfile.js');1011 return compile(testfile)1012 .then(function () {1013 throw new Error('Promise rejection expected');1014 })1015 .catch(function (err) {1016 assertAPIError(err, {1017 stackTop: testfile,1018 message: 'Cannot prepare tests due to an error.\n\n' +1019 '"filter" argument is expected to be a string, function or a number, but it was object.',1020 callsite: " 1 |import { Selector } from 'testcafe';\n" +1021 ' 2 |\n' +1022 ' 3 |fixture `Test`;\n' +1023 ' 4 |Selector(\'span\').prevSibling();\n' +1024 ' > 5 |Selector(\'span\').prevSibling({});\n' +1025 ' 6 |\n' +1026 " 7 |test('yo', () => {\n" +1027 ' 8 |});'1028 });1029 });1030 });...

Full Screen

Full Screen

phetioAPIValidation.js

Source:phetioAPIValidation.js Github

copy

Full Screen

...92 }93 const phetioID = phetioObject.tandem.phetioID;94 // if it isn't dynamic, then it shouldn't be removed during the lifetime of the sim.95 if ( !phetioObject.phetioDynamicElement ) {96 this.assertAPIError( {97 phetioID: phetioID,98 ruleInViolation: '2. Any static, registered PhetioObject can never be deregistered.'99 } );100 }101 }102 /**103 * Should be called from phetioEngine when a PhetioObject is added to the PhET-iO104 * @param {PhetioObject} phetioObject105 * @public106 */107 onPhetioObjectAdded( phetioObject ) {108 if ( !this.enabled ) {109 return;110 }111 const newPhetioType = phetioObject.phetioType;112 const oldPhetioType = this.everyPhetioType[ newPhetioType.typeName ];113 if ( !oldPhetioType ) { // This may not be necessary, but may be helpful so that we don't overwrite if rule 10 is in violation114 this.everyPhetioType[ newPhetioType.typeName ] = newPhetioType;115 }116 if ( this.simHasStarted ) {117 // Here we need to kick this validation to the next frame to support construction in any order. Parent first, or118 // child first. Use namespace to avoid because timer is a PhetioObject.119 phet.axon.animationFrameTimer.runOnNextTick( () => {120 // The only instances that it's OK to create after startup are "dynamic instances" which are marked as such.121 if ( !phetioObject.phetioDynamicElement ) {122 this.assertAPIError( {123 phetioID: phetioObject.tandem.phetioID,124 ruleInViolation: '1. After startup, only dynamic instances prescribed by the baseline file can be registered.'125 } );126 }127 else {128 // Compare the dynamic element to the archetype if creating them this runtime.129 if ( phet.preloads.phetio.createArchetypes ) {130 const archetypeID = phetioObject.tandem.getArchetypalPhetioID();131 const archetypeMetadata = phet.phetio.phetioEngine.getPhetioObject( archetypeID ).getMetadata();132 // Compare to the simulation-defined archetype133 checkDynamicInstanceAgainstArchetype( this, phetioObject, archetypeMetadata, 'simulation archetype' );134 }135 }136 } );137 }138 }139 /**140 * @private141 */142 validateOverridesFile() {143 // import phetioEngine causes a cycle and cannot be used, hence we must use the namespace144 const entireBaseline = phet.phetio.phetioEngine.getPhetioElementsBaseline();145 for ( const phetioID in window.phet.preloads.phetio.phetioElementsOverrides ) {146 const isArchetype = phetioID.indexOf( DynamicTandem.DYNAMIC_ARCHETYPE_NAME ) >= 0;147 if ( !phet.preloads.phetio.createArchetypes && !entireBaseline.hasOwnProperty( phetioID ) ) {148 assert && assert( isArchetype, `phetioID missing from the baseline that was not an archetype: ${phetioID}` );149 }150 else {151 if ( !entireBaseline.hasOwnProperty( phetioID ) ) {152 this.assertAPIError( {153 phetioID: phetioID,154 ruleInViolation: '3. Any schema entries in the overrides file must exist in the baseline file.',155 message: 'phetioID expected in the baseline file but does not exist'156 } );157 }158 else {159 const override = window.phet.preloads.phetio.phetioElementsOverrides[ phetioID ];160 const baseline = entireBaseline[ phetioID ];161 if ( Object.keys( override ).length === 0 ) {162 this.assertAPIError( {163 phetioID: phetioID,164 ruleInViolation: '4. Any schema entries in the overrides file must be different from its baseline counterpart.',165 message: 'no metadata keys found for this override.'166 } );167 }168 for ( const metadataKey in override ) {169 if ( !baseline.hasOwnProperty( metadataKey ) ) {170 this.assertAPIError( {171 phetioID: phetioID,172 ruleInViolation: '8. Any schema entries in the overrides file must be different from its baseline counterpart.',173 message: `phetioID metadata key not found in the baseline: ${metadataKey}`174 } );175 }176 if ( override[ metadataKey ] === baseline[ metadataKey ] ) {177 this.assertAPIError( {178 phetioID: phetioID,179 ruleInViolation: '8. Any schema entries in the overrides file must be different from its baseline counterpart.',180 message: 'phetioID metadata override value is the same as the corresponding metadata value in the baseline.'181 } );182 }183 }184 }185 }186 }187 }188 /**189 * Assert out the failed API validation rule.190 * @param {Object} apiErrorObject - see doc for this.apiMismatches191 * @private192 */193 assertAPIError( apiErrorObject ) {194 const mismatchMessage = apiErrorObject.phetioID ? `${apiErrorObject.phetioID}: ${apiErrorObject.ruleInViolation}` :195 `${apiErrorObject.ruleInViolation}`;196 console.log( 'error data:', apiErrorObject );197 assert && assert( false, `PhET-iO API error:\n${mismatchMessage}` );198 }199}200/**201 * Compare a dynamic phetioObject's metadata to the expected metadata202 * @param {phetioAPIValidation} phetioAPIValidation203 * @param {PhetioObject} phetioObject204 * @param {Object} archetypeMetadata - from an archetype of the dynamic element205 * @param {string} source - where the archetype came from, for debugging206 */207const checkDynamicInstanceAgainstArchetype = ( phetioAPIValidation, phetioObject, archetypeMetadata, source ) => {208 const actualMetadata = phetioObject.getMetadata();209 KEYS_TO_CHECK.forEach( key => {210 // These attributes are different for archetype vs actual211 if ( key !== 'phetioDynamicElement' && key !== 'phetioArchetypePhetioID' && key !== 'phetioIsArchetype' ) {212 if ( archetypeMetadata[ key ] !== actualMetadata[ key ] ) {213 phetioAPIValidation.assertAPIError( {214 phetioID: phetioObject.tandem.phetioID,215 ruleInViolation: '5. Dynamic element metadata should match the archetype in the API.',216 source: source,217 message: `mismatched metadata: ${key}`218 } );219 }220 }221 } );222};223const phetioAPIValidation = new PhetioAPIValidation();224tandemNamespace.register( 'phetioAPIValidation', phetioAPIValidation );...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1/* ------------ Fixtures/constants ------------ */2var VALID_CONTACT_ID = 3;3var MALFORMED_CONTACT_ID = 'z';4var ContactModel = Backbone.Model.extend({});5CRM.Backbone.extendModel(ContactModel, 'Contact');6CRM.Backbone.trackSaved(ContactModel);7var ContactCollection = Backbone.Collection.extend({8 model: ContactModel9});10CRM.Backbone.extendCollection(ContactCollection);11/* ------------ Assertions ------------ */12/**13 * Assert "result" contains an API error14 * @param result15 */16function assertApiError(result) {17 equal(1, result.is_error, 'Expected error boolean');18 ok(result.error_message.length > 0, 'Expected error message')19}20/**21 * When calling an AJAX operation which should return successfully,22 * make sure that there's no error by setting a callback (error: onUnexpectedError)23 */24function onUnexpectedError(ignore, result) {25 if (result && result.error_message) {26 ok(false, "API returned an unexpected error: " + result.error_message);27 } else {28 ok(false, "API returned an unexpected error: (missing message)");29 }30 start();31}32/**33 * When calling an AJAX operation which should return an error,34 * make sure that there's no success by setting a callback (success: onUnexpectedSuccess)35 */36function onUnexpectedSuccess(ignore) {37 ok(false, "API succeeded - but failure was expected");38 start();39}40/* ------------ Test cases ------------ */41module('model - read');42asyncTest("fetch (ok)", function() {43 var c = new ContactModel({id: VALID_CONTACT_ID});44 c.fetch({45 error: onUnexpectedError,46 success: function() {47 notEqual(-1, _.indexOf(['Individual', 'Household', 'Organization'], c.get('contact_type')), 'Loaded contact with valid contact_type');48 ok(c.get('display_name') != '', 'Loaded contact with valid name');49 start();50 }51 });52});53asyncTest("fetch (error)", function() {54 var c = new ContactModel({id: MALFORMED_CONTACT_ID});55 c.fetch({56 success: onUnexpectedSuccess,57 error: function(model, error) {58 assertApiError(error);59 start();60 }61 });62});63module('model - create');64asyncTest("create/read/delete/read (ok)", function() {65 var TOKEN = new Date().getTime();66 var c1 = new ContactModel({67 contact_type: "Individual",68 first_name: "George" + TOKEN,69 last_name: "Anon" + TOKEN70 });71 equal(c1.isSaved(), false, "");72 // Create the new contact73 c1.save({}, {74 error: onUnexpectedError,75 success: function() {76 equal(c1.get("first_name"), "George" + TOKEN, "save() should return new first name");77 equal(c1.isSaved(), true, "");78 // Fetch the newly created contact79 var c2 = new ContactModel({id: c1.get('id')});80 equal(c2.isSaved(), true, "");81 c2.fetch({82 error: onUnexpectedError,83 success: function() {84 equal(c2.get("first_name"), c1.get("first_name"), "fetch() should return first name");85 equal(c2.isSaved(), true, "");86 // Destroy the newly created contact87 c2.destroy({88 error: onUnexpectedError,89 success: function() {90 equal(c2.isSaved(), true, "");91 // Attempt (but fail) to fetch the deleted contact92 var c3 = new ContactModel({id: c1.get('id')});93 equal(c3.isSaved(), true, "");94 c3.fetch({95 success: onUnexpectedSuccess,96 error: function(model, error) {97 assertApiError(error);98 start();99 }100 }); // fetch101 }102 }); // destroy103 }104 }); // fetch105 }106 }); // save107});108asyncTest("create (error)", function() {109 var TOKEN = new Date().getTime();110 var c1 = new ContactModel({111 // MISSING: contact_type: "Individual",112 first_name: "George" + TOKEN,113 last_name: "Anon" + TOKEN114 });115 // Create the new contact116 c1.save({}, {117 success: onUnexpectedSuccess,118 error: function(model, error) {119 assertApiError(error);120 start();121 }122 });123});124module('model - update');125asyncTest("update (ok)", function() {126 var NICKNAME = "George" + new Date().getTime();127 var c = new ContactModel({id: VALID_CONTACT_ID});128 equal(c.isSaved(), true, "");129 c.set({130 nick_name: NICKNAME131 });132 equal(c.isSaved(), false, "");133 c.save({}, {134 error: onUnexpectedError,135 success: function() {136 equal(c.get("nick_name"), NICKNAME, "save() should return new nickname");137 _.defer(function(){138 equal(c.isSaved(), true, "");139 // read back - make sure the save worked140 var c2 = new ContactModel({id: VALID_CONTACT_ID});141 c2.fetch({142 error: onUnexpectedError,143 success: function() {144 equal(c2.get("nick_name"), NICKNAME, "fetch() should return new nickname");145 start();146 }147 });148 });149 }150 });151});152asyncTest("update (error)", function() {153 var NICKNAME = "George" + new Date().getTime();154 var c = new ContactModel({id: VALID_CONTACT_ID});155 equal(c.isSaved(), true, "");156 c.set({157 contact_type: 'Not-a.va+lidConta(ype'158 });159 equal(c.isSaved(), false, "");160 c.save({}, {161 success: onUnexpectedSuccess,162 error: function(model, error) {163 assertApiError(error);164 _.defer(function(){165 equal(c.isSaved(), false, "");166 start();167 });168 }169 });170});171module('collection - read');172asyncTest("fetch by contact_type (1+ results)", function() {173 var c = new ContactCollection([], {174 crmCriteria: {175 contact_type: 'Organization'176 }177 });178 c.fetch({179 error: onUnexpectedError,180 success: function() {181 ok(c.models.length > 0, "Expected at least one contact");182 c.each(function(model) {183 equal(model.get('contact_type'), 'Organization', 'Expected contact with type organization');184 ok(model.get('display_name') != '', 'Expected contact with valid name');185 });186 start();187 }188 });189});190asyncTest("fetch by crazy name (0 results)", function() {191 var c = new ContactCollection([], {192 crmCriteria: {193 display_name: 'asdf23vmlk2309lk2lkasdk-23ASDF32f'194 }195 });196 c.fetch({197 error: onUnexpectedError,198 success: function() {199 equal(c.models.length, 0, "Expected no contacts");200 start();201 }202 });203});204asyncTest("fetch by malformed ID (error)", function() {205 var c = new ContactCollection([], {206 crmCriteria: {207 id: MALFORMED_CONTACT_ID208 }209 });210 c.fetch({211 success: onUnexpectedSuccess,212 error: function(collection, error) {213 assertApiError(error);214 start();215 }216 });217});218module('findCreate');219asyncTest("findCreate by ID (1 result)", function() {220 CRM.Backbone.findCreate({221 CollectionClass: ContactCollection,222 crmCriteria: {223 id: VALID_CONTACT_ID224 },225 error: onUnexpectedError,226 success: function(model) {227 equal(model.get('id'), VALID_CONTACT_ID);228 ok(model.get('contact_type') != '', 'Expected contact with valid type')229 ok(model.get('id'), 'Expected contact with valid ID')230 start();231 }232 });233});234asyncTest("findCreate by crazy name (0 results) - autocreate", function() {235 CRM.Backbone.findCreate({236 CollectionClass: ContactCollection,237 crmCriteria: {238 organization_name: 'asdf23vmlk2309lk2lkasdk-23ASDF32f'239 },240 defaults: {241 contact_type: 'Organization'242 },243 error: onUnexpectedError,244 success: function(model) {245 equal(model.get('organization_name'), 'asdf23vmlk2309lk2lkasdk-23ASDF32f', 'Expected default values from crmCriteria');246 equal(model.get('contact_type'), 'Organization', 'Expected default values from parameters');247 ok(!model.get('id'), 'Expected contact without valid ID')248 start();249 }250 });251});252asyncTest("findCreate by malformed ID (error)", function() {253 CRM.Backbone.findCreate({254 CollectionClass: ContactCollection,255 crmCriteria: {256 id: MALFORMED_CONTACT_ID257 },258 success: onUnexpectedSuccess,259 error: function(collection, error) {260 assertApiError(error);261 start();262 }263 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { assertAPIError } from 'testcafe-api-error-assertion';2import { Selector } from 'testcafe';3test('My first test', async t => {4 .typeText('#developer-name', 'John Smith')5 .click('#submit-button');6 const articleHeader = await Selector('.result-content').find('h1');7 assertAPIError(articleHeader, 'API Error: Cannot find the specified element.');8});9export function assertAPIError (actual, expected) {10 const actualAPIError = actual.apiError;11 const expectedAPIError = expected;12 assert(actualAPIError, expectedAPIError);13}14export default {15 'API Error: Cannot find the specified element.': {16 }17};18export default class ErrorFormatter {19 constructor (err) {20 this.err = err;21 }22 _formatAPIError () {23 const err = this.err;24 return {25 };26 }27}28export default class TestRunError extends Error {29 constructor (type, callsite, opts) {30 super();31 this.callsite = callsite;32 this.opts = opts;33 this._assignProperties(type);34 }35 _assignProperties (type) {36 const errTemplate = ERROR_TEMPLATES[type];37 if (errTemplate) {38 this.code = errTemplate.code;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ClientFunction } from 'testcafe';2import { assertAPIError } from './apiError';3test('My test', async t => {4 .click('#populate')5 .click('#submit-button');6 await assertAPIError('There was an error submitting the form.');7});8import { Selector } from 'testcafe';9export const assertAPIError = async (expectedError) => {10 const apiError = Selector('#api-error');11 await apiError.with({ visibilityCheck: true })();12 const actualError = await apiError.innerText;13 await t.expect(actualError).contains(expectedError);14};15I have created a separate file apiError.js and imported it in test.js. I have used the method assertAPIError in test.js. I am getting the following error:16import { ClientFunction } from 'testcafe';17import { assertAPIError } from './apiError';18test('My test', async t => {19 .click('#populate')20 .click('#submit-button');21 await assertAPIError('There was an error submitting the form.');22});23import { Selector } from 'testcafe';24export const assertAPIError = async (expectedError) => {25 const apiError = Selector('#api-error');26 await apiError.with({ visibilityCheck: true })();27 const actualError = await apiError.innerText;28 await t.expect(actualError).contains(expectedError);29};30I have created a separate file apiError.js and imported it in test.js. I have used the method assertAPIError in test.js. I am getting the following error:

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2import { assertAPIError } from '../utils/testcafe-asserts';3import { ClientFunction } from 'testcafe';4const getLocation = ClientFunction(() => document.location.href);5test('My Test', async t => {6 await assertAPIError(t, async () => {7 .typeText(Selector('#username'), 'test')8 .typeText(Selector('#password'), 'test')9 .click(Selector('#login'));10 });11 await t.expect(getLocation()).contains('/login');12});13export async function assertAPIError(t, action) {14 try {15 await action();16 } catch (err) {17 await t.expect(err.response.statusCode).eql(401);18 await t.expect(err.response.body.error).eql('invalid_grant');19 await t.expect(err.response.body.error_description).eql('The user name or password is incorrect.');20 }21}22await assertAPIError(t, async () => {23 .typeText(Selector('#username'), 'test')24 .typeText(Selector('#password'), 'test')25 .click(Selector('#login'));

Full Screen

Using AI Code Generation

copy

Full Screen

1import { assertAPIError } from 'testcafe-api-error-helper';2import { assertAPIResponse } from 'testcafe-api-response-helper';3test('API Test', async t => {4 .expect(200);5 assertAPIResponse(response, {6 headers: {7 'content-type': 'application/json; charset=utf-8'8 },9 body: {10 }11 });12 assertAPIError(response, {13 headers: {14 'content-type': 'application/json; charset=utf-8'15 },16 body: {17 },18 error: {19 }20 });21});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { assertAPIError } from './assertAPIError.js';2test('API Error Test', async t => {3 .expect(assertAPIError(404)).ok();4});5export async function assertAPIError(statusCode) {6 const { response } = await t.getBrowserConsoleMessages();7 const apiError = response.filter(r => r.text().includes(`Network error ${statusCode} for`));8 return apiError.length > 0;9}10export async function assertAPIError(statusCode) {11 const { response } = await t.getBrowserConsoleMessages();12 const apiError = response.filter(r => r.text().includes(`Network error ${statusCode} for`));13 return apiError.length > 0;14}15import { Selector, t } from 'testcafe';16fixture('Google search')17test('Google search test', async t => {18 const searchField = Selector('input').withAttribute('name', 'q');19 const searchButton = Selector('input').withAttribute('name', 'btnK');20 .expect(searchField.visible).ok()21 .typeText(searchField, 'testcafe')22 .click(searchButton)23 .expect(Selector('title').innerText).eql('testcafe - Google Search');24});25import { Selector, t } from 'testcafe';26fixture('Google search')27test('Google search test', async t => {28 const searchField = Selector('input').withAttribute('name', 'q');

Full Screen

Using AI Code Generation

copy

Full Screen

1import {assertAPIError} from './assertAPIError.js';2import {Selector} from 'testcafe';3test('Sample Test', async t => {4 .click(Selector('input[type="submit"]'))5 .expect(assertAPIError()).eql(true)6});7import { RequestLogger } from 'testcafe';8const logger = RequestLogger({url: /.*api.*/, method: 'get'}, {9});10export async function assertAPIError() {11 const { response } = await logger.requests[0];12 if (response.statusCode === 200) {13 return true;14 } else {15 return false;16 }17}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { assertAPIError } from './apiError';2test('Sample Test', async t => {3 .typeText('#username', 'admin')4 .typeText('#password', 'admin')5 .click('#login')6 .expect(assertAPIError('Invalid username or password', '#apiError')).ok();7});8import { Selector } from 'testcafe';9export async function assertAPIError(expectedError, selector) {10 const actualError = await Selector(selector).innerText;11 return expectedError === actualError;12}13import { assertAPIError } from './apiError';14test('Sample Test', async t => {15 .typeText('#username', 'admin')16 .typeText('#password', 'admin')17 .click('#login')18 .expect(assertAPIError('Invalid username or password', '#apiError')).ok();19});20import { Selector } from 'testcafe';21export async function assertAPIError(expectedError, selector) {22 const actualError = await Selector(selector).innerText;23 return expectedError === actualError;24}25import { assertAPIError } from './apiError';26test('Sample Test', async t => {27 .typeText('#username', 'admin')28 .typeText('#password', 'admin')29 .click('#login')30 .expect(assertAPIError('Invalid username or password', '#apiError')).ok();31});32import { Selector } from 'testcafe';33export async function assertAPIError(expectedError, selector) {34 const actualError = await Selector(selector).innerText;35 return expectedError === actualError;36}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from "testcafe";2import { assertAPIError } from "testcafe-api-errors";3test("Testcafe API Error", async t => {4 const search = Selector("#lst-ib");5 const searchButton = Selector("button[name='btnK']");6 .typeText(search, "testcafe")7 .click(searchButton)8 .expect(search.exists)9 .ok("Search field does not exist")10 .expect(searchButton.exists)11 .ok("Search button does not exist");12 await assertAPIError(t, "testcafe");13});14import { Selector } from "testcafe";15import { assertAPIError } from "testcafe-api-errors";16test("Testcafe API Error", async t => {17 const search = Selector("#lst-ib");18 const searchButton = Selector("button[name='btnK']");19 .typeText(search, "testcafe")20 .click(searchButton)21 .expect(search.exists)22 .ok("Search field does not exist")23 .expect(searchButton.exists)24 .ok("Search button does not exist");25 await assertAPIError(t, "testcafe");26});27import { Selector } from "testcafe";28import { assertAPIError } from "testcafe-api-errors";29test("Testcafe API Error", async t => {30 const search = Selector("#lst-ib");31 const searchButton = Selector("button[name='btnK']");32 .typeText(search, "testcafe")33 .click(searchButton)34 .expect(search.exists)35 .ok("Search field does not exist")36 .expect(searchButton.exists)37 .ok("Search button does not exist");38 await assertAPIError(t, "testcafe");39});40import { Selector } from "testcafe";41import { assertAPIError

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