Best JavaScript code snippet using chai
utils.js
Source:utils.js
1// Load the Cloudant library.2import Cloudant from '@cloudant/cloudant';3//Load UUID4import {v1 as uuidv1, v4 as uuidv4} from 'uuid';5// Load the Cloudant service config.6import vcap from '../cloudant-config/vcap-local.js';7// Get account details from environment variables8var url = vcap.services.cloudantNoSQLDB.credentials.url;9var username = vcap.services.cloudantNoSQLDB.credentials.username;10var password = vcap.services.cloudantNoSQLDB.credentials.password;11// Initialize the library with url and credentials.12var cloudant = Cloudant({ url: url, username: username, password: password });13const utils = {14 //Function to map update-user req to model15 mapUserUpdateToModel: function mapUserUpdateToModel(user, request) { 16 if(request.user_name){17 user.user_name = request.user_name;18 user.updated_dt = new Date(Date.now()).toISOString();19 }20 if(request.password){21 user.password = request.password;22 user.updated_dt = new Date(Date.now()).toISOString();23 }24 if(request.email){25 user.email = request.email;26 user.updated_dt = new Date(Date.now()).toISOString();27 }28 if(request.full_name){29 user.full_name = request.full_name;30 user.updated_dt = new Date(Date.now()).toISOString();31 }32 if(request.dob){33 user.dob = request.dob;34 user.updated_dt = new Date(Date.now()).toISOString();35 }36 if(request.gender){37 user.gender = request.gender;38 user.updated_dt = new Date(Date.now()).toISOString();39 }40 if(request.secure_login_recovery){41 user.secure_login_recovery = request.secure_login_recovery;42 user.updated_dt = new Date(Date.now()).toISOString();43 }44 if(request.street_address_1){45 user.street_address_1 = request.street_address_1;46 user.updated_dt = new Date(Date.now()).toISOString();47 }48 if(request.street_address_2){49 user.street_address_2 = request.street_address_2;50 user.updated_dt = new Date(Date.now()).toISOString();51 }52 if(request.city){53 user.city = request.city;54 user.updated_dt = new Date(Date.now()).toISOString();55 }56 if(request.state){57 user.state = request.state;58 user.updated_dt = new Date(Date.now()).toISOString();59 }60 if(request.zip){61 user.zip = request.zip;62 user.updated_dt = new Date(Date.now()).toISOString();63 }64 if(request.country){65 user.country = request.country;66 user.updated_dt = new Date(Date.now()).toISOString();67 }68 if(request.RoleID){69 var role = [];70 role = user.role;71 role.forEach(item => {72 if(item.RoleID == request.RoleID)73 {74 item.ActiveStatus = !item.ActiveStatus;75 item.UpdatedTime = new Date(Date.now()).toISOString();76 }77 });78 user.role = role;79 user.updated_dt = new Date(Date.now()).toISOString();80 }81 if(request.sold_product_ID){82 user.sold_product_ID = request.sold_product_ID;83 user.updated_dt = new Date(Date.now()).toISOString();84 }85 return user;86 },87 //Function to map update-product req to model88 mapProductUpdateToModel: function mapProductUpdateToModel(product, request) {89 if(request.product_name){90 product.product_name = request.product_name;91 product.updated_dt = new Date(Date.now()).toISOString();92 }93 if(request.unit_price){94 product.unit_price = request.unit_price;95 product.updated_dt = new Date(Date.now()).toISOString();96 }97 if(request.quantity){98 product.quantity = request.quantity;99 product.updated_dt = new Date(Date.now()).toISOString();100 }101 if(request.product_material){102 product.product_material = request.product_material;103 product.updated_dt = new Date(Date.now()).toISOString();104 }105 if(request.recycling_code){106 product.recycling_code = request.recycling_code;107 product.updated_dt = new Date(Date.now()).toISOString();108 }109 if(request.seller_ID){110 product.seller_ID = request.seller_ID;111 product.updated_dt = new Date(Date.now()).toISOString();112 }113 if(request.seller_name){114 product.seller_name = request.seller_name;115 product.updated_dt = new Date(Date.now()).toISOString();116 }117 if(request.product_category){118 product.product_category = request.product_category;119 product.updated_dt = new Date(Date.now()).toISOString();120 }121 if(request.product_sub_category){122 product.product_sub_category = request.product_sub_category;123 product.updated_dt = new Date(Date.now()).toISOString();124 }125 if(request.isApproved){126 product.isApproved = request.isApproved;127 product.updated_dt = new Date(Date.now()).toISOString();128 }129 else if(request.isApproved === false)130 {131 product.isApproved = request.isApproved;132 product.updated_dt = new Date(Date.now()).toISOString();133 }134 return product;135 },136 //Function to map update-cart req to model137 mapCartUpdateToModel: function mapCartUpdateToModel(cart, request) { 138 if(request.products){139 cart.products = request.products;140 cart.updated_dt = new Date(Date.now()).toISOString();141 }142 return cart;143 },144 //Function to Remove object using user_ID145 removeByUserID: function removeByUserID(details, user_ID, user_ID_value) { 146 var i = details.length;147 while(i--){148 if( details[i] 149 && details[i].hasOwnProperty(user_ID) 150 && (arguments.length > 2 && details[i][user_ID] === user_ID_value ) ){ 151 details.splice(i,1);152 }153 }154 return details;155 },156 //Create Cloudant DB function157 createCloudantDB: function createCloudantDB() { 158 var uniqueUserID = Math.random().toString(26).slice(2);159 160 cloudant.db.create('green-production').then(() => {161 cloudant.use('green-production').insert({ user_ID: uniqueUserID }, 'Users').then((data) => {162 console.log(data);163 });164 }).catch((err) => {165 console.log(err);166 });167 },168 //Find all docs in a DB169 findAllDocs: function findAllDocs(){170 var mydb = cloudant.db.use('green-production');171 return new Promise((resolve, reject) => {172 mydb.list({include_docs:true}, function (err, document) {173 if (err) {174 if (err.message == 'missing') {175 resolve({ data: {}, statusCode: 404 });176 } else {177 reject(err);178 }179 } else {180 resolve({ data: document, statusCode: 200 });181 }182 });183 });184 },185 //Fetch document based on doc name(doc ID) 186 getDocumentFromDB: function getDocumentFromDB(docName) { 187 var mydb = cloudant.db.use('green-production');188 //var myData;189 190 return new Promise((resolve, reject) => {191 mydb.get(docName, (err, document) => {192 if (err) {193 if (err.message == 'missing') {194 resolve({ data: {}, statusCode: 404 });195 } else {196 reject(err);197 }198 } else {199 resolve({ data: JSON.stringify(document), statusCode: 200 });200 }201 });202 }); 203 //return myData;204 },205 //Create new Users document206 createUsersDocument: function createUsersDocument(207 docName,208 userName,209 password,210 email,211 full_name,212 dob,213 gender,214 secure_login_recovery,215 street_address_1,216 street_address_2,217 city,218 state,219 zip,220 country,221 role,222 sold_product_ID223 ) {224 var mydb = cloudant.db.use('green-production');225 return new Promise((resolve, reject) => {226 let listId = uuidv4();227 let list = {228 _id: listId,229 type: docName,230 user_details: [231 { 232 'user_ID': uuidv1(),233 'user_name' : userName,234 'password' : password,235 'email' : email,236 'full_name' : full_name,237 'dob' : dob,238 'gender' : gender,239 'secure_login_recovery' : secure_login_recovery,240 'street_address_1' : street_address_1,241 'street_address_2' : street_address_2,242 'city' : city,243 'state' : state,244 'zip' : zip,245 'country' : country,246 'role' : role,247 'sold_product_ID' : sold_product_ID,248 'created_dt': new Date(Date.now()).toISOString(),249 'updated_dt': new Date(Date.now()).toISOString()250 }],251 252 };253 mydb.insert(list, (err, result) => {254 if (err) {255 reject(err);256 } else {257 resolve({ 258 data: { 259 createdId: result.id,260 createdRevId: result.rev,261 user: list.user_details262 },263 statusCode: 201 264 });265 }266 });267 });268 },269 //Insert new user-datails in Users document270 insertUserInfo: function insertUserInfo(id, rev, newUserDetails) {271 var mydb = cloudant.db.use('green-production');272 return new Promise((resolve, reject) => { 273 let list = {274 _id: id,275 type: 'Users',276 _rev: rev,277 user_details: newUserDetails278 };279 mydb.insert(list, (err, response) => {280 if (err) {281 reject(err);282 } else {283 resolve({ data: { updatedId: response.id, updatedRevId: response.rev }, statusCode: 200 });284 }285 });286 });287 },288 //Create new Products document289 createProductsDocument: function createProductsDocument(290 docName,291 productName,292 unitPrice,293 quantity,294 productMaterial,295 recyclingCode,296 sellerID,297 sellerName,298 productCategory,299 productSubCategory300 ) {301 var mydb = cloudant.db.use('green-production');302 return new Promise((resolve, reject) => {303 let listId = uuidv4();304 let list = {305 _id: listId,306 type: docName,307 product_details: [308 { 309 'product_ID': uuidv1(),310 'product_name' : productName,311 'unit_price' : unitPrice,312 'quantity' : quantity,313 'product_material' : productMaterial,314 'recycling_code' : recyclingCode,315 'seller_ID' : sellerID,316 'seller_name' : sellerName,317 'product_category' : productCategory,318 'product_sub_category' : productSubCategory,319 'isApproved' : false,320 'created_dt': new Date(Date.now()).toISOString(),321 'updated_dt': new Date(Date.now()).toISOString()322 }],323 324 };325 mydb.insert(list, (err, result) => {326 if (err) {327 reject(err);328 } else {329 resolve({ data: { createdId: result.id, createdRevId: result.rev }, statusCode: 201 });330 }331 });332 });333 },334 //Insert new product-datails in Products document335 insertProductInfo: function insertProductInfo(id, rev, newProductDetails) {336 var mydb = cloudant.db.use('green-production');337 return new Promise((resolve, reject) => { 338 let list = {339 _id: id,340 type: 'Products',341 _rev: rev,342 product_details: newProductDetails343 };344 mydb.insert(list, (err, response) => {345 if (err) {346 reject(err);347 } else {348 resolve({ data: { updatedId: response.id, updatedRevId: response.rev }, statusCode: 200 });349 }350 });351 });352 },353 //Create new Cart document354 createCartDocument: function createCartDocument(355 docName,356 userID,357 products358 ) {359 var mydb = cloudant.db.use('green-production');360 return new Promise((resolve, reject) => {361 let listId = uuidv4();362 let list = {363 _id: listId,364 type: docName,365 cart_details: [366 { 367 'user_ID': userID,368 'products': products,369 'created_dt': new Date(Date.now()).toISOString(),370 'updated_dt': new Date(Date.now()).toISOString()371 372 }],373 374 };375 mydb.insert(list, (err, result) => {376 if (err) {377 reject(err);378 } else {379 resolve({ data: { createdId: result.id, createdRevId: result.rev }, statusCode: 201 });380 }381 });382 });383 },384 //Insert new user-product details in Cart document385 insertCartItem: function insertCartItem(id, rev, newCartDetails) {386 var mydb = cloudant.db.use('green-production');387 return new Promise((resolve, reject) => { 388 let list = {389 _id: id,390 type: 'Cart',391 _rev: rev,392 cart_details: newCartDetails393 };394 mydb.insert(list, (err, response) => {395 if (err) {396 reject(err);397 } else {398 resolve({ data: { updatedId: response.id, updatedRevId: response.rev }, statusCode: 200 });399 }400 });401 });402 },403 //Create new orders document404 createOrdersDocument: function createOrdersDocument(405 docName,406 userID,407 products408 ) {409 var mydb = cloudant.db.use('green-production');410 return new Promise((resolve, reject) => {411 let listId = uuidv4();412 let list = {413 _id: listId,414 type: docName,415 transaction_details: [] 416 };417 mydb.insert(list, (err, result) => {418 if (err) {419 reject(err);420 } else {421 resolve({ data: { createdId: result.id, createdRevId: result.rev }, statusCode: 201 });422 }423 });424 });425 },426 //Insert new order in Orders document427 insertOrder: function insertOrder(id, rev, newTransactionDetails) {428 var mydb = cloudant.db.use('green-production');429 return new Promise((resolve, reject) => { 430 let list = {431 _id: id,432 type: 'Orders',433 _rev: rev,434 transaction_details: newTransactionDetails435 };436 mydb.insert(list, (err, response) => {437 if (err) {438 reject(err);439 } else {440 resolve({ data: { updatedId: response.id, updatedRevId: response.rev }, statusCode: 200 });441 }442 });443 });444 },445}...
add-months.js
Source:add-months.js
...23describe('addMonths() í
ì¤í¸#1', function() {24 it('1ë¬ ì© ëí기 í
ì¤í¸', function() {25 let now = new Date('2018-07-31T09:00:00.000+09:00');26 // log('íêµ ìê° 2018ë
7ì 31ì¼ 09ìë¡ ì¤ì : ');27 assert.strictEqual(now.toISOString(), '2018-07-31T00:00:00.000Z');28 assert.strictEqual(now.toLocaleString(), '2018. 7. 31. ì¤ì 9:00:00');29 now.addMonths(1); // +1ë¬30 assert.strictEqual(now.toISOString(), '2018-08-31T00:00:00.000Z')31 now.addMonths(1); // +2ë¬32 assert.strictEqual(now.toISOString(), '2018-09-30T00:00:00.000Z')33 now.addMonths(1); // +3ë¬34 assert.strictEqual(now.toISOString(), '2018-10-30T00:00:00.000Z')35 now.addMonths(1); // +4ë¬36 assert.strictEqual(now.toISOString(), '2018-11-30T00:00:00.000Z')37 now.addMonths(1); // +5ë¬38 assert.strictEqual(now.toISOString(), '2018-12-30T00:00:00.000Z')39 now.addMonths(1); // +6ë¬40 assert.strictEqual(now.toISOString(), '2019-01-30T00:00:00.000Z')41 now.addMonths(1); // +7ë¬42 assert.strictEqual(now.toISOString(), '2019-02-28T00:00:00.000Z')43 now.addMonths(1); // +8ë¬44 assert.strictEqual(now.toISOString(), '2019-03-28T00:00:00.000Z')45 now.addMonths(1); // +9ë¬46 assert.strictEqual(now.toISOString(), '2019-04-28T00:00:00.000Z')47 });48 it('1ë¬ ì© ë¹¼ê¸° í
ì¤í¸', function() {49 let now = new Date('2018-07-31T09:00:00.000+09:00');50 // log('ë¤ì íêµ ìê° 2018ë
7ì 31ì¼ 09ìë¡ ì¤ì : ');51 assert.strictEqual(now.toISOString(), '2018-07-31T00:00:00.000Z');52 assert.strictEqual(now.toLocaleString(), '2018. 7. 31. ì¤ì 9:00:00');53 now.addMonths(-1); // -1ë¬54 assert.strictEqual(now.toISOString(), '2018-06-30T00:00:00.000Z')55 now.addMonths(-1); // -2ë¬56 assert.strictEqual(now.toISOString(), '2018-05-30T00:00:00.000Z')57 now.addMonths(-1); // -3ë¬58 assert.strictEqual(now.toISOString(), '2018-04-30T00:00:00.000Z')59 now.addMonths(-1); // -4ë¬60 assert.strictEqual(now.toISOString(), '2018-03-30T00:00:00.000Z')61 now.addMonths(-1); // -5ë¬62 assert.strictEqual(now.toISOString(), '2018-02-28T00:00:00.000Z')63 now.addMonths(-1); // -6ë¬64 assert.strictEqual(now.toISOString(), '2018-01-28T00:00:00.000Z')65 now.addMonths(-1); // -7ë¬66 assert.strictEqual(now.toISOString(), '2017-12-28T00:00:00.000Z')67 now.addMonths(-1); // -8ë¬68 assert.strictEqual(now.toISOString(), '2017-11-28T00:00:00.000Z')69 now.addMonths(-1); // -9ë¬70 assert.strictEqual(now.toISOString(), '2017-10-28T00:00:00.000Z')71 });...
add-months2.js
Source:add-months2.js
...16describe('addMonths() í
ì¤í¸#2', function() {17 it('1ë¬ ì© ëí기 í
ì¤í¸', function() {18 let now = new Date('2018-07-31T09:00:00.000+09:00');19 // log('íêµ ìê° 2018ë
7ì 31ì¼ 09ìë¡ ì¤ì : ');20 assert.strictEqual(now.toISOString(), '2018-07-31T00:00:00.000Z');21 assert.strictEqual(now.toLocaleString(), '2018. 7. 31. ì¤ì 9:00:00');22 now.addMonths(1); // +1ë¬23 assert.strictEqual(now.toISOString(), '2018-08-31T00:00:00.000Z')24 now.addMonths(1); // +2ë¬25 assert.strictEqual(now.toISOString(), '2018-09-30T00:00:00.000Z')26 now.addMonths(1); // +3ë¬27 assert.strictEqual(now.toISOString(), '2018-10-30T00:00:00.000Z')28 now.addMonths(1); // +4ë¬29 assert.strictEqual(now.toISOString(), '2018-11-30T00:00:00.000Z')30 now.addMonths(1); // +5ë¬31 assert.strictEqual(now.toISOString(), '2018-12-30T00:00:00.000Z')32 now.addMonths(1); // +6ë¬33 assert.strictEqual(now.toISOString(), '2019-01-30T00:00:00.000Z')34 now.addMonths(1); // +7ë¬35 assert.strictEqual(now.toISOString(), '2019-02-28T00:00:00.000Z')36 now.addMonths(1); // +8ë¬37 assert.strictEqual(now.toISOString(), '2019-03-28T00:00:00.000Z')38 now.addMonths(1); // +9ë¬39 assert.strictEqual(now.toISOString(), '2019-04-28T00:00:00.000Z')40 });41 it('1ë¬ ì© ë¹¼ê¸° í
ì¤í¸', function() {42 let now = new Date('2018-07-31T09:00:00.000+09:00');43 // log('ë¤ì íêµ ìê° 2018ë
7ì 31ì¼ 09ìë¡ ì¤ì : ');44 assert.strictEqual(now.toISOString(), '2018-07-31T00:00:00.000Z');45 assert.strictEqual(now.toLocaleString(), '2018. 7. 31. ì¤ì 9:00:00');46 now.addMonths(-1); // -1ë¬47 assert.strictEqual(now.toISOString(), '2018-06-30T00:00:00.000Z')48 now.addMonths(-1); // -2ë¬49 assert.strictEqual(now.toISOString(), '2018-05-30T00:00:00.000Z')50 now.addMonths(-1); // -3ë¬51 assert.strictEqual(now.toISOString(), '2018-04-30T00:00:00.000Z')52 now.addMonths(-1); // -4ë¬53 assert.strictEqual(now.toISOString(), '2018-03-30T00:00:00.000Z')54 now.addMonths(-1); // -5ë¬55 assert.strictEqual(now.toISOString(), '2018-02-28T00:00:00.000Z')56 now.addMonths(-1); // -6ë¬57 assert.strictEqual(now.toISOString(), '2018-01-28T00:00:00.000Z')58 now.addMonths(-1); // -7ë¬59 assert.strictEqual(now.toISOString(), '2017-12-28T00:00:00.000Z')60 now.addMonths(-1); // -8ë¬61 assert.strictEqual(now.toISOString(), '2017-11-28T00:00:00.000Z')62 now.addMonths(-1); // -9ë¬63 assert.strictEqual(now.toISOString(), '2017-10-28T00:00:00.000Z')64 });...
Using AI Code Generation
1console.log(new Date().toISOString());2console.log(new Date().toJSON());3console.log(new Date().toString());4console.log(new Date().toLocaleString());5console.log(new Date().toLocaleDateString());6console.log(new Date().toLocaleTimeString());7console.log(new Date().toUTCString());8console.log(new Date().toDateString());9console.log(new Date().toTimeString());10console.log(new Date().toGMTString());11console.log(new Date().valueOf());12console.log(new Date().getTime());
Using AI Code Generation
1var expect = require('chai').expect;2var now = new Date();3describe('Date', function() {4 describe('#toISOString()', function() {5 it('should return a valid ISO 8601 date string', function() {6 expect(now.toISOString()).to.be.a('string');7 expect(now.toISOString()).to.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/);8 });9 });10});11var expect = require('chai').expect;12var now = new Date();13describe('Date', function() {14 describe('#toISOString()', function() {15 it('should return a valid ISO 8601 date string', function() {16 expect(now.toISOString()).to.be.a('string');17 expect(now.toISOString()).to.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/);18 });19 });20});21var expect = require('chai').expect;22var now = new Date();23describe('Date', function() {24 describe('#toISOString()', function() {25 it('should return a valid ISO 8601 date string', function() {26 expect(now.toISOString()).to.be.a('string');27 expect(now.toISOString()).to.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/);28 });29 });30});31var expect = require('chai').expect;32var now = new Date();33describe('Date', function() {34 describe('#toISOString()', function() {35 it('should return a valid ISO 8601 date string', function() {36 expect(now.toISOString()).to.be.a('string');37 expect(now.toISOString()).to.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/);38 });39 });40});
Using AI Code Generation
1var expect = require('chai').expect;2var now = new Date();3describe('Date', function() {4 describe('#toISOString()', function() {5 it('should return a valid ISO-8601 string', function() {6 var isoString = now.toISOString();7 expect(isoString).to.be.a('string');8 expect(isoString).to.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/);9 });10 });11});12describe('Date', function() {13 describe('#toISOString()', function() {14 it('should return a valid ISO-8601 string', function() {15 var isoString = now.toISOString();16 expect(isoString).to.be.a('string');17 expect(isoString).to.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/);18 });19 });20});21describe('Date', function() {22 describe('#toISOString()', function() {23 it('should return a valid ISO-8601 string', function() {24 var isoString = now.toISOString();25 expect(isoString).to.be.a('string');26 expect(isoString).to.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/);27 });28 });29});30describe('Date', function() {31 describe('#toISOString()', function() {32 it('should return a valid ISO-8601 string', function() {33 var isoString = now.toISOString();34 expect(isoString).to.be.a('string');35 expect(isoString).to.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/);36 });37 });38});39describe('Date', function
Using AI Code Generation
1console.log(now.toISOString());2console.log(now.toDateString());3console.log(now.toTimeString());4console.log(now.toUTCString());5console.log(now.toLocaleString());6console.log(now.toLocaleDateString());7console.log(now.toLocaleTimeString());8console.log(now.valueOf());9console.log(now.getTime());10console.log(now.getYear());11console.log(now.getFullYear());12console.log(now.getMonth());13console.log(now.getDate());14console.log(now.getDay());15console.log(now.getHours());
Using AI Code Generation
1var chai = require('chai');2var assert = chai.assert;3var expect = chai.expect;4var should = chai.should();5var today = new Date();6today.should.be.a('date');7expect(today).to.be.a('date');8assert.typeOf(today, 'date');9today.should.be.a('date');10expect(today).to.be.a('date');11assert.typeOf(today, 'date');12var chai = require('chai');13var assert = chai.assert;14var expect = chai.expect;15var should = chai.should();16var today = new Date();17today.should.be.a('date');18expect(today).to.be.a('date');19assert.typeOf(today, 'date');20today.should.be.a('date');21expect(today).to.be.a('date');22assert.typeOf(today, 'date');23var chai = require('chai');24var assert = chai.assert;25var expect = chai.expect;26var should = chai.should();27var today = new Date();28today.should.be.a('date');29expect(today).to.be.a('date');30assert.typeOf(today, 'date');31today.should.be.a('date');32expect(today).to.be.a('date');33assert.typeOf(today, 'date');34var chai = require('chai');35var assert = chai.assert;36var expect = chai.expect;37var should = chai.should();38var today = new Date();39today.should.be.a('date');40expect(today).to.be.a('date');41assert.typeOf(today, 'date');42today.should.be.a('date');43expect(today).to.be.a('date');44assert.typeOf(today, 'date');
Using AI Code Generation
1const moment = require('moment');2const now = moment();3const nowISO = now.toISOString();4console.log(nowISO);5const nowFormatted = now.format('ddd, MMMM Do YYYY, h:mm:ss a');6console.log(nowFormatted);7const nowFormatted2 = now.format('YYYY/MM/DD, h:mm:ss a');8console.log(nowFormatted2);9const nowMoment = moment().toISOString();10console.log(nowMoment);11const nowMoment2 = moment().format('ddd, MMMM Do YYYY, h:mm:ss a');12console.log(nowMoment2);13const nowMoment3 = moment().format('YYYY/MM/DD, h:mm:ss a');14console.log(nowMoment3);15const nowMoment4 = moment().add(1, 'year').subtract(2, 'months').add(1, 'day').format('YYYY/MM/DD, h:mm:ss a');16console.log(nowMoment4);17const nowMoment5 = moment().add(1, 'year').subtract(2, 'months').add(1, 'day').format('YYYY/MM/DD, h:mm:ss a');18console.log(nowMoment5);19const nowMoment6 = moment().add(1, 'year').subtract(2, 'months').add(1, 'day').format('YYYY/MM/DD, h:mm:ss a');20console.log(nowMoment6);21const nowMoment7 = moment().add(1, 'year').subtract(2, 'months').add(1, 'day').format('YYYY/MM/DD, h:mm:ss a');22console.log(nowMoment7);23const nowMoment8 = moment().add(1, 'year').subtract(2, 'months').add(1, 'day').format('YYYY/MM/DD, h:mm:ss a');24console.log(nowMoment8);25const nowMoment9 = moment().add(1, 'year').subtract(2, 'months').add(1, 'day').format('YYYY/MM/DD, h:mm
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!