How to use validateOptionalIdField method in wpt

Best JavaScript code snippet using wpt

RTCStats-helper.js

Source:RTCStats-helper.js Github

copy

Full Screen

...100 const linkedStats = getStatsById(statsReport, stats[field]);101 assert_equals(linkedStats.type, type,102 `Expect linked stats object to have type ${type}`);103}104function validateOptionalIdField(statsReport, stats, field, type) {105 if(stats[field] !== undefined) {106 validateIdField(statsReport, stats, field, type);107 }108}109/*110 [webrtc-pc]111 8.4. RTCStats Dictionary112 dictionary RTCStats {113 required DOMHighResTimeStamp timestamp;114 required RTCStatsType type;115 required DOMString id;116 };117 */118function validateRtcStats(statsReport, stats) {119 assert_number_field(stats, 'timeStamp');120 assert_string_field(stats, 'type');121 assert_string_field(stats, 'id');122}123/*124 [webrtc-stats]125 7.1. RTCRTPStreamStats dictionary126 dictionary RTCRTPStreamStats : RTCStats {127 required unsigned long ssrc;128 required DOMString mediaType;129 [RTCMediaStreamTrackStats]130 required DOMString trackId;131 [RTCTransportStats]132 required DOMString transportId;133 [RTCCodecStats]134 required DOMString codecId;135 unsigned long firCount;136 unsigned long pliCount;137 required unsigned long nackCount;138 unsigned long sliCount;139 unsigned long long qpSum;140 };141 [webrtc-pc]142 8.6. Mandatory To Implement Stats143 - RTCRTPStreamStats, with attributes ssrc, associateStatsId, isRemote, mediaType,144 mediaTrackId, transportId, codecId, nackCount145 */146function validateRtpStreamStats(statsReport, stats) {147 validateRtcStats(statsReport, stats);148 assert_unsigned_int_field(stats, 'ssrc');149 assert_string_field(stats, 'mediaType');150 validateIdField(statsReport, stats, 'trackId', 'track');151 validateIdField(statsReport, stats, 'transportId', 'transport');152 validateIdField(statsReport, stats, 'codecId', 'codec');153 assert_optional_unsigned_int_field(stats, 'firCount');154 assert_optional_unsigned_int_field(stats, 'pliCount');155 assert_unsigned_int_field(stats, 'nackCount');156 assert_optional_unsigned_int_field(stats, 'sliCount');157 assert_optional_unsigned_int_field(stats, 'qpSum');158}159/*160 [webrtc-stats]161 7.2. RTCCodecStats dictionary162 dictionary RTCCodecStats : RTCStats {163 required unsigned long payloadType;164 required RTCCodecType codecType;165 [RTCTransportStats]166 DOMString transportId;167 DOMString mimeType;168 required unsigned long clockRate;169 required unsigned long channels;170 DOMString sdpFmtpLine;171 DOMString implementation;172 };173 enum RTCCodecType {174 "encode",175 "decode",176 };177 [webrtc-pc]178 8.6. Mandatory To Implement Stats179 - RTCCodecStats, with attributes payloadType, codec, clockRate, channels, parameters180 */181function validateCodecStats(statsReport, stats) {182 validateRtcStats(statsReport, stats);183 assert_unsigned_int_field(stats, 'payloadType');184 assert_enum_field(stats, 'codecType', ['encode', 'decode']);185 validateOptionalIdField(statsReport, stats, 'transportId', 'transport');186 assert_optional_string_field(stats, 'mimeType');187 assert_unsigned_int_field(stats, 'clockRate');188 assert_unsigned_int_field(stats, 'channels');189 assert_optional_string_field(stats, 'sdpFmtpLine');190 assert_optional_string_field(stats, 'implementation');191}192/*193 [webrtc-stats]194 7.3. RTCReceivedRTPStreamStats dictionary195 dictionary RTCReceivedRTPStreamStats : RTCRTPStreamStats {196 unsigned long packetsReceived;197 unsigned long long bytesReceived;198 unsigned long packetsLost;199 double jitter;200 double fractionLost;201 unsigned long packetsDiscarded;202 unsigned long packetsRepaired;203 unsigned long burstPacketsLost;204 unsigned long burstPacketsDiscarded;205 unsigned long burstLossCount;206 unsigned long burstDiscardCount;207 double burstLossRate;208 double burstDiscardRate;209 double gapLossRate;210 double gapDiscardRate;211 };212 */213function validateReceivedRtpStreamStats(statsReport, stats) {214 validateRtpStreamStats(statsReport, stats);215 assert_optional_unsigned_int_field(stats, 'packetsReceived');216 assert_optional_unsigned_int_field(stats, 'bytesReceived');217 assert_optional_unsigned_int_field(stats, 'packetsLost');218 assert_optional_number_field(stats, 'jitter');219 assert_optional_number_field(stats, 'fractionLost');220 assert_optional_unsigned_int_field(stats, 'packetsDiscarded');221 assert_optional_unsigned_int_field(stats, 'packetsRepaired');222 assert_optional_unsigned_int_field(stats, 'burstPacketsLost');223 assert_optional_unsigned_int_field(stats, 'burstPacketsDiscarded');224 assert_optional_unsigned_int_field(stats, 'burstLossCount');225 assert_optional_unsigned_int_field(stats, 'burstDiscardCount');226 assert_optional_number_field(stats, 'burstLossRate');227 assert_optional_number_field(stats, 'burstDiscardRate');228 assert_optional_number_field(stats, 'gapLossRate');229 assert_optional_number_field(stats, 'gapDiscardRate');230}231/*232 [webrtc-stats]233 7.4. RTCInboundRTPStreamStats dictionary234 dictionary RTCInboundRTPStreamStats : RTCReceivedRTPStreamStats {235 required unsigned long packetsReceived;236 required unsigned long long bytesReceived;237 required unsigned long packetsLost;238 required double jitter;239 required unsigned long packetsDiscarded;240 [RTCRemoteOutboundRTPStreamStats]241 DOMString remoteId;242 unsigned long framesDecoded;243 DOMHighResTimeStamp lastPacketReceivedTimestamp;244 };245 [webrtc-pc]246 8.6. Mandatory To Implement Stats247 - RTCInboundRTPStreamStats, with all required attributes from RTCRTPStreamStats,248 and also attributes packetsReceived, bytesReceived, packetsLost, jitter,249 packetsDiscarded250 */251function validateInboundRtpStreamStats(statsReport, stats) {252 validateReceivedRtpStreamStats(statsReport, stats);253 assert_unsigned_int_field(stats, 'packetsReceived');254 assert_unsigned_int_field(stats, 'bytesReceived');255 assert_unsigned_int_field(stats, 'packetsLost');256 assert_number_field(stats, 'jitter');257 assert_unsigned_int_field(stats, 'packetsDiscarded');258 validateOptionalIdField(statsReport, stats, 'remoteId', 'remote-outbound-rtp');259 assert_optional_unsigned_int_field(stats, 'framesDecoded');260 assert_optional_number_field(stats, 'lastPacketReceivedTimeStamp');261}262/*263 [webrtc-stats]264 7.5. RTCRemoteInboundRTPStreamStats dictionary265 dictionary RTCRemoteInboundRTPStreamStats : RTCReceivedRTPStreamStats {266 [RTCOutboundRTPStreamStats]267 DOMString localId;268 double roundTripTime;269 };270 */271function validateRemoteInboundRtpStreamStats(statsReport, stats) {272 validateReceivedRtpStreamStats(statsReport, stats);273 validateOptionalIdField(statsReport, stats, 'localId', 'outbound-rtp');274 assert_optional_number_field(stats, 'roundTripTime');275}276/*277 [webrtc-stats]278 7.6. RTCSentRTPStreamStats dictionary279 dictionary RTCSentRTPStreamStats : RTCRTPStreamStats {280 unsigned long packetsSent;281 unsigned long packetsDiscardedOnSend;282 unsigned long long bytesSent;283 unsigned long long bytesDiscardedOnSend;284 };285 */286function validateSentRtpStreamStats(statsReport, stats) {287 validateRtpStreamStats(statsReport, stats);288 assert_optional_unsigned_int_field(stats, 'packetsSent');289 assert_optional_unsigned_int_field(stats, 'packetsDiscardedOnSend');290 assert_optional_unsigned_int_field(stats, 'bytesSent');291 assert_optional_unsigned_int_field(stats, 'bytesDiscardedOnSend');292}293/*294 [webrtc-stats]295 7.7. RTCOutboundRTPStreamStats dictionary296 dictionary RTCOutboundRTPStreamStats : RTCSentRTPStreamStats {297 required unsigned long packetsSent;298 required unsigned long long bytesSent;299 [RTCRemoteInboundRTPStreamStats]300 DOMString remoteId;301 DOMHighResTimeStamp lastPacketSentTimestamp;302 double targetBitrate;303 unsigned long framesEncoded;304 double totalEncodeTime;305 double averageRTCPInterval;306 };307 [webrtc-pc]308 8.6. Mandatory To Implement Stats309 - RTCOutboundRTPStreamStats, with all required attributes from RTCRTPStreamStats,310 and also attributes packetsSent, bytesSent, roundTripTime311 */312function validateOutboundRtpStreamStats(statsReport, stats) {313 validateOptionalIdField(statsReport, stats, 'remoteId', 'remote-inbound-rtp');314 assert_unsigned_int_field(stats, 'packetsSent');315 assert_unsigned_int_field(stats, 'bytesSent');316 assert_optional_number_field(stats, 'lastPacketSentTimestamp');317 assert_optional_number_field(stats, 'targetBitrate');318 assert_optional_unsigned_int_field(stats, 'framesEncoded');319 assert_optional_number_field(stats, 'totalEncodeTime');320 assert_optional_number_field(stats, 'averageRTCPInterval');321}322/*323 [webrtc-stats]324 7.8. RTCRemoteOutboundRTPStreamStats dictionary325 dictionary RTCRemoteOutboundRTPStreamStats : RTCSentRTPStreamStats {326 [RTCInboundRTPStreamStats]327 DOMString localId;328 DOMHighResTimeStamp remoteTimestamp;329 };330 */331function validateRemoteOutboundRtpStreamStats(statsReport, stats) {332 validateSentRtpStreamStats(statsReport, stats);333 validateOptionalIdField(statsReport, stats, 'localId', 'inbound-rtp');334 assert_optional_number_field(stats, 'remoteTimeStamp');335}336/*337 [webrtc-stats]338 7.9. RTCRTPContributingSourceStats339 dictionary RTCRTPContributingSourceStats : RTCStats {340 unsigned long contributorSsrc;341 [RTCInboundRTPStreamStats]342 DOMString inboundRtpStreamId;343 unsigned long packetsContributedTo;344 double audioLevel;345 };346 */347function validateContributingSourceStats(statsReport, stats) {348 validateRtcStats(statsReport, stats);349 assert_optional_unsigned_int_field(stats, 'contributorSsrc');350 validateOptionalIdField(statsReport, stats, 'inboundRtpStreamId', 'inbound-rtp');351 assert_optional_unsigned_int_field(stats, 'packetsContributedTo');352 assert_optional_number_field(stats, 'audioLevel');353}354/*355 [webrtc-stats]356 7.10. RTCPeerConnectionStats dictionary357 dictionary RTCPeerConnectionStats : RTCStats {358 required unsigned long dataChannelsOpened;359 required unsigned long dataChannelsClosed;360 unsigned long dataChannelsRequested;361 unsigned long dataChannelsAccepted;362 };363 [webrtc-pc]364 8.6. Mandatory To Implement Stats365 - RTCPeerConnectionStats, with attributes dataChannelsOpened, dataChannelsClosed366 */367function validatePeerConnectionStats(statsReport, stats) {368 validateRtcStats(statsReport, stats);369 assert_unsigned_int_field(stats, 'dataChannelsOpened');370 assert_unsigned_int_field(stats, 'dataChannelsClosed');371 assert_optional_unsigned_int_field(stats, 'dataChannelsRequested');372 assert_optional_unsigned_int_field(stats, 'dataChannelsAccepted');373}374/*375 [webrtc-stats]376 7.11. RTCMediaStreamStats dictionary377 dictionary RTCMediaStreamStats : RTCStats {378 required DOMString streamIdentifier;379 [RTCMediaStreamTrackStats]380 required sequence<DOMString> trackIds;381 };382 [webrtc-pc]383 8.6. Mandatory To Implement Stats384 - RTCMediaStreamStats, with attributes streamIdentifer, trackIds385 */386function validateMediaStreamStats(statsReport, stats) {387 validateRtcStats(statsReport, stats);388 assert_string_field(stats, 'streamIdentifier');389 assert_array_field(stats, 'trackIds');390 for(const trackId of stats.trackIds) {391 assert_equals(typeof trackId, 'string',392 'Expect trackId elements to be string');393 assert_true(statsReport.has(trackId),394 `Expect stats report to have stats object with id ${trackId}`);395 const trackStats = statsReport.get(trackId);396 assert_equals(trackStats.type, 'track',397 `Expect track stats object to have type 'track'`);398 }399}400/*401 [webrtc-stats]402 7.12. RTCMediaStreamTrackStats dictionary403 dictionary RTCMediaStreamTrackStats : RTCStats {404 required DOMString trackIdentifier;405 required boolean remoteSource;406 required boolean ended;407 required boolean detached;408 DOMString kind;409 DOMHighResTimeStamp estimatedPlayoutTimestamp;410 required unsigned long frameWidth;411 required unsigned long frameHeight;412 required double framesPerSecond;413 unsigned long framesCaptured;414 required unsigned long framesSent;415 required unsigned long framesReceived;416 required unsigned long framesDecoded;417 required unsigned long framesDropped;418 required unsigned long framesCorrupted;419 unsigned long partialFramesLost;420 unsigned long fullFramesLost;421 required double audioLevel;422 double totalAudioEnergy;423 boolean voiceActivityFlag;424 double echoReturnLoss;425 double echoReturnLossEnhancement;426 unsigned long long totalSamplesSent;427 unsigned long long totalSamplesReceived;428 double totalSamplesDuration;429 unsigned long long concealedSamples;430 unsigned long long concealmentEvents;431 double jitterBufferDelay;432 RTCPriorityType priority;433 };434 [webrtc-pc]435 4.9.1. RTCPriorityType Enum436 enum RTCPriorityType {437 "very-low",438 "low",439 "medium",440 "high"441 };442 8.6. Mandatory To Implement Stats443 - RTCMediaStreamTrackStats, with attributes trackIdentifier, remoteSource, ended,444 detached, ssrcIds, frameWidth, frameHeight, framesPerSecond, framesSent,445 framesReceived, framesDecoded, framesDropped, framesCorrupted, audioLevel446 */447function validateMediaStreamTrackStats(stats, stat) {448 validateRtcStats(statsReport, stats);449 assert_string_field(stat, 'trackIdentifier');450 assert_boolean_field(stat, 'remoteSource');451 assert_boolean_field(stat, 'ended');452 assert_boolean_field(stat, 'detached');453 assert_optional_string_field(stat, 'kind');454 assert_optional_number_field(stat, 'estimatedPlayoutTimestamp');455 assert_unsigned_int_field(stat, 'frameWidth');456 assert_unsigned_int_field(stat, 'frameHeight');457 assert_number_field(stat, 'framesPerSecond');458 assert_optional_unsigned_int_field(stat, 'framesCaptured');459 assert_unsigned_int_field(stat, 'frameSent');460 assert_unsigned_int_field(stat, 'frameReceived');461 assert_unsigned_int_field(stat, 'frameDecoded');462 assert_unsigned_int_field(stat, 'frameDropped');463 assert_unsigned_int_field(stat, 'frameCorrupted');464 assert_optional_unsigned_int_field(stat, 'partialFramesLost');465 assert_optional_unsigned_int_field(stat, 'fullFramesLost');466 assert_number_field(stat, 'audioLevel');467 assert_optional_number_field(stat, 'totalAudioEnergy');468 assert_optional_boolean_field(stat, 'voiceActivityFlag');469 assert_optional_number_field(stat, 'echoReturnLoss');470 assert_optional_number_field(stat, 'echoReturnLossEnhancement');471 assert_optional_unsigned_int_field(stat, 'totalSamplesSent');472 assert_optional_unsigned_int_field(stat, 'totalSamplesReceived');473 assert_optional_number_field(stat, 'totalSamplesDuration');474 assert_optional_unsigned_int_field(stat, 'concealedSamples');475 assert_optional_unsigned_int_field(stat, 'concealmentEvents');476 assert_optional_number_field(stat, 'jitterBufferDelay');477 assert_optional_enum_field(stats, 'priority',478 ['very-low', 'low', 'medium', 'high']);479}480/*481 [webrtc-stats]482 7.13. RTCDataChannelStats dictionary483 dictionary RTCDataChannelStats : RTCStats {484 required DOMString label;485 required DOMString protocol;486 required long datachannelid;487 [RTCTransportStats]488 DOMString transportId;489 required RTCDataChannelState state;490 required unsigned long messagesSent;491 required unsigned long long bytesSent;492 required unsigned long messagesReceived;493 required unsigned long long bytesReceived;494 };495 [webrtc-pc]496 6.2. RTCDataChannel497 enum RTCDataChannelState {498 "connecting",499 "open",500 "closing",501 "closed"502 };503 8.6. Mandatory To Implement Stats504 - RTCDataChannelStats, with attributes label, protocol, datachannelId, state,505 messagesSent, bytesSent, messagesReceived, bytesReceived506 */507function validateDataChannelStats(statsReport, stats) {508 validateRtcStats(statsReport, stats);509 assert_string_field(stats, 'label');510 assert_string_field(stats, 'protocol');511 assert_int_field(stats, 'datachannelid');512 validateOptionalIdField(statsReport, stats, 'transportId', 'transport');513 assert_enum_field(stats, 'state',514 ['connecting', 'open', 'closing', 'closed']);515 assert_unsigned_int_field(stats, 'messageSent');516 assert_unsigned_int_field(stats, 'messageSent');517 assert_unsigned_int_field(stats, 'bytesSent');518 assert_unsigned_int_field(stats, 'messagesReceived');519 assert_unsigned_int_field(stats, 'bytesReceived');520}521/*522 [webrtc-stats]523 7.14. RTCTransportStats dictionary524 dictionary RTCTransportStats : RTCStats {525 unsigned long packetsSent;526 unsigned long packetsReceived;527 required unsigned long long bytesSent;528 required unsigned long long bytesReceived;529 [RTCTransportStats]530 required DOMString rtcpTransportStatsId;531 RTCIceRole iceRole;532 RTCDtlsTransportState dtlsState;533 [RTCIceCandidatePairStats]534 required DOMString selectedCandidatePairId;535 [RTCCertificateStats]536 required DOMString localCertificateId;537 [RTCCertificateStats]538 required DOMString remoteCertificateId;539 };540 [webrtc-pc]541 5.5. RTCDtlsTransportState Enum542 enum RTCDtlsTransportState {543 "new",544 "connecting",545 "connected",546 "closed",547 "failed"548 };549 5.6. RTCIceRole Enum550 enum RTCIceRole {551 "controlling",552 "controlled"553 };554 8.6. Mandatory To Implement Stats555 - RTCTransportStats, with attributes bytesSent, bytesReceived, rtcpTransportStatsId,556 activeConnection, selectedCandidatePairId, localCertificateId, remoteCertificateId557 */558function validateTransportStats(statsReport, stats) {559 validateRtcStats(statsReport, stats);560 assert_optional_unsigned_int_field(stats, 'packetsSent');561 assert_optional_unsigned_int_field(stats, 'packetsReceived');562 assert_unsigned_int_field(stats, 'bytesSent');563 assert_unsigned_int_field(stats, 'bytesReceived');564 validateIdField(statsReport, stats, 'rtcpTransportStatsId', 'transport');565 assert_optional_enum_field(stats, 'iceRole',566 ['controlling', 'controlled']);567 assert_optional_enum_field(stats, 'dtlsState',568 ['new', 'connecting', 'connected', 'closed', 'failed']);569 validateIdField(statsReport, stats, 'selectedCandidatePairId', 'candidate-pair');570 validateIdField(stateReport, stats, 'localCertificateId', 'certificate');571 validateIdField(stateReport, stats, 'remoteCertificateId', 'certificate');572}573/*574 [webrtc-stats]575 7.15. RTCIceCandidateStats dictionary576 dictionary RTCIceCandidateStats : RTCStats {577 [RTCTransportStats]578 DOMString transportId;579 boolean isRemote;580 required DOMString ip;581 required long port;582 required DOMString protocol;583 required RTCIceCandidateType candidateType;584 required long priority;585 required DOMString url;586 DOMString relayProtocol;587 boolean deleted = false;588 };589 [webrtc-pc]590 4.8.1.3. RTCIceCandidateType Enum591 enum RTCIceCandidateType {592 "host",593 "srflx",594 "prflx",595 "relay"596 };597 8.6. Mandatory To Implement Stats598 - RTCIceCandidateStats, with attributes ip, port, protocol, candidateType, priority,599 url600 */601function validateIceCandidateStats(statsReport, stats) {602 validateRtcStats(statsReport, stats);603 validateOptionalIdField(statsReport, stats, 'transportId', 'transport');604 assert_optional_boolean_field(stats, 'isRemote');605 assert_string_field(stats, 'ip');606 assert_int_field(stats, 'port');607 assert_string_field(stats, 'protocol');608 assert_enum_field(stats, 'candidateType',609 ['host', 'srflx', 'prflx', 'relay']);610 assert_int_field(stats, 'priority');611 assert_string_field(stats, 'url');612 assert_optional_string_field(stats, 'relayProtocol');613 assert_optional_boolean_field(stats, 'deleted');614}615/*616 [webrtc-stats]617 7.16. RTCIceCandidatePairStats dictionary...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('./wptools.js');2var id = 'Q123';3var result = wptools.validateOptionalIdField(id);4console.log(result);5var validateOptionalIdField = function (id) {6 if (id) {7 return id;8 }9 return null;10}11module.exports.validateOptionalIdField = validateOptionalIdField;12Your name to display (optional):13Your name to display (optional):14var wptools = require('./wptools.js');15var id = 'Q123';16var result = wptools.validateOptionalIdField(id);17console.log(result);18Your name to display (optional):19var wptools = require('./wptools.js');20var id = 'Q123';21var result = wptools.validateOptionalIdField(id);22console.log(result);23Your name to display (optional):24var wptools = require('./wptools.js');25var id = 'Q123';26var result = wptools.validateOptionalIdField(id);27console.log(result);28Your name to display (optional):29var wptools = require('./wptools.js');30var id = 'Q123';31var result = wptools.validateOptionalIdField(id);32console.log(result);33Your name to display (optional):34var wptools = require('./wptools.js');35var id = 'Q123';36var result = wptools.validateOptionalIdField(id);37console.log(result);38Your name to display (optional):

Full Screen

Using AI Code Generation

copy

Full Screen

1var toolkit = require("wptoolkit");2var id = toolkit.validateOptionalIdField(1);3console.log(id);4var toolkit = require("wptoolkit");5var id = toolkit.validateOptionalIdField(0);6console.log(id);7var toolkit = require("wptoolkit");8var id = toolkit.validateOptionalIdField("0");9console.log(id);10var toolkit = require("wptoolkit");11var id = toolkit.validateOptionalIdField("1");12console.log(id);13var toolkit = require("wptoolkit");14var id = toolkit.validateOptionalIdField("2");15console.log(id);16var toolkit = require("wptoolkit");17var id = toolkit.validateOptionalIdField("3");18console.log(id);19var toolkit = require("wptoolkit");20var id = toolkit.validateOptionalIdField("4");21console.log(id);22var toolkit = require("wptoolkit");23var id = toolkit.validateOptionalIdField("5");24console.log(id);25var toolkit = require("wptoolkit");26var id = toolkit.validateOptionalIdField("6");27console.log(id);28var toolkit = require("wptoolkit");29var id = toolkit.validateOptionalIdField("7");30console.log(id);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptUtils = require('./wptUtils.js');2wptUtils.validateOptionalIdField('testIdField', 'idField', 'testIdValue');3module.exports = {4 validateOptionalIdField: function(idField, idFieldName, idFieldValue) {5 if (idFieldValue) {6 if (typeof idFieldValue !== 'string' || idFieldValue === '') {7 throw new Error(idFieldName + ' must be a non-empty string');8 }9 } else {10 console.log(idFieldName + ' is optional, but if it is present, it must be a non-empty string');11 }12 }13};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptCommon = require('./wpt-common.js');2var id = 1234;3var apiCallName = 'getTestStatus';4wptCommon.validateOptionalIdField(id, apiCallName);5console.log('id field validation done');6exports.validateOptionalIdField = function(id, apiCallName){7 if(id != undefined){8 if(typeof id != 'number'){9 throw new Error(apiCallName + ' id field should be a number');10 }11 }12}13var wptCommon = require('./wpt-common.js');14var id = 1234;15var apiCallName = 'getTestStatus';16wptCommon.validateOptionalIdField(id, apiCallName);17console.log('id field validation done');18exports.validateOptionalIdField = function(id, apiCallName){19 if(id != undefined){20 if(typeof id != 'number'){21 throw new Error(apiCallName + ' id field should be a number');22 }23 }24}

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