How to use Promise.mapSeries method in Cypress

Best JavaScript code snippet using cypress

jmdict.js

Source:jmdict.js Github

copy

Full Screen

...32 }33 }34 });3536 let kanjiElements = await Promise.mapSeries(rawEntry.k_ele || [], async rawKanjiElement => {37 let [kanjiElement] = await models.JMdictKanjiElement.findOrCreate({38 where: {39 JMdictEntryId: entry.id,40 word: rawKanjiElement.keb[0]41 }42 });4344 kanjiElement.info = rawKanjiElement.ke_inf;45 // TODO: Change prioroty → priority46 kanjiElement.prioroty = rawKanjiElement.ke_pri;47 return kanjiElement.save();48 });4950 let kanjiRestrictedReadingElements = await Promise.mapSeries(kanjiElements, k => k.getKanjiRestrictedReadingElements);5152 let readingElements = await Promise.mapSeries(rawEntry.r_ele || [], async rawReadingElement => {53 let readingElementUniqueData = {54 word: rawReadingElement.reb[0]55 };5657 let readingElement;58 if (rawReadingElement.re_nokanji || !kanjiElements || !kanjiElements.length) {59 readingElementUniqueData.JMdictEntryId = entry.id;60 [readingElement] = await models.JMdictReadingElement.findOrCreate({61 where: readingElementUniqueData62 });63 } else if (rawReadingElement.re_restr && rawReadingElement.re_restr.length) {64 readingElement = kanjiRestrictedReadingElements.find(e => e.word === readingElementUniqueData.word);65 if (!readingElement) {66 readingElement = await models.JMdictReadingElement.create(readingElementUniqueData);67 }6869 await Promise.mapSeries(rawReadingElement.re_restr, async restrictedKeb => {70 let matchingKanjiElements = kanjiElements.filter(e => e.word === restrictedKeb);71 return Promise.mapSeries(matchingKanjiElements, async kanjiElement => {72 if (!(await kanjiElement.hasKanjiRestrictedReadingElement(readingElement))) {73 return kanjiElement.addKanjiRestrictedReadingElement(readingElement);74 }75 });76 });77 } else if (kanjiElements && kanjiElements.length) {78 readingElement = kanjiRestrictedReadingElements.find(e => e.word === readingElementUniqueData.word);79 if (!readingElement) {80 readingElement = await models.JMdictReadingElement.create(readingElementUniqueData);81 }8283 return Promise.mapSeries(kanjiElements, async kanjiElement => {84 if (!(await kanjiElement.hasKanjiRestrictedReadingElement(readingElement))) {85 return kanjiElement.addKanjiRestrictedReadingElement(readingElement);86 }87 });88 } else {89 readingElementUniqueData.JMdictEntryId = entry.id;90 [readingElement] = await models.JMdictReadingElement.findOrCreate({91 where: readingElementUniqueData92 });93 }9495 readingElement.info = rawReadingElement.re_inf;96 // TODO: Change prioroty → priority97 readingElement.prioroty = rawReadingElement.re_pri;98 return readingElement.save();99 });100101 // Delete old senses102 let oldSenseElements = await entry.getAllSenseElements();103 await Promise.mapSeries(oldSenseElements, e => e.destroy);104105 let senseElements = await Promise.mapSeries(rawEntry.sense || [], async rawSenseElement => {106 let senseData = {107 partsOfSpeech: rawSenseElement.pos || [],108 fields: rawSenseElement.field || [],109 misc: rawSenseElement.misc || [],110 languageSources: rawSenseElement.lsource || [],111 dialects: rawSenseElement.dial || [],112 info: rawSenseElement.s_inf || []113 };114115 senseData.languageSources = senseData.languageSources.map(rawLanguageSourceValue => {116 if (_.isString(rawLanguageSourceValue)) {117 return {118 value: rawLanguageSourceValue119 };120 } else {121 let attributedValue = rawLanguageSourceValue['$'];122 attributedValue.value = rawLanguageSourceValue._;123 return attributedValue;124 }125 });126127 let senseElement = await models.JMdictSenseElement.create(senseData);128 await senseElement.setParentEntry(entry);129130 let glosses = (rawSenseElement.gloss || []).map(rawGlossValue => {131 if (_.isString(rawGlossValue)) {132 return {133 value: rawGlossValue,134 properties: {}135 };136 } else {137 return {138 value: rawGlossValue._,139 properties: rawGlossValue['$'] || {}140 };141 }142 });143144 let glossElements = await Promise.mapSeries(glosses, g => models.JMdictSenseGlossElement.create(g));145 senseElement.setGlosses(glossElements);146147 if (!rawSenseElement.stagk && !rawSenseElement.stagr) {148 await senseElement.setSenseEntry(entry);149 } else {150 if (rawSenseElement.stagk && rawSenseElement.stagk.length) {151 await Promise.mapSeries(rawSenseElement.stagk, async restrictedStagK => {152 let matchingKanjiElements = kanjiElements.filter(e => e.word === restrictedStagK);153 return Promise.mapSeries(matchingKanjiElements, e => e.addKanjiRestrictedSenseElement(senseElement));154 });155 }156157 if (rawSenseElement.stagr && rawSenseElement.stagr.length) {158 await Promise.mapSeries(rawSenseElement.stagr, async restrictedStagR => {159 let matchingReadingElements = readingElements.filter(e => e.word === restrictedStagR);160 return Promise.mapSeries(matchingReadingElements, e => e.addReadingRestrictedSenseElement(senseElement));161 });162 }163 }164165 return senseElement;166 });167168 iii++;169 console.log(`Completed Entry: ${iii} / ${dict.length} = ${ ((100.0 * iii) / dict.length).toFixed(2) }. [kanjiElements: ${kanjiElements.length}, readingElements: ${readingElements.length}, senseElements: ${senseElements.length}]`);170 }, { concurrency: 80 });171172 resolve();173 });174});

Full Screen

Full Screen

gulpfile.js

Source:gulpfile.js Github

copy

Full Screen

...41gulp.task('html-build', () =>42 loadData()43 // Build pages44 .then(data =>45 Promise.mapSeries(Object.keys(data.pages), slug => {46 const {[slug]: page} = data.pages;47 const template = path.join(gulpConfig.src.templates, slug + '.njk');48 const uri = path.join(slug);49 const context = {data, page};50 return renderPage(template, uri, context);51 }).then(() => data)52 )53 // Build projects54 .then(data =>55 Promise.mapSeries(Object.keys(data.projects), slug => {56 const {[slug]: page} = data.projects;57 const template = path.join(gulpConfig.src.templates, 'project.njk');58 const uri = path.join('work', slug);59 const context = {data, page};60 return renderPage(template, uri, context);61 })62 )63);64gulp.task('html', gulp.series('html-clean', 'html-build'));65// CSS66gulp.task('css-clean', () => fs.removeAsync(gulpConfig.dist.css));67gulp.task('css-build', () =>68 buildCss(path.join(gulpConfig.src.css, '**/*.scss'), gulpConfig.dist.css)69);70gulp.task('css', gulp.series('css-clean', 'css-build'));71// JS72gulp.task('js-clean', () => fs.removeAsync(gulpConfig.dist.js));73gulp.task('js-build', () =>74 globPromise(path.join(gulpConfig.src.js, '*.js')).then(files =>75 Promise.mapSeries(files, file => {76 const filename = path.basename(file);77 const basename = path.basename(file, path.extname(file));78 return buildJs({79 ...webpackConfigProd,80 entry: {81 [basename]: path.resolve(gulpConfig.src.js, filename),82 [basename + '.min']: path.resolve(gulpConfig.src.js, filename)83 },84 output: {85 filename: '[name].js',86 path: path.resolve(gulpConfig.dist.js)87 }88 });89 })90 )91);92gulp.task('js', gulp.series('js-clean', 'js-build'));93// Favicon94gulp.task('favicon-clean', () => Promise.resolve());95gulp.task('favicon-build', () =>96 globPromise(path.join(gulpConfig.src.favicon, '*'), {97 nodir: true98 }).then(files =>99 Promise.mapSeries(files, file =>100 fs.copyAsync(file, path.join(gulpConfig.dist.base, path.basename(file)), {101 preserveTimestamps: true102 })103 )104 )105);106gulp.task('favicon', gulp.series('favicon-clean', 'favicon-build'));107// Fonts108gulp.task('fonts-clean', () => fs.removeAsync(gulpConfig.dist.fonts));109gulp.task('fonts-build', () =>110 globPromise(path.join(gulpConfig.src.fonts, '**/*.{woff,woff2}'), {111 nodir: true112 }).then(files =>113 Promise.mapSeries(files, file =>114 fs.copyAsync(115 file,116 path.join(gulpConfig.dist.fonts, path.basename(file)),117 {preserveTimestamps: true}118 )119 )120 )121);122gulp.task('fonts', gulp.series('fonts-clean', 'fonts-build'));123// Icons124gulp.task('icons', buildIcons);125// Deletes derivate images126gulp.task('penrose-clean', () =>127 fs.removeAsync(path.join(gulpConfig.penrose.schemes.public.path, 'styles'))128);129// Creates derivative images130gulp.task('penrose-build', () =>131 Promise.mapSeries(Object.values(gulpConfig.penrose.tasks), task =>132 Promise.mapSeries(task.src.map(src => penrose.resolvePath(src)), src =>133 globPromise(src)134 )135 .then(groups =>136 groups137 .reduce((result, files) => result.concat(files), [])138 // Include only files inside public directory139 .filter(file => ~file.indexOf(gulpConfig.penrose.schemes.public.path))140 // Strip base dir from file path and add scheme141 .map(142 file =>143 'public://' +144 file.substring(gulpConfig.penrose.schemes.public.path.length)145 )146 .reduce(147 (result, src) =>148 result.concat(149 task.styles.map(styleName => {150 const style = gulpConfig.imageStyles[styleName];151 const dist = penrose.getStylePath(styleName, src);152 return {153 style,154 src,155 dist156 };157 })158 ),159 []160 )161 )162 .then(tasks =>163 Promise.mapSeries(tasks, task =>164 penrose.createDerivative(task.style, task.src, task.dist)165 )166 )167 )168);169// Deletes and creates derivative images170gulp.task('penrose', gulp.series('penrose-clean', 'penrose-build'));171// Build vendor files172gulp.task('vendor-clean', () => fs.removeAsync(gulpConfig.dist.vendor));173gulp.task('vendor-copy', copyVendor);174gulp.task('vendor-modernizr', buildModernizr);175gulp.task(176 'vendor',177 gulp.series('vendor-clean', 'vendor-copy', 'vendor-modernizr')...

Full Screen

Full Screen

buildGlyph.js

Source:buildGlyph.js Github

copy

Full Screen

...32 const svgDistDirs = []; // Destination directories of colorized SVG.33 let srcFiles;34 // Delete temp directories.35 return (36 Promise.mapSeries([tempDir1, tempDir2], function (file) {37 return fs.removeAsync(file);38 })39 .then(function () {40 const dirs = [tempDir1, tempDir2].concat(svgBuildsDist, pngBuildsDist);41 // Create temp and destination directories.42 return Promise.mapSeries(dirs, function (dir) {43 return fs.mkdirpAsync(dir);44 });45 })46 // Find source files.47 .then(function () {48 return multiGlob(config.src);49 })50 .then(function (files) {51 srcFiles = files;52 // If colorizing.53 if (colors.length) {54 return Promise.mapSeries(colors, function (color) {55 const svgDistDir = path.resolve(56 svgBuilds[0].dist,57 color.name.replace(/_/g, '-')58 );59 svgDistDirs.push(svgDistDir);60 return fs61 .mkdirpAsync(svgDistDir)62 .then(function () {63 return Promise.mapSeries(srcFiles, function (file) {64 // Add colors to filename for DirectoryColorfy.65 const extname = path.extname(file);66 const basename = path.basename(file, extname);67 const copy = path.resolve(68 tempDir1,69 basename + '.colors-' + color.name + extname70 );71 console.log(72 `Building SVG glyph: ${chalk.cyan(73 config.name74 )} > ${chalk.cyan(basename)} > ${chalk.cyan(color.name)}`75 );76 return fs.copyAsync(file, copy);77 });78 })79 .then(function () {80 return loadFiles([path.resolve(tempDir1, '*.svg')]);81 })82 .then(function (files) {83 return Promise.mapSeries(files, function (file) {84 // Minify SVG.85 return Promise.props(86 _.assign(file, {data: svgMin(file.data)})87 );88 });89 })90 .then(function (files) {91 return Promise.mapSeries(files, function (file) {92 return fs.writeFileAsync(file.path, file.data, 'utf-8');93 });94 })95 .then(function () {96 // Colorfy directory of SVGs.97 const dc = new DirectoryColorfy(tempDir1, tempDir2, {98 colors: {[color.name]: color.hex}99 });100 return dc.convert();101 })102 .then(function () {103 // Remove color suffix from SVG and move to color directory.104 return Promise.mapSeries(srcFiles, function (file) {105 const extname = path.extname(file);106 const basename = path.basename(file, extname);107 const srcPath = path.resolve(108 tempDir2,109 basename + '-' + color.name + '.svg'110 );111 const distPath = path.resolve(svgDistDir, basename + '.svg');112 return fs.renameAsync(srcPath, distPath);113 });114 });115 });116 }117 // If not colorizing (no colors were defined in config), then create118 // minified SVG without color applied.119 return Promise.mapSeries(files, function (file) {120 const extname = path.extname(file);121 const basename = path.basename(file);122 const svgDistPath = path.join(svgBuilds[0].dist, basename);123 console.log(124 `Building PNG glyph: ${chalk.cyan(config.name)} > ${chalk.cyan(125 path.basename(file, extname)126 )}`127 );128 return fs129 .readFileAsync(file, 'utf-8')130 .then(function (data) {131 // Minify SVG.132 return svgMin(data);133 })134 .then(function (data) {135 return fs.writeFileAsync(svgDistPath, data, 'utf-8');136 })137 .then(function () {138 if (pngBuilds.length) {139 return Promise.mapSeries(pngBuilds, function (pngBuild) {140 // Convert SVG to PNG.141 return svg2pngMin(svgDistPath, pngBuild.dist, pngBuild.scale);142 });143 }144 return Promise.resolve(true);145 });146 });147 })148 .then(function () {149 // If colorizing and generating PNG.150 if (pngBuilds.length && svgDistDirs.length) {151 const src = _.map(svgDistDirs, function (dir) {152 return path.resolve(dir, '*.svg');153 });154 const base = path.resolve(svgDistDirs[0], '..');155 return multiGlob(src).then(function (files) {156 return Promise.mapSeries(pngBuilds, function (pngBuild, i) {157 console.log(158 `Building PNG glyphs [${i + 1}/${159 pngBuilds.length160 }]: ${chalk.cyan(config.name)}`161 );162 return Promise.mapSeries(files, function (file) {163 const pngDistDir = path.dirname(164 path.join(pngBuild.dist, file.substring(base.length))165 );166 // Convert SVG to PNG.167 return svg2pngMin(file, pngDistDir, pngBuild.scale);168 });169 });170 });171 }172 return Promise.resolve(true);173 })174 .then(function () {175 let dirs = [tempDir1, tempDir2];176 // If no PNG builds, then delete PNG dist directories.177 if (!pngBuilds.length) {178 dirs = dirs.concat(pngBuildsDist);179 }180 // If no SVG builds, then delete SVG dist directories.181 if (!svgBuilds.length) {182 dirs = dirs.concat(svgBuildsDist);183 }184 // Clean up.185 return Promise.mapSeries(dirs, function (file) {186 return fs.removeAsync(file);187 });188 })189 );...

Full Screen

Full Screen

test.mapSeries.js

Source:test.mapSeries.js Github

copy

Full Screen

...12 order.push([key, value]);13 resolve(value * 2);14 }, DELAY * value));15 };16 const res = await Promise.mapSeries(collection, iterator);17 assert.strictEqual(Object.prototype.toString.call(res), '[object Array]');18 assert.deepStrictEqual(res, [2, 8, 4]);19 assert.deepStrictEqual(order, [20 [0, 1],21 [1, 4],22 [2, 2]23 ]);24 });25 it('should execute on synchronous', async () => {26 const collection = [1, 4, 2];27 const iterator = value => value * 2;28 const res = await Promise.mapSeries(collection, iterator);29 assert.strictEqual(Object.prototype.toString.call(res), '[object Array]');30 assert.deepStrictEqual(res, [2, 8, 4]);31 });32 it('should execute with object collection in series', async () => {33 const order = [];34 const collection = {35 task1: 1,36 task2: 4,37 task3: 238 };39 const iterator = (value, key) => {40 return new Promise(resolve => setTimeout(() => {41 order.push([key, value]);42 resolve(value * 2);43 }, DELAY * value));44 };45 const res = await Promise.mapSeries(collection, iterator);46 assert.strictEqual(Object.prototype.toString.call(res), '[object Array]');47 assert.deepStrictEqual(res, [2, 8, 4]);48 assert.deepStrictEqual(order, [49 ['task1', 1],50 ['task2', 4],51 ['task3', 2]52 ]);53 });54 it('should return an empty array if collection is an empty array', async () => {55 const iterator = value => {56 value.test();57 };58 const res = await Promise.mapSeries([], iterator);59 assert.strictEqual(Object.prototype.toString.call(res), '[object Array]');60 assert.strictEqual(res.length, 0);61 });62 it('should return an empty array if collection is an empty object', async () => {63 const iterator = value => {64 value.test();65 };66 const res = await Promise.mapSeries({}, iterator);67 assert.strictEqual(Object.prototype.toString.call(res), '[object Array]');68 assert.strictEqual(res.length, 0);69 });70 it('should return an empty array if collection is string', async () => {71 const iterator = value => {72 value.test();73 };74 const res = await Promise.mapSeries('test', iterator);75 assert.strictEqual(Object.prototype.toString.call(res), '[object Array]');76 assert.strictEqual(res.length, 0);77 });78 it('should catch a TypeError', async () => {79 const collection = [1, 4, 2];80 const iterator = value => {81 value.test();82 };83 try {84 await Promise.mapSeries(collection, iterator);85 assert.fail();86 } catch (e) {87 assert.ok(e instanceof TypeError);88 }89 });90 it('should execute even if arguments are not exists', () => {91 return Promise.mapSeries();92 });93});94parallel('#mapSeries', () => {95 it('should execute in series', async () => {96 const order = [];97 const collection = [1, 4, 2];98 const iterator = (value, key) => {99 return new Promise(resolve => setTimeout(() => {100 order.push([key, value]);101 resolve(value * 2);102 }, DELAY * value));103 };104 const res = await Promise.resolve(collection).mapSeries(iterator);105 assert.deepStrictEqual(res, [2, 8, 4]);...

Full Screen

Full Screen

monitor.js

Source:monitor.js Github

copy

Full Screen

...6 request = require('./request');7function start() {8 return getLords().then((lords) => {9 let emails = _.uniq(_.flatten(lords.map(lord => lord.emails)));10 return Promise.mapSeries(emails, email => {11 return request.get(`https://securenodes.eu.zensystem.io/api/grid/${email}/nodes`);12 }).then(responses => {13 let nodes = _.flatten(responses.map(resp => resp.rows));14 return nodes;15 }).then(securenodes => {16 return Promise.mapSeries(securenodes, node => {17 let nodeid = node.id;18 delete node.id;19 //return db.securenodes.updateAsync()20 return new Promise((resolve, reject) => {21 db.securenodes.update({ id: nodeid }, { $set: node }, { upsert: true, returnUpdatedDocs: true },22 (err, numAffected, affectedDocuments, upsert) => {23 if (err) {24 reject(err);25 } else {26 resolve({27 node: affectedDocuments,28 upsert29 });30 }31 });32 });33 });34 }).then((nodes) => {35 let paymentArr = [], chalArr = [], exceptionArr = [];36 let now = moment();37 nodes.forEach(node => {38 exceptionArr.push(node.node.id);39 if (node.upsert || !node.node.payments || node.node.payments.length == 0) {40 paymentArr.push(node.node.id);41 chalArr.push(node.node.id);42 } else {43 if (node.node.payments && node.node.payments.length) {44 let latestPayment = node.node.payments[0];45 if (latestPayment.status === 'paid'46 && latestPayment.paidat47 && moment(latestPayment.paidat).add(23, 'hour').isAfter(now)) {48 //skit49 } else {50 paymentArr.push(node.node.id);51 }52 }53 if (node.node.challenges && node.node.challenges.length) {54 let latestChal = node.node.challenges[0];55 if (latestChal.result !== 'pass'56 || !latestChal.received57 || moment(latestChal.received).add(25, 'hour').isBefore(now)){58 chalArr.push(node.node.id);59 }60 } else {61 chalArr.push(node.node.id);62 }63 }64 });//forEach65 let paymentPromise = Promise.mapSeries(paymentArr, paymentNodeId => {66 return request.get(`https://securenodes.eu.zensystem.io/api/grid/${paymentNodeId}/pmts`)67 .then(payment => {68 return {69 nodeid: paymentNodeId,70 payments: payment.rows,71 };72 });73 });74 let chalPromise = Promise.mapSeries(chalArr, chalNodeId => {75 return request.get(`https://securenodes.eu.zensystem.io/api/grid/${chalNodeId}/crs`)76 .then(chal => {77 return {78 nodeid: chalNodeId,79 chals: chal.rows,80 };81 });82 });83 let exceptionPromise = Promise.mapSeries(exceptionArr, exceptionNodeId => {84 return request.get(`https://securenodes.eu.zensystem.io/api/grid/${exceptionNodeId}/ex`)85 .then(ex => {86 return {87 nodeid: exceptionNodeId,88 chals: ex.rows,89 };90 });91 });92 return Promise.join(paymentPromise, chalPromise, exceptionPromise)93 .then(([payments, chals, exceptions]) => {94 return Promise.mapSeries(payments, payment => {95 return db.securenodes.updateAsync({id: payment.nodeid}, {$set: {payments: payment.payments}});96 }).then(() => {97 return Promise.mapSeries(chals, chal => {98 return db.securenodes.updateAsync({id: chal.nodeid}, {$set: {challenges: chal.chals}});99 });100 }).then(() => {101 return Promise.mapSeries(exceptions, exception => {102 return db.securenodes.updateAsync({id: exception.nodeid}, {$set: {exceptions: exception.chals}});103 });104 });105 }).then(db.compact.bind(db));106 });107 })108 .catch(err => {109 console.error(err);110 })111 .then(() => {112 return Promise.delay(300 * 1000).then(start);113 });114}115function getGlobalData() {...

Full Screen

Full Screen

loader.js

Source:loader.js Github

copy

Full Screen

1var Promise = require('bluebird'),2 fs = Promise.promisifyAll(require('fs')),3 _ = require('lodash'),4 colors = require('colors')5var core = {}6var loadModules = function (core)7 {8 console.log('1. Building module tree...'.blue);9 var objModule_Tree = {}10 var intSection_Index = 011 function loadSection (objModule_Tree, strSection_Name)12 {13 console.log(colors.blue('\t2.' + intSection_Index++ + ' Loading ' + strSection_Name + ' section:'))14 return Promise.mapSeries15 (16 _.keys(objModule_Tree),17 function (strModule_Name)18 {19 core[strModule_Name] = core[strModule_Name] || {}20 if (objModule_Tree[strModule_Name][strSection_Name])21 {22 core[strModule_Name][strSection_Name] = core[strModule_Name][strSection_Name] || {}23 console.log(('\t\t- ' + strModule_Name + ':').black)24 return Promise.mapSeries25 (26 objModule_Tree[strModule_Name][strSection_Name],27 function (strFile_Name)28 {29 var strFile_Path = './module/' + strModule_Name + '/' + strSection_Name + '/' + strFile_Name30 console.log(colors.red('\t\t\t' + strFile_Path))31 return require(strFile_Path)(core)32 }33 )34 }35 else36 return null37 }38 )39 }40 return fs.readdirAsync('./module').then41 (42 function (arystrModule_Name)43 {44 return Promise.mapSeries45 (46 arystrModule_Name,47 function (strModule_Name)48 {49 objModule_Tree[strModule_Name] = {}50 return fs.readdirAsync('./module/' + strModule_Name + '/').then51 (52 function (arystrSubmodule_Name)53 {54 return Promise.mapSeries55 (56 arystrSubmodule_Name,57 function (strSubmodule_Name)58 {59 return fs.readdirAsync('./module/' + strModule_Name + '/' + strSubmodule_Name).then60 (61 function (aryStr_File_Name)62 {63 objModule_Tree[strModule_Name][strSubmodule_Name] = aryStr_File_Name64 }65 )66 }67 )68 }69 )70 }71 );72 }73 )74 .then75 (76 function ()77 {78 console.log('2. Loading modules:'.blue)79 return Promise.mapSeries80 (81 [82 'initialize',83 'load',84 'controller',85 'route',86 'server'87 ],88 function (strSection_Name)89 {90 return loadSection(objModule_Tree, strSection_Name)91 }92 )93 }94 )95 };96console.log('0. Loading environment'.blue)97require('dotenv').load()98loadModules(core).then99 (100 function ()101 {102 console.log('Loading completed successfully'.blue)103 }...

Full Screen

Full Screen

seed-reviews.js

Source:seed-reviews.js Github

copy

Full Screen

1import {2 R, H, ApolloClient, gql, fetch, setContext, createHttpLink, InMemoryCache, Promise, reviews3} from './common'4const5{hackprague, others, goodreads} = reviews,6[uri] = R.props7([`API_URL`])8(process.env),9mutation = gql`10 mutation AddReview($input: AddReviewHydrationInput!) {11 addReviewHydration(input: $input) {12 success13 }14 }15`,16createReview = (client) => async (rev) => {17 // JSON.stringify (rev) |> console.log ('JSON.stringify (rev)', #)18 await client.mutate ({mutation, variables: {input: rev}})19},20createHackPragueReview = (client) => async (rev) => {21 // JSON.stringify (rev) |> console.log ('JSON.stringify (rev)', #)22 const _rev = R.omit ([`prerequisites`]) (H.renameKeys ({urls: `url_main`}) (rev))23 await client.mutate ({mutation, variables: {input: _rev}})24}25export default async (token) => {26 const authLink = setContext (() => ({27 headers: {authorization: `Bearer ${token}`}28 })),29 client = new ApolloClient ({30 link: authLink.concat (createHttpLink ({uri, fetch})),31 cache: new InMemoryCache()32 })33 // console.log (`Creating HackPrague reviews`)34 // // await Promise.mapSeries (R.slice (0) (100) (hackprague), createHackPragueReview (client))35 // await Promise.mapSeries (hackprague, createHackPragueReview (client))36 // console.log (`Successfully created HackPrague reviews`)37 // console.log (`Creating Other reviews`)38 // // await Promise.mapSeries (R.slice (0) (100) (others), createReview (client))39 // await Promise.mapSeries (others, createReview (client))40 // console.log (`Successfully created Other reviews`)41 console.log (`Creating Goodreads reviews`)42 await Promise.mapSeries (R.slice (0) (7198) (goodreads), createReview (client))43 // await Promise.mapSeries (goodreads, createReview (client))44 console.log (`Successfully created Goodreads reviews`)45 // console.log (R.length (hackprague))46 // console.log (R.length (others))47 // console.log (R.length (goodreads))...

Full Screen

Full Screen

tables.js

Source:tables.js Github

copy

Full Screen

...4function tables(session, tables) {5 const knex = session.knex;6 const schema = knex.schema;7 before(() => {8 return Promise.mapSeries(sortBy(tables, 'deleteIndex'), table => {9 return schema.dropTableIfExists(table.name);10 }).then(() => {11 return Promise.mapSeries(tables, table => {12 if (table.build) {13 return schema.createTable(table.name, table.build);14 }15 });16 }).then(() => {17 return Promise.mapSeries(tables, table => {18 return Promise.mapSeries(table.raw || [], raw => {19 return schema.raw(raw[session.dialect()]);20 });21 });22 });23 });24 beforeEach(() => {25 return Promise.mapSeries(sortBy(tables, 'deleteIndex'), table => {26 return knex(table.name).delete();27 });28 });29 after(() => {30 return Promise.mapSeries(sortBy(tables, 'deleteIndex'), table => {31 return schema.dropTableIfExists(table.name);32 });33 });34}35module.exports = {36 tables...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2 it('test', function() {3 cy.viewport(320, 480)4 cy.get('#navbar').should('be.visible')5 cy.viewport('ipad-2')6 cy.get('#navbar').should('be.visible')7 cy.viewport('macbook-15')8 cy.get('#navbar').should('be.visible')9 cy.viewport('iphone-6+')10 cy.get('#navbar').should('be.visible')11 cy.viewport('samsung-note9')12 cy.get('#navbar').should('be.visible')13 })14})15describe('Test', function() {16 it('test', function() {17 cy.viewport(320, 480)18 cy.get('#navbar').should('be.visible')19 cy.viewport('ipad-2')20 cy.get('#navbar').should('be.visible')21 cy.viewport('macbook-15')22 cy.get('#navbar').should('be.visible')23 cy.viewport('iphone-6+')24 cy.get('#navbar').should('be.visible')25 cy.viewport('samsung-note9')26 cy.get('#navbar').should('be.visible')27 })28})29describe('Test', function() {30 it('test', function() {31 cy.viewport(320, 480)32 cy.get('#navbar').should('be.visible')33 cy.viewport('ipad-2')34 cy.get('#navbar').should('be.visible')35 cy.viewport('macbook-15')36 cy.get('#navbar').should('be.visible')37 cy.viewport('iphone-6+')38 cy.get('#navbar').should('be.visible')39 cy.viewport('samsung-note9')40 cy.get('#navbar').should('be.visible')41 })42})43describe('Test', function() {44 it('test', function() {45 cy.viewport(320, 480)46 cy.get('#navbar').should('be.visible')47 cy.viewport('ipad-2')48 cy.get('#navbar').should('be.visible')49 cy.viewport('macbook-15')

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Promise.mapSeries', function () {2 it('works', function () {3 return Promise.mapSeries(values, (value) => {4 return new Promise((resolve) => {5 setTimeout(() => {6 resolve(value * 2)7 }, 100)8 })9 }).then((results) => {10 expect(results).to.deep.eq([2, 4, 6])11 })12 })13})14describe('Promise.mapSeries', function () {15 it('works', function () {16 return cy.wrap(Promise.mapSeries(values, (value) => {17 return new Promise((resolve) => {18 setTimeout(() => {19 resolve(value * 2)20 }, 100)21 })22 })).then((results) => {23 expect(results).to.deep.eq([2, 4, 6])24 })25 })26})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("Test", () => {2 it("should", () => {3 cy.wait(2000);4 cy.get("input[name='q']").type("cypress");5 cy.wait(2000);6 cy.get("input[name='btnK']").click();7 cy.wait(2000);8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Promise.mapSeries', () => {2 it('should resolve all promises in series', () => {3 () => cy.wrap(1),4 () => cy.wrap(2),5 () => cy.wrap(3),6 cy.Promise.mapSeries(promises, (promise) => {7 return promise().then((value) => {8 expect(value).to.be.a('number')9 })10 })11 })12})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Promise.mapSeries', () => {2 it('should map over an array of values', () => {3 return cy.wrap(arr).mapSeries((num) => {4 return new Promise((resolve) => {5 setTimeout(() => {6 resolve(num * 2)7 }, 1000)8 })9 }).should('deep.equal', [2, 4, 6, 8, 10])10 })11})12describe('Promise.map', () => {13 it('should map over an array of values', () => {14 return cy.wrap(arr).map((num) => {15 return new Promise((resolve) => {16 setTimeout(() => {17 resolve(num * 2)18 }, 1000)19 })20 }).should('deep.equal', [2, 4, 6, 8, 10])21 })22})23describe('Promise.filter', () => {24 it('should filter an array of values', () => {25 return cy.wrap(arr).filter((num) => {26 return new Promise((resolve) => {27 setTimeout(() => {28 resolve(num % 2 === 0)29 }, 1000)30 })31 }).should('deep.equal', [2, 4])32 })33})34describe('Promise.each', () => {35 it('should iterate over an array of values', () => {36 return cy.wrap(arr).each((num) => {37 return new Promise((resolve) => {38 setTimeout(() => {39 resolve(num

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Promise.mapSeries', function() {2 it('Promise.mapSeries', function() {3 cy.get('tr td:nth-child(2)').each(($el, index, $list) => {4 const text = $el.text()5 if (text.includes('Python')) {6 cy.get('tr td:nth-child(2)').eq(index).next().then(function(price) {7 const priceText = price.text()8 expect(priceText).to.equal('25')9 })10 }11 })12 })13})

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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