How to use dryRun method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

main.js

Source:main.js Github

copy

Full Screen

1#!/usr/bin/env node2const yargs = require('yargs')3const AWS = require('aws-sdk')4const bunyan = require('bunyan')5const Promise = require('bluebird')6const _ = require('lodash')7let log8const efs = new AWS.EFS({ apiVersion: '2015-02-01', region: process.env.AWS_REGION })9const ec2 = new AWS.EC2({ apiVersion: '2016-11-15' })10const elb = new AWS.ELBv2({ apiVersion: '2015-12-01' });11const elbClassic = new AWS.ELB();12const yargsFunc = (yargs) => {13 //yargs.positional('vpc-id', { describe: 'ID of the VPC', default: null })14}15yargs16 .command('delete [vpc-id]', 'Delete the VPC and all dependencies', yargsFunc, async (argv) => {17 const stream = argv.logToStdout ? process.stdout : process.stderr18 log = bunyan.createLogger({ name: "delete-vpc", level: argv.logLevel, stream })19 argv.dryRun = false;20 await deleteEC2Instances(argv.vpcId, argv.dryRun) // Remove Instances21 await deleteELBs(argv.vpcId, argv.dryRun) // Remove Load Balancers22 await deleteELBsClassic(argv.vpcId, argv.dryRun) // Remove Load Balancers23 await deleteEFS(argv.vpcId, argv.dryRun) // Remove EFS volumes24 await deleteNATGateways(argv.vpcId, argv.dryRun) // Remove NAT Gateways25 await deleteNetworkInterfaces(argv.vpcId, argv.dryRun) // Remove Network Interfaces 26 await deleteSecurityGroups(argv.vpcId, argv.dryRun) // Remove Instances27 await deleteInternetGateways(argv.vpcId, argv.dryRun) // Remove Internet Gateways28 await deleteSubnets(argv.vpcId, argv.dryRun)29 await deleteRouteTables(argv.vpcId, argv.dryRun)30 await deleteVPCEndpoints(argv.vpcId, argv.dryRun)31 await deleteVPC(argv.vpcId, argv.dryRun) // Remove VPC32 //await releaseEIPs(argv.vpcId, argv.dryRun) // Remove Instances33 //console.log('VPC Deleted');34 })35 .option('log-level', { describe: 'Log level (debug, trace, info, warn, error)', default: 'info' })36 .option('log-to-stdout', { describe: 'Output logs to STDOUT instead of STDERR', default: true })37 .argv38async function releaseEIPs(VpcId, DryRun) {39 console.log('Releasing EIPs instances .... ')40 const params = {41 Filters: [42 {43 Name: 'domain',44 Values: [ 'vpc' ]45 }]46 };47 const response = await Promise.fromCallback(cb => ec2.describeAddresses(params, cb))48 await Promise.map(response.Addresses, async (item) => {49 const allocationID = item.AllocationId50 const releaseParams = { DryRun, AllocationId:allocationID }51 return $(ec2, 'releaseAddress', releaseParams, { allowedErrorCodes: ['OperationNotPermitted','InvalidAttachmentID.NotFound'], retryErrorCodes: ['AuthFailure','UnsupportedOperation','InvalidParameterValue','OperationalError'] }) 52 })53}54 55async function deleteEC2Instances(vpcId, DryRun) {56 console.log('Deleting EC2 instances .... ')57 this.log = log.child({ methods: 'deleteEC2Instances', vpcId });58 this.log.trace('Start deleting EC2 instances')59 const filterParams = {60 Filters: [61 {62 Name: 'vpc-id',63 Values: [ vpcId ]64 }]65 }66 this.log.trace('Filter Params', { filterParams })67 const reservations = await Promise.fromCallback(cb => ec2.describeInstances(filterParams, cb))68 const instancesMap = reservations.Reservations.reduce((accumulator, current) => {69 current.Instances.forEach(i => { accumulator[i.InstanceId] = i })70 return accumulator71 }, {})72 const Ids = Object.keys(instancesMap)73 this.log.trace('Instances', { Ids })74 if (Ids.length === 0) {75 this.log.trace('No instances to delete')76 return []77 }78 const deleteParams = { InstanceIds:Ids, DryRun }79 this.log.trace('DeleteParams', { deleteParams })80 return $(ec2, 'terminateInstances', deleteParams)81}82async function deleteELBs(vpcId, DryRun) {83 console.log('Deleting ELBs non-classic instances .... ')84 this.log = log.child({ methods: 'deleteELBs', vpcId });85 this.log.trace('Start')86 const elbs = await Promise.fromCallback(cb => elb.describeLoadBalancers({}, cb))87 const elbsInVPC = elbs.LoadBalancers.filter(x => x.VpcId === vpcId) 88 89 return await Promise.map(elbsInVPC, async (elbInstance) => {90 const deleteParams = {91 LoadBalancerArn: elbInstance.LoadBalancerArn92 }93 94 if (DryRun) {95 this.log.info('Dry run. Deleteing ELB', { name: elbInstance.LoadBalancerName })96 return97 }98 return await $(elb, 'deleteLoadBalancer', deleteParams)99 })100}101async function deleteELBsClassic(vpcId, DryRun) {102 console.log('Deleting ELBs classic instances .... ')103 this.log = log.child({ methods: 'deleteELBs', vpcId });104 this.log.trace('Start')105 const elbs = await Promise.fromCallback(cb => elbClassic.describeLoadBalancers({}, cb))106 const elbsInVPC = elbs.LoadBalancerDescriptions.filter(x => x.VPCId === vpcId) 107 108 109 return await Promise.map(elbsInVPC, async (elbInstance) => {110 const deleteParams = {111 LoadBalancerName: elbInstance.LoadBalancerName112 }113 114 if (DryRun) {115 this.log.info('Dry run. Deleteing ELB', { name: elbInstance.LoadBalancerName })116 return117 }118 return await $(elbClassic, 'deleteLoadBalancer', deleteParams)119 })120}121async function deleteVPCEndpoints(VpcId, DryRun) {122 console.log('Deleting VPC endpoint instances .... ')123 this.log = log.child({ methods: 'deleteVpcEndpoints', VpcId, DryRun });124 const params = {125 Filters: [126 {127 Name: 'vpc-id',128 Values: [ VpcId ]129 }]130 };131 const response = await Promise.fromCallback(cb => ec2.describeVpcEndpoints(params, cb))132 133 const endPointIds = response.VpcEndpoints.map(x => x.VpcEndpointId)134 135 await Promise.map(endPointIds, async (id) => {136 const params = { VpcEndpointIds:[id], DryRun };137 //const detachParams = Object.assign({}, params, { VpcId })138 //await $(ec2, 'deleteVpcEndpoints', detachParams)139 await $(ec2, 'deleteVpcEndpoints', params)140 })141 this.log.trace(`endPointIds succesfuly deleted DryRun: ${DryRun}`)142 return endPointIds143}144async function deleteInternetGateways(VpcId, DryRun) {145 console.log('Deleting IG instances .... ')146 this.log = log.child({ methods: 'deleteInternetGateways', VpcId, DryRun });147 this.log.trace('Start deleting internet gateways')148 const params = {149 Filters: [150 {151 Name: "attachment.vpc-id",152 Values: [ VpcId ]153 }154 ]155 };156 const response = await Promise.fromCallback(cb => ec2.describeInternetGateways(params, cb))157 const InternetGatewayIds = response.InternetGateways.map(x => x.InternetGatewayId)158 this.log.trace('Internet Gateway Ids', { InternetGatewayIds })159 await Promise.map(InternetGatewayIds, async (id) => {160 const params = { InternetGatewayId:id, DryRun };161 const detachParams = Object.assign({}, params, { VpcId })162 await $(ec2, 'detachInternetGateway', detachParams)163 await $(ec2, 'deleteInternetGateway', params)164 })165 this.log.trace(`InternetGateways succesfuly deleted DryRun: ${DryRun}`)166 return InternetGatewayIds167}168async function deleteEFS (vpcId, DryRun) {169 console.log('Deleting EFS instances .... ')170 this.log = log.child({ methods: 'deleteEFS', vpcId, DryRun });171 this.log.trace('Start deleting EFS Filesystems')172 const response = await Promise.fromCallback(cb => efs.describeFileSystems({}, cb))173 const fileSystemIds = response.FileSystems.map(x => x.FileSystemId)174 this.log.trace('fileSystemIds', { fileSystemIds })175 const mountTargets = await Promise.reduce(fileSystemIds, async (memo, FileSystemId) => {176 const params = { FileSystemId }177 const response = await Promise.fromCallback(cb => efs.describeMountTargets(params, cb))178 this.log.trace('memoLength', { length: memo.length, super: response.MountTargets.length })179 return [].concat(memo).concat(response.MountTargets)180 }, [])181 const subnetIds = await getSubnetIds(vpcId)182 this.log.trace('mountTargets', { mountTargets })183 this.log.trace('subnetIds', { subnetIds })184 const mountTargetsToBeDeleted = mountTargets.filter(x => {185 this.log.trace('SubnetId', { SubnetId: x.SubnetId })186 return subnetIds.includes(x.SubnetId)187 })188 this.log.trace('mountTargetsToBeDeleted', { mountTargetsToBeDeleted })189 const fileSystemsToBeDeleted = _.uniq(mountTargetsToBeDeleted.map(x => x.FileSystemId))190 this.log.trace('fileSystemsToBeDeleted', { fileSystemsToBeDeleted })191 await Promise.map(mountTargetsToBeDeleted, async (mountTarget) => {192 const params = { MountTargetId: mountTarget.MountTargetId }193 this.log.trace('Delete File System', { params })194 return await $(efs, 'deleteMountTarget', params)195 })196 // NOTE: This will delete any EFS with a mount target in the subet. Very greedy197 // Ideally it would only delete EFS with all mount targets in a VPC198 await Promise.delay(3000)199 await Promise.map(fileSystemsToBeDeleted, async (FileSystemId) => {200 const params = { FileSystemId }201 this.log.trace('Delete File System', { FileSystemId })202 return await $(efs, 'deleteFileSystem', params, { retryErrorCodes: 'FileSystemInUse', retries: 10 })203 })204}205async function deleteNATGateways(vpcId, DryRun) {206 console.log('Deleting NAT Gateways instances .... ')207 this.log = log.child({ methods: 'deleteNATGateways', vpcId, DryRun });208 this.log.trace('Start deleting NAT Gateways')209 const params = {210 Filter: [211 {212 Name: "vpc-id",213 Values: [ vpcId ]214 }215 ]216 };217 const response = await Promise.fromCallback(cb => ec2.describeNatGateways(params, cb))218 const NatGatewayIds = response.NatGateways.map(x => x.NatGatewayId)219 return await Promise.map(NatGatewayIds, async (id) => {220 const params = { NatGatewayId:id };221 await $(ec2, 'deleteNatGateway', params)222 })223}224async function getSubnetIds (vpcId) {225 const params = {226 Filters: [{227 Name: "vpc-id",228 Values: [ vpcId ]229 }]230 };231 const subnetResponse = await Promise.fromCallback(cb => ec2.describeSubnets(params, cb))232 return subnetResponse.Subnets.map(x => x.SubnetId)233}234async function deleteSubnets (id, DryRun) {235 console.log('Deleting subnets instances .... ')236 this.log = log.child({ methods: 'deleteSubnets', id, DryRun });237 this.log.trace('Start deleting subnets')238 const params = { VpcId: id, DryRun };239 const subnetIds = await getSubnetIds(id)240 this.log.trace('SubnetIds', { subnetIds })241 await Promise.delay(3000)242 await Promise.map(subnetIds, async (SubId) => {243 const params = {SubnetId:SubId, DryRun}244 this.log.trace('Deleting subnet', { SubId })245 await $(ec2, 'deleteSubnet', params, { retryErrorCodes: 'DependencyViolation' })246 })247}248async function deleteVPC (id, DryRun) {249 console.log('Finallay, deleting VPC instances .... ')250 this.log = log.child({ methods: 'deleteVPC', VpcId: id || 'nothing', DryRun });251 this.log.trace('Start deleting VPC')252 const params = { VpcId: id, DryRun };253 await $(ec2, 'deleteVpc', params, { allowedErrorCodes: 'InvalidVpcID.NotFound' })254 //this.log.info('VPC Deleted')255}256async function deleteSecurityGroups (vpcId, DryRun) {257 var params = {258 DryRun,259 Filters: [{260 Name: 'vpc-id',261 Values: [ vpcId ]262 }]263 }264 const securityGroups = (await Promise.fromCallback(cb => ec2.describeSecurityGroups(params, cb))).SecurityGroups;265 this.log.trace('Security Groups', { securityGroups })266 await Promise.mapSeries(securityGroups, async (securityGroup) => {267 this.log.trace('Security group', { securityGroup, })268 await Promise.mapSeries(securityGroup.IpPermissions, async (ruleUnfiltered) => {269 const rule = {}270 rule.GroupId = securityGroup.GroupId271 if (!_.isEmpty(ruleUnfiltered.IpRanges)) {272 const ipRange = ruleUnfiltered.IpRanges[0]273 rule.IpProtocol = ruleUnfiltered.IpProtocol274 rule.FromPort = ruleUnfiltered.FromPort275 rule.ToPort = ruleUnfiltered.ToPort276 rule.CidrIp = ipRange.CidrIp277 }278 if (!_.isEmpty(ruleUnfiltered.UserIdGroupPairs)) {279 rule.IpPermissions = [ _.pick(ruleUnfiltered, ['IpProtocol', 'UserIdGroupPairs', 'FromPort', 'ToPort']) ]280 }281 this.log.trace('Delete Ingress Rule', { rule, ruleUnfiltered })282 await $(ec2, 'revokeSecurityGroupIngress', rule)283 })284 return285 })286 const sgIds = securityGroups.filter(x => x.GroupName !== 'default').map(x => x.GroupId)287 this.log.trace('Security Group Ids', { sgIds })288 await Promise.delay(1000)289 await Promise.map(sgIds, async function (id) {290 const params = { GroupId:id, DryRun }291 return await $(ec2, 'deleteSecurityGroup', params)292 })293}294async function deleteNetworkInterfaces (VpcId, DryRun) {295 this.log = log.child({ methods: 'deleteNetworkInterfaces', VpcId });296 const queryParams = {297 DryRun,298 Filters: [299 {300 Name: 'vpc-id',301 Values: [ VpcId ]302 }303 ]304 };305 const response = await Promise.fromCallback(cb => ec2.describeNetworkInterfaces(queryParams, cb))306 const networkInterfaceIds = response.NetworkInterfaces.map(x => x.NetworkInterfaceId)307 const networkInterfaceAttachmentIds = response.NetworkInterfaces.map(x => _.get(x, 'Attachment.AttachmentId')).filter(x => !!x)308 await Promise.map(networkInterfaceAttachmentIds, async (id) => {309 const detachParams = { AttachmentId:id, Force: true, DryRun }310 await $(ec2, 'detachNetworkInterface', detachParams, { allowedErrorCodes: ['OperationNotPermitted','InvalidAttachmentID.NotFound'], retryErrorCodes: ['AuthFailure','UnsupportedOperation','InvalidParameterValue','OperationalError'] })311 })312 await Promise.map(networkInterfaceIds, async (id) => {313 const deleteParams = { DryRun, NetworkInterfaceId:id }314 return $(ec2, 'deleteNetworkInterface', deleteParams, { allowedErrorCodes: 'InvalidNetworkInterfaceID.NotFound', retryErrorCodes: ['AuthFailure','UnsupportedOperation','InvalidParameterValue','OperationalError'] })315 })316}317async function deleteRouteTables (VpcId, DryRun) {318 const queryParams = {319 DryRun,320 Filters: [321 {322 Name: 'vpc-id',323 Values: [ VpcId ]324 },325 ]326 }327 const response = await Promise.fromCallback(cb => ec2.describeRouteTables(queryParams, cb))328 // TODO: This should filter out the default route table329 //const routeTableIds = response.RouteTables.filter(x => ((typeof x.Associations[0] !== 'undefined') && !x.Associations[0].Main)).map(x => x.RouteTableId)330 const routeTableIds = response.RouteTables.map(x => x.RouteTableId)331 return await Promise.map(routeTableIds, async (id) => {332 const query = { RouteTableId: id, DryRun } 333 return $(ec2, 'deleteRouteTable', query,{ allowedErrorCodes: 'DependencyViolation' } )334 })335}336async function $(classInstance, methodName, query, opts = {}) {337 this.log = log.child({ methods: '$', endpoint: classInstance.endpoint.host, methodName, query, opts });338 const className = classInstance.endpoint.host.split('.')[0]339 let result340 try {341 result = await Promise.fromCallback(cb => classInstance[methodName](query, cb))342 } catch (err) {343 if (opts.retryErrorCodes && opts.retryErrorCodes.includes(err.code)) {344 opts.retries = ((_.isNumber(opts.retries) ? opts.retries : 20) - 1)345 if (opts.retries <= 0) {346 this.log.error('No retries left', { retries: opts.retries, errorCode: err.code })347 return348 //throw err349 }350 this.log.trace('Retrying', { retries: opts.retries, errorCode: err.code })351 await Promise.delay(opts.retryDelay || 5000)352 return $(classInstance, methodName, query, opts)353 }354 if (opts.allowedErrorCodes && opts.allowedErrorCodes.includes(err.code)) {355 this.log.trace('Allowed Error', { errorCode: err.code })356 return 357 }358 if (opts.unHandledErrorCodes && opts.unHandledErrorCodes.includes(err.code)) {359 this.log.error('Unhandled Error. This error is unhanlded and cannot be fixed by re-running this command. Log in to the AWS console and check what other resources are tied this resource.', { errorCode: err.code })360 throw err361 }362 this.log.error(`Error executing ${className}.${methodName}`, { errorCode: err.code })363 throw err364 }365 return result...

Full Screen

Full Screen

cleanup.ts

Source:cleanup.ts Github

copy

Full Screen

1import { BonusDocumentDbClient } from "./io-bonus-db";2const cleanUpDb = async ({3 dbClient,4 familyUIDs,5 fiscalCodes,6 bonuses,7 dryRun8}: {9 dbClient: BonusDocumentDbClient;10 familyUIDs: readonly string[];11 fiscalCodes: readonly string[];12 bonuses: readonly string[];13 dryRun: boolean;14}): Promise<ReadonlyArray<readonly [string, boolean]>> => {15 const executeOrDryRun = async (16 fn: () => Promise<void>,17 label: string18 ): Promise<readonly [string, boolean]> => {19 if (dryRun) {20 return [label, true];21 }22 return fn()23 .then(_ => true)24 .catch(_ => false)25 .then(result => [label, result]);26 };27 const operations: ReadonlyArray<Promise<readonly [string, boolean]>> = [28 // eligibility checks29 ...fiscalCodes.map(fiscalCode =>30 executeOrDryRun(31 () => dbClient.deleteEligibilityCheck(fiscalCode),32 `DELETE EligibilityCheck for ${fiscalCode} (dryRun=${dryRun})`33 )34 ),35 // bonus activation36 ...bonuses.map(bonus =>37 executeOrDryRun(38 () => dbClient.deleteBonusActivation(bonus),39 `DELETE BonusActivation for ${bonus} (dryRun=${dryRun})`40 )41 ),42 // user bonus43 ...bonuses.map(bonus =>44 executeOrDryRun(45 () => dbClient.deleteUserBonus(bonus),46 `DELETE UserBonus for ${bonus} (dryRun=${dryRun})`47 )48 ),49 // bonus processing50 ...bonuses.map(bonus =>51 executeOrDryRun(52 () => dbClient.deleteBonusProcessing(bonus),53 `DELETE BonusProcessing for ${bonus} (dryRun=${dryRun})`54 )55 ),56 // bonus lease57 ...familyUIDs.map(familyUID =>58 executeOrDryRun(59 () => dbClient.deleteBonusLease(familyUID),60 `DELETE BonusLease for ${familyUID} (dryRun=${dryRun})`61 )62 )63 ];64 return Promise.all(operations);65};66export interface ITestingSession {67 cleanData: (68 // tslint:disable-next-line: bool-param-default69 dryRun?: boolean70 ) => Promise<ReadonlyArray<readonly [string, boolean]>>;71 registerFiscalCode: (fiscalCode: string) => void;72 registerBonus: (bonus: string) => void;73 registerFamilyUID: (familyUID: string) => void;74}75export const createTestingSession = (76 dbClient: BonusDocumentDbClient77): ITestingSession => {78 const data = {79 bonuses: new Set<string>(),80 familyUIDs: new Set<string>(),81 fiscalCodes: new Set<string>()82 };83 return {84 async cleanData(85 dryRun = false86 ): Promise<ReadonlyArray<readonly [string, boolean]>> {87 const cleanReport = await cleanUpDb({88 bonuses: [...data.bonuses],89 dbClient,90 dryRun,91 familyUIDs: [...data.familyUIDs],92 fiscalCodes: [...data.fiscalCodes]93 }).catch(err => {94 console.error("cleanup general failure", err);95 return [];96 });97 data.bonuses.clear();98 data.fiscalCodes.clear();99 data.familyUIDs.clear();100 return cleanReport;101 },102 registerFiscalCode(fiscalCode: string): void {103 data.fiscalCodes.add(fiscalCode);104 },105 registerBonus(bonus: string): void {106 data.bonuses.add(bonus);107 },108 registerFamilyUID(familyUID: string): void {109 data.familyUIDs.add(familyUID);110 }111 };112};113export const printCleanReport = (114 cleanReport: ReadonlyArray<readonly [string, boolean]>115) => {116 cleanReport.forEach(([log, result]) => {117 if (result) {118 console.log(`cleanup success ${log}`);119 } else {120 console.error(`cleanup failure ${log}`);121 }122 });...

Full Screen

Full Screen

doPost.js

Source:doPost.js Github

copy

Full Screen

1'use strict';2const URL = 'https://api.zoined.com/';3const rp = require('request-promise');4const constants = require('./constants');5const postData = async(zoinedKey, dataType, dataValue) => {6 let uri = URL;7 switch (dataType) {8 case constants.SUPPLIERS:9 uri += 'suppliers?dryRun=false';10 break;11 case constants.SALES:12 uri += 'sales?dryRun=false';13 break;14 case constants.CAMPAIGN:15 uri += 'campaigns?dryRun=false';16 break;17 case constants.CAMPAIGNPRODUCTS:18 uri += 'campaignProducts?dryRun=false';19 break;20 case constants.DEPARTMENTS:21 uri += 'departments?dryRun=false';22 break;23 case constants.BUDGETS:24 uri += 'budgets?dryRun=false';25 break;26 case constants.PRODUCTS:27 uri += 'products?dryRun=false';28 break;29 case constants.CUSTOMERS:30 uri += 'customers?dryRun=false';31 break;32 case constants.ORGANISATIONS:33 uri += 'organisations?dryRun=false';34 break;35 case constants.SALESPERSON:36 uri += 'salespersons?dryRun=false';37 break;38 case constants.CURRENCYRATES:39 uri += 'currencyRates?dryRun=false';40 break;41 case constants.INVENTORYSNAPSHOTS:42 uri += 'inventorySnapshots?dryRun=false';43 break;44 case constants.INVENTORYTRANSACTIONS:45 uri += 'inventoryTransactions?dryRun=false';46 break;47 case constants.FLATHIERACHIES:48 uri += 'flatHierarchies?dryRun=false';49 break;50 case constants.PRODUCTHIERACHIES:51 uri += 'productHierarchies?dryRun=false';52 break;53 case constants.REBATECODES:54 uri += 'rebateCodes?dryRun=false';55 break;56 case constants.SALESSUMMARY:57 uri += 'salesSummaries?dryRun=false';58 break;59 case constants.VISITORS:60 uri += 'visitors?dryRun=false';61 break;62 case constants.VISTORDEMOGRAPHICS:63 uri += 'visitorDemographics?dryRun=false';64 break;65 case constants.IDMAPPING:66 uri += 'idMapping?dryRun=false';67 break;68 case constants.FEEDBACK:69 uri += 'customerFeedbacks?dryRun=false';70 break;71 case constants.SALESBUDGETS:72 case constants.ATVBUDGETS:73 case constants.UPTBUDGETS:74 uri += 'budgets/budget?dryRun=false';75 break;76 }77 let postOptions = {78 method: 'POST',79 uri: uri,80 body: JSON.stringify(dataValue),81 auth: {82 'bearer': zoinedKey83 },84 headers: {85 'content-type': 'application/json'86 }87 };88 return await rp(postOptions);89};...

Full Screen

Full Screen

index.test.js

Source:index.test.js Github

copy

Full Screen

1'use strict';2/* eslint-env jest */3/* eslint-disable global-require */4afterEach(() => {5 delete process.env.DRY_RUN;6});7describe('environment', () => {8 function expectEnv(env, active) {9 if (env != null) {10 process.env.DRY_RUN = env;11 }12 jest.resetModules();13 const dryrun = require('./index');14 expect(dryrun.isDryRun()).toBe(active);15 expect(dryrun.shouldPerform()).toBe(!active);16 }17 test('undefined', () => expectEnv(undefined, false));18 test('empty', () => expectEnv('', false));19 test('false', () => expectEnv('false', false));20 test('0', () => expectEnv('0', false));21 test('no', () => expectEnv('no', false));22 test('true', () => expectEnv('true', true));23 test('1', () => expectEnv('1', true));24 test('yes', () => expectEnv('yes', true));25 test('bla', () => expectEnv('bla', true));26});27describe('setDryRun', () => {28 function expectSet(flag, active) {29 const dryrun = require('./index');30 dryrun.setDryRun(flag);31 expect(dryrun.isDryRun()).toBe(active);32 expect(dryrun.shouldPerform()).toBe(!active);33 }34 test('empty', () => expectSet(undefined, true));35 test('true', () => expectSet(true, true));36 test('false', () => expectSet(false, false));37});38test('reset', () => {39 const dryrun = require('./index');40 dryrun.setDryRun(true);41 dryrun.resetDryRun();42 expect(dryrun.isDryRun()).toBe(false);43 expect(dryrun.shouldPerform()).toBe(true);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var fc = require("fast-check");2var result = fc.check(fc.property(fc.integer(), fc.integer(), function (a, b) {3 return a + b === b + a;4}), { dryRun: true });5console.log(result.counterexample);6console.log(result.numRuns);7console.log(result.failed);8var fc = require("fast-check");9var result = fc.check(fc.property(fc.integer(), fc.integer(), function (a, b) {10 return a + b === b + a;11}), { dryRun: true });12console.log(result.counterexample);13console.log(result.numRuns);14console.log(result.failed);15var fc = require("fast-check");16var result = fc.check(fc.property(fc.integer(), fc.integer(), function (a, b) {17 return a + b === b + a;18}), { dryRun: true });19console.log(result.counterexample);20console.log(result.numRuns);21console.log(result.failed);22var fc = require("fast-check");23var result = fc.check(fc.property(fc.integer(), fc.integer(), function (a, b) {24 return a + b === b + a;25}), { dryRun: true });26console.log(result.counterexample);27console.log(result.numRuns);28console.log(result.failed);29var fc = require("fast-check");30var result = fc.check(fc.property(fc.integer(), fc.integer(), function (a, b) {31 return a + b === b + a;32}), { dryRun: true });33console.log(result.counterexample);34console.log(result.numRuns);35console.log(result.failed);36var fc = require("fast-check");37var result = fc.check(fc.property(fc.integer(), fc.integer(), function (a, b) {38 return a + b === b + a;39}), { dryRun: true });40console.log(result.counterexample);41console.log(result.numRuns);42console.log(result.failed);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const { dryRun } = require("fast-check-monorepo");3fc.assert(4 fc.property(fc.integer(), (x) => {5 return x <= x + 1;6 })7);8dryRun({9});10dryRun({11});

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const { dryRun } = require("fast-check-monorepo");3const arb = fc.array(fc.integer(), 1, 10);4fc.assert(5 fc.property(arb, (arr) => {6 console.log(arr);7 return true;8 }),9 { verbose: true, numRuns: 10 }10);11dryRun(arb, { numRuns: 10 });12const fc = require("fast-check");13const { dryRun } = require("fast-check-monorepo");14const arb = fc.array(fc.integer(), 1, 10);15fc.assert(16 fc.property(arb, (arr) => {17 console.log(arr);18 return true;19 }),20 { verbose: true, numRuns: 10 }21);22dryRun(arb, { numRuns: 10 });23const fc = require("fast-check");24const { dryRun } = require("fast-check-monorepo");25const arb = fc.array(fc.integer(), 1, 10);26fc.assert(27 fc.property(arb, (arr) => {28 console.log(arr);29 return true;30 }),31 { verbose: true, numRuns: 10 }32);33dryRun(arb, { numRuns: 10 });34const fc = require("fast-check");35const { dryRun } = require("fast-check-monorepo");36const arb = fc.array(fc.integer(), 1, 10);37fc.assert(38 fc.property(arb, (arr) => {39 console.log(arr);40 return true;41 }),42 { verbose: true, numRuns: 10 }43);44dryRun(arb, { numRuns: 10 });45const fc = require("fast-check");46const { dryRun } = require("fast-check-monorepo");47const arb = fc.array(fc.integer(), 1, 10);48fc.assert(49 fc.property(arb, (arr) => {50 console.log(arr);51 return true;52 }),53 { verbose: true, numRuns:

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { dryRun } = require('fast-check-monorepo');3const { generate } = require('./test2');4const { generate2 } = require('./test2');5const { generate3 } = require('./test2');6const { generate4 } = require('./test2');7const { generate5 } = require('./test2');8const { generate6 } = require('./test2');9const { generate7 } = require('./test2');10const { generate8 } = require('./test2');11const { generate9 } = require('./test2');12const { generate10 } = require('./test2');13const { generate11 } = require('./test2');14const { generate12 } = require('./test2');15const { generate13 } = require('./test2');16const { generate14 } = require('./test2');17const { generate15 } = require('./test2');18const { generate16 } = require('./test2');19const { generate17 } = require('./test2');20const { generate18 } = require('./test2');21const { generate19 } = require('./test2');22const { generate20 } = require('./test2');23const { generate21 } = require('./test2');24const { generate22 } = require('./test2');25const { generate23 } = require('./test2');26const { generate24 } = require('./test2');27const { generate25 } = require('./test2');28const { generate26 } = require('./test2');29const { generate27 } = require('./test2');30const { generate28 } = require('./test2');31const { generate29 } = require('./test2');32const { generate30 } = require('./test2');33const { generate31 } = require('./test2');34const { generate32 } = require('./test2');35const { generate33 } = require('./test2');36const { generate34 } = require('./test2');37const { generate35 } = require('./test2');38const { generate36 } = require('./test2');39const { generate37 } = require('./test2');40const { generate38 } = require('./test2');41const { generate39 } = require('./test2');42const { generate40 } = require('./test2');43const { generate41 } = require('./test2');44const { generate42 } = require('./test2');45const { generate43 } = require('./test2');46const { generate44

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { dryRun } = require('fast-check-monorepo');3const { constant } = require('fast-check');4const myProp = (a, b) => a + b === b + a;5const myArb = constant(42);6const myConf = { numRuns: 1000 };7dryRun(myProp, myArb, myConf);8const fc = require('fast-check');9const { jestProperty } = require('fast-check-monorepo');10const { constant } = require('fast-check');11const myProp = (a, b) => a + b === b + a;12const myArb = constant(42);13const myConf = { numRuns: 1000 };14describe('myProp', () => {15 it('should hold', () => {16 jestProperty(myProp, myArb, myConf);17 });18});19const fc = require('fast-check');20const { mochaProperty } = require('fast-check-monorepo');21const { constant } = require('fast-check');22const myProp = (a, b) => a + b === b + a;23const myArb = constant(42);24const myConf = { numRuns: 1000 };25describe('myProp', () => {26 it('should hold', () => {27 mochaProperty(myProp, myArb, myConf);28 });29});30[MIT](LICENSE)

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const { dryRun } = require("fast-check-monorepo");3const generateRandomString = () => {4 const randomString = fc.sample(5 fc.string(),6 {7 },8 )[0];9 return randomString;10};11const generateRandomStringWithLength = (length) => {12 const randomString = fc.sample(13 fc.string(length),14 {15 },16 )[0];17 return randomString;18};19const generateRandomStringWithLengthRange = (min, max) => {20 const randomString = fc.sample(21 fc.string({ minLength: min, maxLength: max }),22 {23 },24 )[0];25 return randomString;26};27const generateRandomStringWithLengthRangeAndChars = (min, max, chars) => {28 const randomString = fc.sample(29 fc.string({ minLength: min, maxLength: max, char: chars }),30 {31 },32 )[0];33 return randomString;34};35const generateRandomStringWithLengthRangeAndCharsAndFullUnicode = (36) => {37 const randomString = fc.sample(38 fc.string({39 }),40 {41 },42 )[0];43 return randomString;44};45const generateRandomStringWithLengthRangeAndCharsAndFullUnicodeAndNoSurrogate = (46) => {47 const randomString = fc.sample(48 fc.string({49 }),50 {

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2fc.dryRun(() => fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));3fc.dryRun();4fc.dryRun({ numRuns: 1000 }, () => fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));5fc.dryRun({ numRuns: 1000 });6fc.dryRun({ verbose: true });7fc.dryRun({ seed: 42 });8fc.dryRun({ endOnFailure: true });9fc.dryRun({ endOnFailure: true, seed: 42 });10fc.dryRun({ endOnFailure: true, numRuns: 1000 });11fc.dryRun({ endOnFailure: true, seed: 42, numRuns: 1000 });12fc.dryRun({ endOnFailure: true, seed: 42, numRuns: 1000, verbose: true });13fc.dryRun({ endOnFailure: true, seed: 42, numRuns: 1000, verbose: true }, () => fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));14fc.dryRun({ endOnFailure: true, seed: 42, numRuns: 1000, verbose: true }, () => fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));15fc.dryRun({ endOnFailure: true, seed: 42, numRuns: 1000, verbose: true }, () => fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a));

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const { dryRun } = require("fast-check/lib/fast-check-default");3const { pathExists } = require("fs-extra");4const arb = fc.array(fc.integer(), 1, 100);5const { failures } = dryRun(arb, (xs) => {6 const ys = xs.slice().sort((a, b) => a - b);7 return xs.every((x, idx) => x === ys[idx]);8});9console.log(failures);10const fc = require("fast-check");11const { dryRun } = require("fast-check/lib/fast-check-default");12const { pathExists } = require("fs-extra");13const arb = fc.array(fc.integer(), 1, 100);14const { failures } = dryRun(arb, (xs) => {15 const ys = xs.slice().sort((a, b) => a - b);16 return xs.every((x, idx) => x === ys[idx]);17});18console.log(failures);19const fc = require("fast-check");20const { dryRun } = require("fast-check/lib/fast-check-default");21const { pathExists } = require("fs-extra");22const arb = fc.array(fc.integer(), 1, 100);23const { failures } = dryRun(arb, (xs) => {24 const ys = xs.slice().sort((a, b) => a - b);25 return xs.every((x, idx) => x === ys[idx]);26});27console.log(failures);28const fc = require("fast-check");29const { dryRun } = require("fast-check/lib/fast-check-default");30const { pathExists } = require("fs-extra");31const arb = fc.array(fc.integer(), 1, 100);32const { failures } = dryRun(arb, (xs) => {33 const ys = xs.slice().sort((a, b) => a - b);34 return xs.every((x, idx) => x === ys[idx]);35});36console.log(failures);

Full Screen

Using AI Code Generation

copy

Full Screen

1import fc from 'fast-check';2const test = fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a).dryRun();3console.log(test);4import fc from 'fast-check';5const test = fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a).dryRun();6console.log(test);7The propertyRunReport object returned by the dryRun() method has two properties:8import fc from 'fast-check';9const test = fc.property(fc.integer(), fc.integer(), (a, b) => a + b === b + a).withSettings({ seed: 42 }).check();10console.log(test);

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 fast-check-monorepo 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