Best JavaScript code snippet using qawolf
20190807152808_defaultTimeUpdate.js
Source:20190807152808_defaultTimeUpdate.js  
2 * The purpose of this update is to add the defaultTime (current_timestamp()) to all date-based functions that this would make sense for.3*/4exports.up = async (knex, Promise) => {5    // Modify Users6    await knex.schema.alterTable("users", (t) => {7        t.dateTime("user_joindate").notNullable().defaultTo(knex.fn.now()).alter();8        t.dateTime("user_lastonline").notNullable().defaultTo(knex.fn.now()).alter();9        t.dateTime("user_birthdate").notNullable().defaultTo(knex.fn.now()).alter();10    });11    // Modify user_avatar12    await knex.schema.alterTable("user_avatar", (table) => {13        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();14    });15    // Modify user_emails16    await knex.schema.alterTable("user_emails", (table) => {17        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();18    });19    // Modify user_inventory20    await knex.schema.alterTable("user_inventory", (table) => {21        table.dateTime("date_created").notNullable().defaultTo(knex.fn.now()).alter();22    });23    // Modify user_ip24    await knex.schema.alterTable("user_ip", (table) => {25        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();26    });27    // Modify user_ip28    await knex.schema.alterTable("user_messages", (table) => {29        table.dateTime("message_date").notNullable().defaultTo(knex.fn.now()).alter();30    });31    // Modify user_status32    await knex.schema.alterTable("user_status", (table) => {33        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();34    });35    // Modify catalog36    await knex.schema.alterTable("catalog", (table) => {37        table.dateTime("date_created").notNullable().defaultTo(knex.fn.now()).alter();38    });39    // Modify catalog_comments40    await knex.schema.alterTable("catalog_comments", (table) => {41        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();42    });43    // Modify forum_threads44    await knex.schema.alterTable("forum_threads", (table) => {45        table.dateTime("date_created").notNullable().defaultTo(knex.fn.now()).alter();46        table.dateTime("date_edited").notNullable().defaultTo(knex.fn.now()).alter();47    });48    // Modify forum_posts49    await knex.schema.alterTable("forum_posts", (table) => {50        table.dateTime("date_created").notNullable().defaultTo(knex.fn.now()).alter();51        table.dateTime("date_edited").notNullable().defaultTo(knex.fn.now()).alter();52    });53    // Modify friendships54    await knex.schema.alterTable("friendships", (table) => {55        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();56    });57    // Modify groups58    await knex.schema.alterTable("groups", (table) => {59        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();60    });61    // Modify group_shout62    await knex.schema.alterTable("group_shout", (table) => {63        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();64    });65    // Modify group_wall66    await knex.schema.alterTable("group_wall", (table) => {67        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();68    });69    // Modify moderation_ban70    await knex.schema.alterTable("moderation_ban", (table) => {71        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();72    });73    // Modify moderation_currency74    await knex.schema.alterTable("moderation_currency", (table) => {75        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();76    });77    // Modify moderation_give78    await knex.schema.alterTable("moderation_give", (table) => {79        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();80    });81    // Modify thumbnails82    await knex.schema.alterTable("thumbnails", (table) => {83        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();84    });85    // Modify trades86    await knex.schema.alterTable("trades", (table) => {87        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();88    });89    // Modify transactions90    await knex.schema.alterTable("transactions", (table) => {91        table.dateTime("date").notNullable().defaultTo(knex.fn.now()).alter();92    });93};94exports.down = async (knex, Promise) => {95    // Un-modify Users96    await knex.schema.alterTable("users", (t) => {97        t.dateTime("user_joindate").notNullable().alter();98        t.dateTime("user_lastonline").notNullable().alter();99        t.dateTime("user_birthdate").notNullable().alter();100    });101    // Un-modify user_avatar102    await knex.schema.alterTable("user_avatar", (table) => {103        table.dateTime("date").notNullable().alter();104    });105    // Un-modify user_emails106    await knex.schema.alterTable("user_emails", (table) => {107        table.dateTime("date").notNullable().alter();108    });109    // Un-modify user_inventory110    await knex.schema.alterTable("user_inventory", (table) => {111        table.dateTime("date").notNullable().alter();112    });113    // Un-modify user_ip114    await knex.schema.alterTable("user_ip", (table) => {115        table.dateTime("date").notNullable().alter();116    });117    // Un-modify user_messages118    await knex.schema.alterTable("user_messages", (table) => {119        table.dateTime("message_date").notNullable().alter();120    });121    // Un-modify user_status122    await knex.schema.alterTable("user_status", (table) => {123        table.dateTime("date").notNullable().alter();124    });125    // Un-modify catalog126    await knex.schema.alterTable("catalog", (table) => {127        table.dateTime("date_created").notNullable().alter();128    });129    // Un-modify catalog130    await knex.schema.alterTable("catalog_comments", (table) => {131        table.dateTime("date").notNullable().alter();132    });133    // Un-modify forum_threads134    await knex.schema.alterTable("forum_threads", (table) => {135        table.dateTime("date_created").notNullable().alter();136        table.dateTime("date_edited").notNullable().alter();137    });138    // Un-modify forum_posts139    await knex.schema.alterTable("forum_posts", (table) => {140        table.dateTime("date_created").notNullable().alter();141        table.dateTime("date_edited").notNullable().alter();142    });143    // Un-modify friendships144    await knex.schema.alterTable("friendships", (table) => {145        table.dateTime("date").notNullable().alter();146    });147    // Un-Modify groups148    await knex.schema.alterTable("groups", (table) => {149        table.dateTime("date").notNullable().alter();150    });151    // Un-Modify group_shout152    await knex.schema.alterTable("group_shout", (table) => {153        table.dateTime("date").notNullable().alter();154    });155    // Un-Modify group_wall156    await knex.schema.alterTable("group_wall", (table) => {157        table.dateTime("date").notNullable().alter();158    });159    // Un-Modify moderation_ban160    await knex.schema.alterTable("moderation_ban", (table) => {161        table.dateTime("date").notNullable().alter();162    });163    // Un-Modify moderation_currency164    await knex.schema.alterTable("moderation_currency", (table) => {165        table.dateTime("date").notNullable().alter();166    });167    // Un-Modify moderation_give168    await knex.schema.alterTable("moderation_give", (table) => {169        table.dateTime("date").notNullable().alter();170    });171    // Un-Modify thumbnails172    await knex.schema.alterTable("thumbnails", (table) => {173        table.dateTime("date").notNullable().alter();174    });175    // Un-Modify trades176    await knex.schema.alterTable("trades", (table) => {177        table.dateTime("date").notNullable().alter();178    });179    // Un-Modify transactions180    await knex.schema.alterTable("transactions", (table) => {181        table.dateTime("date").notNullable().alter();182    });...20200212081516_migrateTonsOfColumnsToUtf.js
Source:20200212081516_migrateTonsOfColumnsToUtf.js  
1/**2 * Change encoding from some latin thing to utf8mb4_unicode_ci3 */4exports.up = async (knex, Promise) => {5    await knex.schema.alterTable('catalog', (t) => {6        t.string('name', 256).collate('utf8mb4_unicode_ci').alter();7        t.string('description', 1024).collate('utf8mb4_unicode_ci').alter();8    });9    await knex.schema.alterTable('catalog_comments', (t) => {10        t.text('comment').collate('utf8mb4_unicode_ci').alter();11    });12    await knex.schema.alterTable('chat_messages', (t) => {13        t.string('content', 255).collate('utf8mb4_unicode_ci').alter();14    });15    await knex.schema.alterTable('forum_posts', (t) => {16        t.text('post_body').collate('utf8mb4_unicode_ci').alter();17    });18    await knex.schema.alterTable('forum_subcategories', (t) => {19        t.string('title',64).collate('utf8mb4_unicode_ci').alter();20        t.string('description',256).collate('utf8mb4_unicode_ci').alter();21    });22    await knex.schema.alterTable('forum_threads', (t) => {23        t.string('title',64).collate('utf8mb4_unicode_ci').alter();24    });25    await knex.schema.alterTable('groups', (t) => {26        t.string('name',75).collate('utf8mb4_unicode_ci').alter();27        t.text('description').collate('utf8mb4_unicode_ci').alter();28    });29    await knex.schema.alterTable('group_roles', (t) => {30        t.string('name',50).collate('utf8mb4_unicode_ci').alter();31        t.string('description',100).collate('utf8mb4_unicode_ci').alter();32    });33    await knex.schema.alterTable('group_shout', (t) => {34        t.text('shout').collate('utf8mb4_unicode_ci').alter();35    });36    await knex.schema.alterTable('group_wall', (t) => {37        t.text('content').collate('utf8mb4_unicode_ci').alter();38    });39    await knex.schema.alterTable('user_messages', (t) => {40        t.string('message_subject', 128).collate('utf8mb4_unicode_ci').alter();41        t.text('message_body').collate('utf8mb4_unicode_ci').alter();42    });43    await knex.schema.alterTable('user_staff_comments', (t) => {44        t.text('comment').collate('utf8mb4_unicode_ci').alter();45    });46    await knex.schema.alterTable('user_status', (t) => {47        t.string('status',255).collate('utf8mb4_unicode_ci').alter();48    });49    await knex.schema.alterTable('users', (t) => {50        t.string('user_status',128).collate('utf8mb4_unicode_ci').alter();51        t.string('user_blurb',1024).collate('utf8mb4_unicode_ci').alter();52    });53};54exports.down = async (knex, Promise) => {55    await knex.schema.alterTable('catalog', (t) => {56        t.string('name', 512).collate('latin1_swedish_ci').alter();57        t.string('description', 4096).collate('latin1_swedish_ci').alter();58    });59    await knex.schema.alterTable('catalog_comments', (t) => {60        t.text('comment').collate('latin1_swedish_ci').alter();61    });62    await knex.schema.alterTable('chat_messages', (t) => {63        t.string('content', 255).collate('latin1_swedish_ci').alter();64    });65    await knex.schema.alterTable('forum_posts', (t) => {66        t.text('post_body').collate('latin1_swedish_ci').alter();67    });68    await knex.schema.alterTable('forum_subcategories', (t) => {69        t.string('title',64).collate('latin1_swedish_ci').alter();70        t.string('description',256).collate('latin1_swedish_ci').alter();71    });72    await knex.schema.alterTable('forum_threads', (t) => {73        t.string('title',64).collate('latin1_swedish_ci').alter();74    });75    await knex.schema.alterTable('groups', (t) => {76        t.string('name',75).collate('latin1_swedish_ci').alter();77        t.text('description').collate('latin1_swedish_ci').alter();78    });79    await knex.schema.alterTable('group_roles', (t) => {80        t.string('name',50).collate('latin1_swedish_ci').alter();81        t.string('description',100).collate('latin1_swedish_ci').alter();82    });83    await knex.schema.alterTable('group_shout', (t) => {84        t.text('shout').collate('latin1_swedish_ci').alter();85    });86    await knex.schema.alterTable('group_wall', (t) => {87        t.text('content').collate('latin1_swedish_ci').alter();88    });89    await knex.schema.alterTable('user_messages', (t) => {90        t.string('message_subject', 128).collate('latin1_swedish_ci').alter();91        t.text('message_body').collate('latin1_swedish_ci').alter();92    });93    await knex.schema.alterTable('user_staff_comments', (t) => {94        t.text('comment').collate('latin1_swedish_ci').alter();95    });96    await knex.schema.alterTable('user_status', (t) => {97        t.string('status',255).collate('latin1_swedish_ci').alter();98    });99    await knex.schema.alterTable('users', (t) => {100        t.string('user_status',128).collate('utf8mb4_bin').alter(); // idk why this was binary101        t.string('user_blurb',1024).collate('latin1_swedish_ci').alter();102    });...20180402170153_make-varchar-uniform.js
Source:20180402170153_make-varchar-uniform.js  
1exports.up = async knex => {2  const dbChanges = [3    knex.schema.alterTable('articles', table => {4      table5        .string('slug')6        .notNullable()7        .alter();8      table9        .string('title')10        .notNullable()11        .alter();12    }),13    knex.schema.alterTable('categories', table => {14      table15        .string('slug')16        .notNullable()17        .alter();18      table19        .string('name')20        .notNullable()21        .alter();22    }),23    knex.schema.alterTable('info_pages', table => {24      table25        .string('slug')26        .notNullable()27        .alter();28      table29        .string('title')30        .notNullable()31        .alter();32    }),33    knex.schema.alterTable('issues', table => {34      table35        .string('name')36        .notNullable()37        .alter();38    }),39    knex.schema.alterTable('semesters', table => {40      table41        .string('name')42        .notNullable()43        .alter();44    }),45    knex.schema.alterTable('staff', table => {46      table47        .string('slug')48        .notNullable()49        .alter();50      table51        .string('name')52        .notNullable()53        .alter();54      table.string('job_title').alter();55      table.string('biography', 1000).alter();56      table.string('image_url').alter();57    }),58    knex.schema.alterTable('tags', table => {59      table60        .string('name')61        .notNullable()62        .alter();63      table64        .string('slug')65        .notNullable()66        .alter();67    }),68    knex.schema.alterTable('teams', table => {69      table70        .string('name')71        .notNullable()72        .alter();73      table74        .string('slug')75        .notNullable()76        .alter();77    }),78  ];79  await Promise.all(dbChanges);80};81exports.down = async knex => {82  const dbChanges = [83    knex.schema.alterTable('articles', table => {84      table85        .string('slug', 150)86        .notNullable()87        .alter();88      table89        .string('title', 150)90        .notNullable()91        .alter();92    }),93    knex.schema.alterTable('categories', table => {94      table95        .string('slug', 70)96        .notNullable()97        .alter();98      table99        .string('name', 70)100        .notNullable()101        .alter();102    }),103    knex.schema.alterTable('info_pages', table => {104      table105        .string('slug', 70)106        .notNullable()107        .alter();108      table109        .string('title', 70)110        .notNullable()111        .alter();112    }),113    knex.schema.alterTable('issues', table => {114      table115        .string('name', 70)116        .notNullable()117        .alter();118    }),119    knex.schema.alterTable('semesters', table => {120      table121        .string('name', 70)122        .notNullable()123        .alter();124    }),125    knex.schema.alterTable('staff', table => {126      table127        .string('slug', 70)128        .notNullable()129        .alter();130      table131        .string('name', 70)132        .notNullable()133        .alter();134      table.string('job_title', 70).alter();135      table.string('biography', 400).alter();136      table.text('image_url').alter();137    }),138    knex.schema.alterTable('tags', table => {139      table140        .string('name', 150)141        .notNullable()142        .alter();143      table144        .string('slug', 150)145        .notNullable()146        .alter();147    }),148    knex.schema.alterTable('teams', table => {149      table150        .string('name', 70)151        .notNullable()152        .alter();153      table154        .string('slug', 70)155        .notNullable()156        .alter();157    }),158  ];159  await Promise.all(dbChanges);...20201028A-remove-collection-foreign-keys.ts
Source:20201028A-remove-collection-foreign-keys.ts  
1import Knex from 'knex';2export async function up(knex: Knex) {3	await knex.schema.alterTable('directus_fields', (table) => {4		table.dropForeign(['collection']);5	});6	await knex.schema.alterTable('directus_activity', (table) => {7		table.dropForeign(['collection']);8	});9	await knex.schema.alterTable('directus_permissions', (table) => {10		table.dropForeign(['collection']);11	});12	await knex.schema.alterTable('directus_presets', (table) => {13		table.dropForeign(['collection']);14	});15	await knex.schema.alterTable('directus_relations', (table) => {16		table.dropForeign(['one_collection']);17		table.dropForeign(['many_collection']);18	});19	await knex.schema.alterTable('directus_revisions', (table) => {20		table.dropForeign(['collection']);21	});22}23export async function down(knex: Knex) {24	await knex.schema.alterTable('directus_fields', (table) => {25		table.foreign('collection').references('directus_collections.collection');26	});27	await knex.schema.alterTable('directus_activity', (table) => {28		table.foreign('collection').references('directus_collections.collection');29	});30	await knex.schema.alterTable('directus_permissions', (table) => {31		table.foreign('collection').references('directus_collections.collection');32	});33	await knex.schema.alterTable('directus_presets', (table) => {34		table.foreign('collection').references('directus_collections.collection');35	});36	await knex.schema.alterTable('directus_relations', (table) => {37		table.foreign('one_collection').references('directus_collections.collection');38		table.foreign('many_collection').references('directus_collections.collection');39	});40	await knex.schema.alterTable('directus_revisions', (table) => {41		table.foreign('collection').references('directus_collections.collection');42	});...Using AI Code Generation
1const {chromium} = require('playwright');2(async () => {3  const browser = await chromium.launch();4  const context = await browser.newContext();5  const page = await context.newPage();6  await page.click('text=New Transaction');7  await page.type('input[name="amount"]', '100');8  await page.type('input[name="description"]', 'test');9  await page.click('text=Submit');10  await page.click('text=New Transaction');11  await page.type('input[name="amount"]', '200');12  await page.type('input[name="description"]', 'test2');13  await page.click('text=Submit');14  await page.click('text=New Transaction');15  await page.type('input[name="amount"]', '300');16  await page.type('input[name="description"]', 'test3');17  await page.click('text=Submit');18  await page.click('text=New Transaction');19  await page.type('input[name="amount"]', '400');20  await page.type('input[name="description"]', 'test4');21  await page.click('text=Submit');22  await page.click('text=New Transaction');23  await page.type('input[name="amount"]', '500');24  await page.type('input[name="description"]', 'test5');25  await page.click('text=Submit');26  await page.click('text=New Transaction');27  await page.type('input[name="amount"]', '600');28  await page.type('input[name="description"]', 'test6');29  await page.click('text=Submit');30  await page.click('text=New Transaction');31  await page.type('input[name="amount"]', '700');32  await page.type('input[name="description"]', 'test7');33  await page.click('text=Submit');34  await page.click('text=New Transaction');35  await page.type('input[name="amount"]', '800');36  await page.type('input[name="description"]', 'test8');37  await page.click('text=Submit');38  await page.click('text=New Transaction');39  await page.type('input[name="amount"]', '900');40  await page.type('input[name="description"]', 'test9');41  await page.click('text=Submit');42  await page.click('text=New TransactionUsing AI Code Generation
1const { launch } = require("qawolf");2const selectors = require("./selectors/test");3describe('test', () => {4  let browser;5  beforeAll(async () => {6    browser = await launch();7  });8  afterAll(async () => {9    await browser.close();10  });11  it('test', async () => {12    const context = await browser.newContext();13    const page = await context.newPage();14    await page.click(selectors[0]);15    await page.click(selectors[1]);16    await page.click(selectors[2]);17    await page.click(selectors[3]);18    await page.click(selectors[4]);19    await page.click(selectors[5]);20    await page.click(selectors[6]);21    await page.click(selectors[7]);22    await page.click(selectors[8]);23    await page.click(selectors[9]);24    await page.click(selectors[10]);25    await page.click(selectors[11]);26    await page.click(selectors[12]);27    await page.click(selectors[13]);28    await page.click(selectors[14]);29    await page.click(selectors[15]);30    await page.click(selectors[16]);31    await page.click(selectors[17]);32    await page.click(selectors[18]);33    await page.click(selectors[19]);34    await page.click(selectors[20]);35    await page.click(selectors[21]);36    await page.click(selectors[22]);Using AI Code Generation
1const { create } = require("qawolf");2const selectors = require("../selectors/test");3describe('test', () => {4  let browser;5  beforeAll(async () => {6    browser = await create();7  });8  afterAll(async () => {9    await browser.close();10  });11  it('test', async () => {12    const page = await browser.newPage();13    await page.click(selectors[0]);14    await page.type(selectors[0], "Hello World");15    await page.click(selectors[1]);16    await page.type(selectors[1], "Hello World");17    await page.click(selectors[2]);18    await page.type(selectors[2], "Hello World");19    await page.click(selectors[3]);20    await page.type(selectors[3], "Hello World");21    await page.click(selectors[4]);22    await page.type(selectors[4], "Hello World");23    await page.click(selectors[5]);24    await page.type(selectors[5], "Hello World");25    await page.click(selectors[6]);26    await page.type(selectors[6], "Hello World");27    await page.click(selectors[7]);28    await page.type(selectors[7], "Hello World");29    await page.click(selectors[8]);30    await page.type(selectors[8], "Hello World");31    await page.click(selectors[9]);32    await page.type(selectors[9], "Hello World");33    await page.click(selectors[10]);34    await page.type(selectors[10], "Hello World");35    await page.click(selectors[11]);36    await page.type(selectors[11], "Hello World");37    await page.click(selectors[12]);38    await page.type(selectors[12], "Hello World");39    await page.click(selectors[13]);40    await page.type(selectors[13], "Hello World");41    await page.click(selectors[14]);42    await page.type(selectors[14], "Hello World");43    await page.click(selectors[15]);44    await page.type(selectors[15], "Hello World");45    await page.click(selectors[16]);46    await page.type(selectors[16], "Hello World");47    await page.click(selectors[17]);48    await page.type(selectors[17], "Hello World");49    await page.click(selectorsUsing AI Code Generation
1const { test, expect } = require('@playwright/test');2const { createTable } = require('knex');3test.describe('My first test suite', () => {4  test('My first test', async ({ page }) => {5    await page.click('text=Get started');6    await page.click('text=Docs');7    await page.click('text=API');8    await page.click('text=Test');Using AI Code Generation
1const knex = require("knex");2const config = require("./knexfile.js");3const env = "development";4const connection = knex(config[env]);5const table = "users";6const columnName = "password";7const columnType = "string";8connection.schema.alterTable(table, (table) => {9  table[columnType](columnName);10});Using AI Code Generation
1const qawolf = require('qawolf');2const knex = require('knex');3const { createTable } = require('knex');4const { alterTable } = require('knex');5const { dropTable } = require('knex');6describe('test', () => {7  let browser;8  let context;9  let page;10  beforeAll(async () => {11    browser = await qawolf.launch();12    context = await browser.newContext();13    page = await context.newPage();14  });15  afterAll(async () => {16    await browser.close();17  });18  it('test', async () => {19    const context = await browser.newContext();20    const page = await context.newPage();21    await page.click('text=API Reference');22    await page.click('text=Schema');23    await page.click('Using AI Code Generation
1const knex = require('knex')({2  connection: {3  }4});5const run = async () => {6    .createTable('test', table => {7      table.increments('id');8      table.string('name');9      table.integer('age').defaultTo(0);10    })11    .then(() => {12      console.log('Table created');13    })14    .catch(err => {15      console.error(err);16    });17    .dropTable('test')18    .then(() => {19      console.log('Table dropped');20    })21    .catch(err => {22      console.error(err);23    });24};25run();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!!
