How to use expectErrors method in wpt

Best JavaScript code snippet using wpt

basic.spec.ts

Source:basic.spec.ts Github

copy

Full Screen

1/* eslint-disable @typescript-eslint/ban-ts-comment */2/* eslint-disable unused-imports/no-unused-vars-ts */3import * as Joi from 'joi';4import { JoiSchema } from 'joi-class-decorators';5import { fromPairs } from 'lodash';6import { JoiPipe } from 'nestjs-joi';7import { Class } from 'type-fest';8import {9 AdvancedType,10 BasicType,11 BasicTypeWithNoDefaultOptions,12 BasicTypeWithOptions,13 DecoratorExtendedType,14 DecoratorExtendedTypeWithOptions,15 EmptyType,16 ExtendedType,17 ExtendedTypeWithOptions,18 TypeWithNestedType,19 TypeWithNestedTypeAndCustomizer,20 TypeWithNestedTypeArray,21 TypeWithNestedTypeArrayAndArrayCustomizer,22 TypeWithNestedTypeArrayAndCustomizer,23} from '../../fixtures';24describe('basic integration', () => {25 describe('with schema as argument', () => {26 it('should validate against the schema', async () => {27 const pipe = new JoiPipe(28 Joi.object().keys({29 prop: Joi.string(),30 }),31 );32 try {33 pipe.transform(34 {35 prop: 1,36 },37 { type: 'query' },38 );39 throw new Error('should not be thrown');40 } catch (error) {41 expect(error.message).toContain('"prop" must be a string');42 }43 });44 it('should validate against the schema, ignoring groups (positive test)', async () => {45 const pipe = new JoiPipe(46 Joi.object().keys({47 prop: Joi.string(),48 }),49 { group: 'group1' },50 );51 let error;52 try {53 pipe.transform(54 {55 prop: '1',56 },57 { type: 'query' },58 );59 } catch (error_) {60 error = error_;61 }62 expect(error).toBeUndefined();63 });64 it('should validate against the schema, ignoring groups (negative test)', async () => {65 const pipe = new JoiPipe(66 Joi.object().keys({67 prop: Joi.string(),68 }),69 { group: 'group1' },70 );71 try {72 pipe.transform(73 {74 prop: 1,75 },76 { type: 'query' },77 );78 throw new Error('should not be thrown');79 } catch (error) {80 expect(error.message).toContain('"prop" must be a string');81 }82 });83 it('should ignore a metatype passed in the metadata', async () => {84 const pipe = new JoiPipe(85 Joi.object().keys({86 prop: Joi.string(),87 }),88 );89 class metatype {90 @JoiSchema(Joi.number())91 prop!: number;92 }93 try {94 pipe.transform(95 {96 prop: 1,97 },98 { type: 'query', metatype },99 );100 throw new Error('should not be thrown');101 } catch (error) {102 expect(error.message).toContain('"prop" must be a string');103 }104 });105 });106 const CASES: {107 [name: string]: {108 fit?: boolean;109 type: Class;110 opts: { group?: string };111 payload: unknown;112 expectErrors: string[];113 notExpectErrors: string[];114 };115 } = {116 'schema constructed from empty type': {117 type: EmptyType,118 opts: {},119 payload: {},120 expectErrors: [],121 notExpectErrors: [],122 },123 'schema constructed from basic type': {124 type: BasicType,125 opts: {},126 payload: {127 prop1: 'foo',128 },129 expectErrors: ['"prop1" must be [basic_prop1]', '"prop2" is required'],130 notExpectErrors: ['"prop0"'],131 },132 'schema constructed from extended type': {133 type: ExtendedType,134 opts: {},135 payload: {136 prop1: 'foo',137 prop2: 'foo',138 },139 expectErrors: [140 '"prop1" must be [basic_prop1]',141 '"prop2" must be [extended_prop2]',142 '"extendedProp" is required',143 ],144 notExpectErrors: ['"prop0"'],145 },146 'schema constructed from decorator-extended type': {147 type: DecoratorExtendedType,148 opts: {},149 payload: {150 prop1: 'foo',151 prop2: 'foo',152 },153 expectErrors: [154 '"prop1" must be [basic_prop1]',155 '"prop2" must be [decorator_extended_prop2]',156 '"extendedProp" is required',157 ],158 notExpectErrors: ['"prop0"'],159 },160 'schema constructed from basic type, respecting groups': {161 type: BasicType,162 opts: { group: 'group1' },163 payload: {164 prop1: 'foo',165 prop2: 'foo',166 },167 expectErrors: [168 '"prop1" must be [basic_prop1_group1]',169 '"prop2" must be [basic_prop2_group1]',170 ],171 notExpectErrors: ['"prop0"'],172 },173 'schema constructed from basic type, falling back to default group': {174 type: BasicType,175 opts: { group: 'groupX' },176 payload: {177 prop1: 'foo',178 prop2: 'foo',179 },180 expectErrors: ['"prop1" must be [basic_prop1]', '"prop2" must be [basic_prop2]'],181 notExpectErrors: ['"prop0"'],182 },183 'schema constructed from extended type, respecting groups': {184 type: ExtendedType,185 opts: { group: 'group1' },186 payload: {187 prop1: 'foo',188 prop2: 'foo',189 extendedProp: 'foo',190 },191 expectErrors: [192 '"prop1" must be [basic_prop1_group1]',193 '"prop2" must be [extended_prop2_group1]',194 '"extendedProp" must be [extended_extendedProp_group1]',195 ],196 notExpectErrors: ['"prop0"'],197 },198 'schema constructed from decorator-extended type, respecting groups': {199 type: DecoratorExtendedType,200 opts: { group: 'group1' },201 payload: {202 prop1: 'foo',203 prop2: 'foo',204 extendedProp: 'foo',205 },206 expectErrors: [207 '"prop1" must be [basic_prop1_group1]',208 '"prop2" must be [decorator_extended_prop2_group1]',209 '"extendedProp" must be [decorator_extended_extendedProp_group1]',210 ],211 notExpectErrors: ['"prop0"'],212 },213 'schema constructed from advanced type (positive, alternative 1)': {214 type: AdvancedType,215 opts: {},216 payload: {217 prop: {218 prop1: 'basic_prop1',219 prop2: 'basic_prop2',220 },221 },222 expectErrors: [],223 notExpectErrors: ['"prop"'],224 },225 'schema constructed from advanced type (positive, alternative 2)': {226 type: AdvancedType,227 opts: {},228 payload: {229 prop: {230 prop1: 'basic_prop1',231 prop2: 'extended_prop2',232 extendedProp: 'extended_extendedProp',233 },234 },235 expectErrors: [],236 notExpectErrors: ['"prop"'],237 },238 'schema constructed from advanced type (negative)': {239 type: AdvancedType,240 opts: {},241 payload: {242 prop: {243 prop1: 'basic_prop1',244 },245 },246 expectErrors: ['"prop" does not match any of the allowed types'],247 notExpectErrors: [],248 },249 'schema constructed from basic type with options': {250 type: BasicTypeWithOptions,251 opts: {},252 payload: {253 prop: 'basicwithoptions_prop',254 unknownProp: 'string',255 },256 expectErrors: ['"unknownProp" is not allowed'],257 notExpectErrors: [],258 },259 'schema constructed from extended type with options': {260 type: ExtendedTypeWithOptions,261 opts: {},262 payload: {263 prop: 'basicwithoptions_prop',264 unknownProp: 'string',265 },266 expectErrors: [],267 notExpectErrors: [],268 },269 'schema constructed from decorator-extended type with options': {270 type: DecoratorExtendedTypeWithOptions,271 opts: {},272 payload: {273 prop: 'basicwithoptions_prop',274 unknownProp: 'string',275 },276 expectErrors: [],277 notExpectErrors: [],278 },279 'schema constructed from basic type with options, respecting groups': {280 type: BasicTypeWithOptions,281 opts: { group: 'group1' },282 payload: {283 prop: 'basicwithoptions_prop',284 unknownProp: 'string',285 },286 expectErrors: [],287 notExpectErrors: [],288 },289 'schema constructed from extended type with options, respecting groups': {290 type: ExtendedTypeWithOptions,291 opts: { group: 'group1' },292 payload: {293 prop: 'basicwithoptions_prop',294 unknownProp: 'string',295 },296 expectErrors: ['"unknownProp" is not allowed'],297 notExpectErrors: [],298 },299 'schema constructed from decorator-extended type with options, respecting groups': {300 type: DecoratorExtendedTypeWithOptions,301 opts: { group: 'group1' },302 payload: {303 prop: 'basicwithoptions_prop',304 unknownProp: 'string',305 },306 expectErrors: ['"unknownProp" is not allowed'],307 notExpectErrors: [],308 },309 'schema constructed from basic type with no default options': {310 type: BasicTypeWithNoDefaultOptions,311 opts: {},312 payload: {313 prop1: 'string',314 prop2: 'string',315 },316 expectErrors: [317 '"prop1" must be [basicwithnodefaultoptions_prop1]',318 '"prop2" must be [basicwithnodefaultoptions_prop2]',319 ],320 notExpectErrors: [],321 },322 'schema constructed from basic type with no default options, respecting groups': {323 type: BasicTypeWithNoDefaultOptions,324 opts: { group: 'group1' },325 payload: {326 prop1: 'string',327 prop2: 'string',328 },329 expectErrors: ['"prop1" must be [basicwithnodefaultoptions_prop1_group1]'],330 notExpectErrors: ['"prop2" must be [basicwithnodefaultoptions_prop2_group1]'],331 },332 'schema constructed from type with nested type (negative)': {333 type: TypeWithNestedType,334 opts: {},335 payload: {336 prop0: 'string',337 prop1: 'string',338 nestedProp: {339 prop1: 'string',340 prop2: 'string',341 },342 },343 expectErrors: [344 '"prop1" must be [nested_prop1]',345 '"nestedProp.prop1" must be [basic_prop1]',346 '"nestedProp.prop2" must be [basic_prop2]',347 ],348 notExpectErrors: ['"prop0"', 'nestedTypeWithFn'],349 },350 'schema constructed from type with nested type (positive)': {351 type: TypeWithNestedType,352 opts: {},353 payload: {354 prop0: 'string',355 prop1: 'nested_prop1',356 nestedProp: {357 prop1: 'basic_prop1',358 prop2: 'basic_prop2',359 },360 },361 expectErrors: [],362 notExpectErrors: ['"prop0"', '"prop1"', '"nestedProp.prop1"', '"nestedProp.prop2"'],363 },364 'schema constructed from type with nested type, respecting groups (negative)': {365 type: TypeWithNestedType,366 opts: { group: 'group1' },367 payload: {368 prop0: 'string',369 prop1: 'string',370 nestedProp: {371 prop1: 'string',372 prop2: 'string',373 extendedProp: 'string',374 },375 },376 expectErrors: [377 '"prop1" must be [nested_prop1_group1]',378 '"nestedProp.prop1" must be [basic_prop1_group1]',379 '"nestedProp.prop2" must be [extended_prop2_group1]',380 '"nestedProp.extendedProp" must be [extended_extendedProp_group1]',381 ],382 notExpectErrors: ['"prop0"', 'nestedTypeWithFn'],383 },384 'schema constructed from type with nested type, respecting groups (positive)': {385 type: TypeWithNestedType,386 opts: { group: 'group1' },387 payload: {388 prop0: 'string',389 prop1: 'nested_prop1_group1',390 nestedProp: {391 prop1: 'basic_prop1_group1',392 prop2: 'extended_prop2_group1',393 extendedProp: 'extended_extendedProp_group1',394 },395 },396 expectErrors: [],397 notExpectErrors: [398 '"prop0"',399 '"prop1"',400 '"nestedProp.prop1"',401 '"nestedProp.prop2"',402 '"nestedProp.extendedProp"',403 ],404 },405 'schema constructed from type with nested type array (negative)': {406 type: TypeWithNestedTypeArray,407 opts: {},408 payload: {409 prop0: 'string',410 prop1: 'string',411 nestedProp: [412 {413 prop1: 'string',414 prop2: 'string',415 },416 ],417 },418 expectErrors: [419 '"prop1" must be [nested_array_prop1]',420 '"nestedProp[0].prop1" must be [basic_prop1]',421 '"nestedProp[0].prop2" must be [basic_prop2]',422 ],423 notExpectErrors: ['"prop0"'],424 },425 'schema constructed from type with nested type array (positive)': {426 type: TypeWithNestedTypeArray,427 opts: {},428 payload: {429 prop0: 'string',430 prop1: 'nested_array_prop1',431 nestedProp: [432 {433 prop1: 'basic_prop1',434 prop2: 'basic_prop2',435 },436 ],437 },438 expectErrors: [],439 notExpectErrors: [440 '"prop0"',441 '"prop1"',442 '"nestedProp[0].prop1"',443 '"nestedProp[0].prop2"',444 '"nestedProp[0].extendedProp"',445 ],446 },447 'schema constructed from type with nested type array, respecting groups (negative)': {448 type: TypeWithNestedTypeArray,449 opts: { group: 'group1' },450 payload: {451 prop0: 'string',452 prop1: 'string',453 nestedProp: [454 {455 prop1: 'string',456 prop2: 'string',457 extendedProp: 'string',458 },459 ],460 },461 expectErrors: [462 '"prop1" must be [nested_array_prop1_group1]',463 '"nestedProp[0].prop1" must be [basic_prop1_group1]',464 '"nestedProp[0].prop2" must be [extended_prop2_group1]',465 '"nestedProp[0].extendedProp" must be [extended_extendedProp_group1]',466 ],467 notExpectErrors: ['"prop0"'],468 },469 'schema constructed from type with nested type array, respecting groups (positive)': {470 type: TypeWithNestedTypeArray,471 opts: { group: 'group1' },472 payload: {473 prop0: 'string',474 prop1: 'nested_array_prop1_group1',475 nestedProp: [476 {477 prop1: 'basic_prop1_group1',478 prop2: 'extended_prop2_group1',479 extendedProp: 'extended_extendedProp_group1',480 },481 ],482 },483 expectErrors: [],484 notExpectErrors: [485 '"prop0"',486 '"prop1"',487 '"nestedProp[0].prop1"',488 '"nestedProp[0].prop2"',489 '"nestedProp[0].extendedProp"',490 ],491 },492 'schema constructed from type with nested type and customizer (positive)': {493 type: TypeWithNestedTypeAndCustomizer,494 opts: {},495 payload: {496 nestedProp: undefined,497 },498 expectErrors: [],499 notExpectErrors: ['"nestedProp"'],500 },501 'schema constructed from type with nested type and customizer (negative)': {502 type: TypeWithNestedTypeAndCustomizer,503 opts: {},504 payload: {505 nestedProp: {506 prop1: 'string',507 prop2: 'string',508 },509 },510 expectErrors: [511 '"nestedProp.prop1" must be [basic_prop1]',512 '"nestedProp.prop2" must be [basic_prop2]',513 ],514 notExpectErrors: [],515 },516 'schema constructed from type with nested type and customizer, respecting groups (negative)': {517 type: TypeWithNestedTypeAndCustomizer,518 opts: { group: 'group1' },519 payload: {520 nestedProp: undefined,521 },522 expectErrors: ['"nestedProp" is required'],523 notExpectErrors: [],524 },525 'schema constructed from type with nested type and customizer, respecting groups (positive)': {526 type: TypeWithNestedTypeAndCustomizer,527 opts: { group: 'group1' },528 payload: {529 nestedProp: {530 prop1: 'basic_prop1_group1',531 prop2: 'basic_prop2_group1',532 },533 },534 expectErrors: [],535 notExpectErrors: ['"nestedProp"'],536 },537 'schema constructed from type with nested type array and array customizer (positive)': {538 type: TypeWithNestedTypeArrayAndArrayCustomizer,539 opts: {},540 payload: {541 nestedProp: undefined,542 },543 expectErrors: [],544 notExpectErrors: ['"nestedProp"'],545 },546 'schema constructed from type with nested type array and array customizer (negative)': {547 type: TypeWithNestedTypeArrayAndArrayCustomizer,548 opts: {},549 payload: {550 nestedProp: [551 {552 prop1: 'string',553 prop2: 'string',554 },555 ],556 },557 expectErrors: [558 '"nestedProp[0].prop1" must be [basic_prop1]',559 '"nestedProp[0].prop2" must be [basic_prop2]',560 ],561 notExpectErrors: [],562 },563 'schema constructed from type with nested type array and array customizer, respecting groups (negative)':564 {565 type: TypeWithNestedTypeArrayAndArrayCustomizer,566 opts: { group: 'group1' },567 payload: {568 nestedProp: undefined,569 },570 expectErrors: ['"nestedProp" is required'],571 notExpectErrors: [],572 },573 'schema constructed from type with nested type array and array customizer, respecting groups (positive)':574 {575 type: TypeWithNestedTypeArrayAndArrayCustomizer,576 opts: { group: 'group1' },577 payload: {578 nestedProp: [579 {580 prop1: 'basic_prop1_group1',581 prop2: 'basic_prop2_group1',582 },583 ],584 },585 expectErrors: [],586 notExpectErrors: ['"nestedProp"'],587 },588 'schema constructed from type with nested type array and customizer (positive)': {589 type: TypeWithNestedTypeArrayAndCustomizer,590 opts: {},591 payload: {592 nestedProp: [],593 },594 expectErrors: [],595 notExpectErrors: ['"nestedProp"'],596 },597 'schema constructed from type with nested type array and customizer (negative)': {598 type: TypeWithNestedTypeArrayAndCustomizer,599 opts: {},600 payload: {601 nestedProp: [602 {603 prop1: 'string',604 prop2: 'string',605 },606 ],607 },608 expectErrors: [609 '"nestedProp[0].prop1" must be [basic_prop1]',610 '"nestedProp[0].prop2" must be [basic_prop2]',611 ],612 notExpectErrors: [],613 },614 'schema constructed from type with nested type array and customizer, respecting groups (negative)':615 {616 type: TypeWithNestedTypeArrayAndCustomizer,617 opts: { group: 'group1' },618 payload: {619 nestedProp: [],620 },621 expectErrors: ['"nestedProp" does not contain 1 required value'],622 notExpectErrors: [],623 },624 'schema constructed from type with nested type array and customizer, respecting groups (positive)':625 {626 type: TypeWithNestedTypeArrayAndCustomizer,627 opts: { group: 'group1' },628 payload: {629 nestedProp: [630 {631 prop1: 'basic_prop1_group1',632 prop2: 'basic_prop2_group1',633 },634 ],635 },636 expectErrors: [],637 notExpectErrors: ['"nestedProp"'],638 },639 'nothing: empty schema without @JoiSchema': {640 type: EmptyType,641 opts: {},642 payload: {643 prop: 'basicwithoptions_prop',644 unknownProp: 'string',645 },646 expectErrors: [],647 notExpectErrors: [],648 },649 // Special inbuilt types: construct cases650 ...fromPairs(651 [String, Object, Number, Array].map(type => [652 'nothing: handle inbuilt type ' + type.name,653 {654 type,655 opts: {},656 payload: {657 prop: 'basicwithoptions_prop',658 unknownProp: 'string',659 },660 expectErrors: [],661 },662 ]),663 ),664 };665 for (const mode of ['type', 'metatype']) {666 describe('with ' + mode + ' as argument', () => {667 for (const [668 caseName,669 { fit: useFit, type, opts, payload, expectErrors, notExpectErrors },670 ] of Object.entries(CASES)) {671 (useFit ? fit : it)('should validate against ' + caseName, async () => {672 const pipe = mode === 'type' ? new JoiPipe(type, opts) : new JoiPipe(opts);673 let error_;674 try {675 pipe.transform(payload, {676 type: 'query',677 metatype: mode === 'metatype' ? type : undefined,678 });679 if (expectErrors && expectErrors.length) {680 throw new Error('should not be thrown');681 }682 } catch (error) {683 error_ = error;684 if (expectErrors && expectErrors.length) {685 expectErrors.map(x => expect(error.stack).toContain(x));686 }687 if (notExpectErrors && notExpectErrors.length) {688 notExpectErrors.map(x => expect(error.stack).not.toContain(x));689 }690 }691 if (!expectErrors || !expectErrors.length) {692 expect(error_).toBeUndefined();693 }694 });695 }696 });697 }...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...55 *************************/56// assert stacktrace shows line of failure57executor.addCommandlineTest('node lib/cli.js spec/errorTest/singleFailureConf.js')58 .expectExitCode(1)59 .expectErrors({60 stackTrace: 'single_failure_spec1.js:5:32'61 });62// assert timeout works63executor.addCommandlineTest('node lib/cli.js spec/errorTest/timeoutConf.js')64 .expectExitCode(1)65 .expectErrors({66 message: 'Timeout - Async callback was not invoked within timeout ' +67 'specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'68 })69 .expectTestDuration(0, 100);70executor.addCommandlineTest('node lib/cli.js spec/errorTest/afterLaunchChangesExitCodeConf.js')71 .expectExitCode(11)72 .expectErrors({73 message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.'74 });75executor.addCommandlineTest('node lib/cli.js spec/errorTest/multiFailureConf.js')76 .expectExitCode(1)77 .expectErrors([{78 message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',79 stacktrace: 'single_failure_spec1.js:5:32'80 }, {81 message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',82 stacktrace: 'single_failure_spec2.js:5:32'83 }]);84executor.addCommandlineTest('node lib/cli.js spec/errorTest/shardedFailureConf.js')85 .expectExitCode(1)86 .expectErrors([{87 message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',88 stacktrace: 'single_failure_spec1.js:5:32'89 }, {90 message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.',91 stacktrace: 'single_failure_spec2.js:5:32'92 }]);93executor.addCommandlineTest('node lib/cli.js spec/errorTest/mochaFailureConf.js')94 .expectExitCode(1)95 .expectErrors([{96 message: 'expected \'My AngularJS App\' to equal \'INTENTIONALLY INCORRECT\'',97 stacktrace: 'mocha_failure_spec.js:11:20'98 }]);99executor.addCommandlineTest('node lib/cli.js spec/errorTest/pluginsFailingConf.js')100 .expectExitCode(1)101 .expectErrors([102 {message: 'Expected true to be false'},103 {message: 'from setup'},104 {message: 'from postTest passing'},105 {message: 'from postTest failing'},106 {message: 'from teardown'}107 ]);108executor.addCommandlineTest('node lib/cli.js spec/errorTest/slowHttpAndTimeoutConf.js')109 .expectExitCode(1)110 .expectErrors([111 {message: 'The following tasks were pending[\\s\\S]*\\$http: \/slowcall'},112 {message: 'The following tasks were pending[\\s\\S]*' + 113 '\\$timeout: function \\(\\) {[\\s\\S]*' + 114 '\\$scope\\.slowAngularTimeoutStatus = \'done\';[\\s\\S]' + 115 '*}'}116 ]);117// Check ngHint plugin118executor.addCommandlineTest(119 'node lib/cli.js plugins/ngHint/spec/failureConfig.js')120 .expectExitCode(1)121 .expectErrors([{122 message: 'warning -- ngHint plugin cannot be run as ngHint code was ' +123 'never included into the page'124 }, {125 message: 'warning -- ngHint is included on the page, but is not active ' +126 'because there is no `ng-hint` attribute present'127 }, {128 message: 'warning -- Module "xApp" was created but never loaded.'129 }]);130// Check accessibility plugin131executor.addCommandlineTest(132 'node lib/cli.js plugins/accessibility/spec/failureConfig.js')133 .expectExitCode(1)134 .expectErrors([{135 message: '3 elements failed:'136 },137 {138 message: '1 element failed:'139 }]);140// Check console plugin141executor.addCommandlineTest(142 'node lib/cli.js plugins/console/spec/consoleFailConfig.js')143 .expectExitCode(1)144 .expectErrors([145 {message: 'This is a test warning'},146 {message: 'This is a test error'},147 {message: 'This should be filtered out by string'},148 {message: 'This should be filtered out by regex'}149 ]);150executor.addCommandlineTest(151 'node lib/cli.js plugins/console/spec/consoleFailErrorConfig.js')152 .expectExitCode(1)153 .expectErrors([154 {message: 'This is a test error'},155 {message: 'This should be filtered out by string'},156 {message: 'This should be filtered out by regex'}157 ]);158executor.addCommandlineTest(159 'node lib/cli.js plugins/console/spec/consoleFailWarningConfig.js')160 .expectExitCode(1)161 .expectErrors([162 {message: 'This is a test warning'}163 ]);164executor.addCommandlineTest(165 'node lib/cli.js plugins/console/spec/consoleFailFilterConfig.js')166 .expectExitCode(1)167 .expectErrors([168 {message: 'This is a test error'}169 ]);...

Full Screen

Full Screen

main.spec.ts

Source:main.spec.ts Github

copy

Full Screen

...39 // a new note should be valid40 const obj = new ActivityStreams.StreamObject();41 // const expectErrors = async () => expect((await validate(obj)).length).toBeGreaterThan(0);42 const expectErrors = async (count: number) => expect(await validate(obj)).toHaveLength(count);43 expectErrors(0);44 // obj with ID should be valid45 obj.id = "https://yuforium.com/users/chris/note-123";46 expectErrors(0);47 // obj with invalid URL should fail48 obj.id = 'some-id';49 expectErrors(1);50 // @ts-ignore a new note with invalid id51 obj.id = 5;52 expectErrors(1);53 // @ts-ignore a new note with invalid id54 obj.id = ["https://yuforium.com/users/chris/note-123"];55 expectErrors(1);56 });57});58describe('basic type validation', () => {59 it('should pass basic validation', async () => {60 let errs: any[];61 const obj = new ActivityStreams.StreamObject();62 const expectErrors = async (count: number) => expect(await validate(obj)).toHaveLength(count);63 obj.type = "Object";64 expectErrors(0);65 obj.type = ["Object", "test:Object"];66 expectErrors(0);67 obj.type = [];68 expectErrors(1);69 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = wpt('www.webpagetest.org');3var options = {4 videoParams: {5 }6};7test.runTest(options, function(err, data) {8 if (err) return console.log(err);9 console.log('Test ID: %s', data.data.testId);10 test.getTestResults(data.data.testId, function(err, data) {11 if (err) return console.log(err);12 console.log(data.data.median.firstView.SpeedIndex);13 });14});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt-runner');2var expect = require('chai').expect;3wpt.expectErrors(function() {4 expect(1).to.equal(2);5}, 1);6wpt.expectErrors(function() {7 expect(1).to.equal(2);8}, 2);9wpt.expectErrors(function() {10 expect(1).to.equal(2);11}, 0);

Full Screen

Using AI Code Generation

copy

Full Screen

1var expect = require('chai').expect;2var assert = require('chai').assert;3describe('WPT Runner', function () {4 it('should be able to run WPT tests', function () {5 browser.expectErrors = true;6 browser.expect.element('body').to.be.present;7 browser.expect.element('body').to.be.present.before(1000);8 browser.expect.element('body').to.be.present.after(1000);9 browser.expect.element('body').to.be.visible;10 browser.expect.element('body').to.be.visible.before(1000);11 browser.expect.element('body').to.be.visible.after(1000);12 browser.expect.element('body').to.be.an('element');13 browser.expect.element('body').to.be.an('element').before(1000);14 browser.expect.element('body').to.be.an('element').after(1000);15 browser.expect.element('body').to.have.attribute('class').which.contains('vasq');16 browser.expect.element('body').to.have.attribute('class').which.contains('vasq').before(1000);17 browser.expect.element('body').to.have.attribute('class').which.contains('vasq').after(1000);18 browser.expect.element('body').to.have.attribute('class').which.matches(/vasq/);19 browser.expect.element('body').to.have.attribute('class').which.matches(/vasq/).before(1000);20 browser.expect.element('body').to.have.attribute('class').which.matches(/vasq/).after(1000);21 browser.expect.element('body').to.have.attribute('class').before(1000);22 browser.expect.element('body').to.have.attribute('class').after(1000);23 browser.expect.element('body').to.have.attribute('class');24 browser.expect.element('body').to.have.css('display');25 browser.expect.element('body').to.have.css('display').which.equals('block');26 browser.expect.element('body').to.have.css('display').which.equals('block').before(1000);27 browser.expect.element('body').to.have.css('display').which.equals('block').after(1000);28 browser.expect.element('body').to.have.css('display').before(1000);29 browser.expect.element('body').to.have.css('display').after(1000);30 browser.expect.element('body').to

Full Screen

Using AI Code Generation

copy

Full Screen

1var expect = require('chai').expect;2var expectErrors = require('expect-errors');3expectErrors.expectErrors(2, function(){4 var errors = 0;5 var error = document.createElement('p');6 error.className = 'error';7 document.body.appendChild(error);8 if(document.getElementsByClassName('error').length > 0){9 errors += 1;10 }11 var error = document.createElement('p');12 error.className = 'error';13 document.body.appendChild(error);14 if(document.getElementsByClassName('error').length > 0){15 errors += 1;16 }17 return errors;18});19var expect = require('chai').expect;20var expectErrors = require('expect-errors');21expectErrors.expectErrors(2, function(){22 var errors = 0;23 var error = document.createElement('p');24 error.className = 'error';25 document.body.appendChild(error);26 if(document.getElementsByClassName('error').length > 0){27 errors += 1;28 }29 var error = document.createElement('p');30 error.className = 'error';31 document.body.appendChild(error);32 if(document.getElementsByClassName('error').length > 0){33 errors += 1;34 }35 return errors;36});37var expect = require('chai').expect;38var expectErrors = require('expect-errors');39expectErrors.expectErrors(2, function(){40 var errors = 0;41 var error = document.createElement('p');42 error.className = 'error';43 document.body.appendChild(error);44 if(document.getElementsByClassName('error').length > 0){

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var test = new wpt(options);5var params = {6 videoParams: { 'fps': 30, 'quality': 10 }7};8test.runTest(url, params, function(err, data) {9 if (err) return console.error(err);10 console.log('Test submitted. Polling for results...');11 test.waitForTest(data.data.testId, function(err, data) {12 if (err) return console.error(err);13 console.log('Got test results: %j', data);14 var testId = data.data.testId;15 var firstView = data.data.runs[1].firstView;16 var errors = firstView.result;17 var testURL = firstView.url;18 var testLocation = firstView.location;19 var testDateTime = firstView.completed;20 console.log('Test ID: %s', testId);21 console.log('Test URL: %s', testURL);22 console.log('Test Location: %s', testLocation);23 console.log('Test Completed: %s', testDateTime);24 console.log('Errors: %j', errors);25 });26});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webpagetest = new wpt('A.8d6c0d6a4f6d2c2a8f7a4e6e1b7e8c0d');3webpagetest.expectErrors(testUrl, { runs: 3, location: 'Dulles:Chrome' }, function(err, data) {4 if (err) console.error(err);5 console.log(data);6});7var wpt = require('webpagetest');8var webpagetest = new wpt('A.8d6c0d6a4f6d2c2a8f7a4e6e1b7e8c0d');9webpagetest.expectErrors(testUrl, { runs: 3, location: 'Dulles:Chrome' }, function(err, data) {10 if (err) console.error(err);11 console.log(data);12});13var wpt = require('webpagetest');14var webpagetest = new wpt('A.8d6c0d6a4f6d2c2a8f7a4e6e1b7e8c0d');15webpagetest.getLocations(function(err, data) {16 if (err) console.error(err);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful