Best JavaScript code snippet using fast-check-monorepo
ValuesAndSeparateKeysToObject.spec.ts
Source:ValuesAndSeparateKeysToObject.spec.ts
1import {2 buildValuesAndSeparateKeysToObjectMapper,3 buildValuesAndSeparateKeysToObjectUnmapper,4} from '../../../../../src/arbitrary/_internals/mappers/ValuesAndSeparateKeysToObject';5describe('buildValuesAndSeparateKeysToObjectMapper', () => {6 it('should create instances with Object prototype', () => {7 // Arrange8 const keys: (string | symbol)[] = [];9 const magicNoValue = Symbol('no-value');10 const values: any[] = [];11 // Act12 const mapper = buildValuesAndSeparateKeysToObjectMapper<any, typeof magicNoValue>(keys, magicNoValue);13 const obj = mapper(values);14 // Assert15 expect(Object.getPrototypeOf(obj)).toBe(Object.prototype);16 });17 it('should replace magic values by no key', () => {18 // Arrange19 const keys: (string | symbol)[] = ['a', 'b', 'c', 'd'];20 const magicNoValue = Symbol('no-value');21 const values: any[] = [undefined, magicNoValue, null, 0];22 // Act23 const mapper = buildValuesAndSeparateKeysToObjectMapper<any, typeof magicNoValue>(keys, magicNoValue);24 const obj = mapper(values);25 // Assert26 expect(obj).toHaveProperty('a');27 expect(obj).not.toHaveProperty('b');28 expect(obj).toHaveProperty('c');29 expect(obj).toHaveProperty('d');30 expect(obj).toEqual({ a: undefined, c: null, d: 0 });31 });32 it('should be able to produce instances with "__proto__" as key', () => {33 // Arrange34 const keys: (string | symbol)[] = ['__proto__'];35 const magicNoValue = Symbol('no-value');36 const values: any[] = [0];37 // Act38 const mapper = buildValuesAndSeparateKeysToObjectMapper<any, typeof magicNoValue>(keys, magicNoValue);39 const obj = mapper(values);40 // Assert41 expect(Object.getPrototypeOf(obj)).toBe(Object.prototype);42 expect(obj).toHaveProperty('__proto__');43 expect(obj.__proto__).toBe(0);44 expect(obj).toEqual({ ['__proto__']: 0 });45 });46});47describe('buildValuesAndSeparateKeysToObjectUnmapper', () => {48 it('should properly unmap basic instances of Object without keys', () => {49 // Arrange50 const obj = {};51 const keys: (string | symbol)[] = [];52 const magicNoValue = Symbol('no-value');53 // Act54 const unmapper = buildValuesAndSeparateKeysToObjectUnmapper<any, typeof magicNoValue>(keys, magicNoValue);55 const values = unmapper(obj);56 // Assert57 expect(values).toEqual([]);58 });59 it('should properly unmap basic instances of Object with multiple keys and no missing', () => {60 // Arrange61 const obj = { a: 'e', 1: 'hello', b: undefined };62 const keys: (string | symbol)[] = ['b', '1', 'a'];63 const magicNoValue = Symbol('no-value');64 // Act65 const unmapper = buildValuesAndSeparateKeysToObjectUnmapper<any, typeof magicNoValue>(keys, magicNoValue);66 const values = unmapper(obj);67 // Assert68 expect(values).toEqual([undefined, 'hello', 'e']);69 });70 it('should properly unmap instances of Object with known symbols as keys', () => {71 // Arrange72 const s1 = Symbol('s1');73 const s2 = Symbol('s2');74 const obj = { a: 'e', [s2]: 'hello', [s1]: undefined };75 const keys: (string | symbol)[] = [s2, s1, 'a'];76 const magicNoValue = Symbol('no-value');77 // Act78 const unmapper = buildValuesAndSeparateKeysToObjectUnmapper<any, typeof magicNoValue>(keys, magicNoValue);79 const values = unmapper(obj);80 // Assert81 expect(values).toEqual(['hello', undefined, 'e']);82 });83 it('should properly unmap instances of Object with missing keys', () => {84 // Arrange85 const s1 = Symbol('s1');86 const s2 = Symbol('s2');87 const s3 = Symbol('s2');88 const obj = { a: 'e', [s2]: 'hello', [s1]: undefined };89 const keys: (string | symbol)[] = [s2, 'b', s1, 'a', 'd', s3];90 const magicNoValue = Symbol('no-value');91 // Act92 const unmapper = buildValuesAndSeparateKeysToObjectUnmapper<any, typeof magicNoValue>(keys, magicNoValue);93 const values = unmapper(obj);94 // Assert95 expect(values).toEqual(['hello', magicNoValue, undefined, 'e', magicNoValue, magicNoValue]);96 });97 it('should properly unmap instances of Object with "__proto__" as key when there', () => {98 // Arrange99 const obj = { ['__proto__']: 'e' };100 const keys: (string | symbol)[] = ['toString', '__proto__', 'a'];101 const magicNoValue = Symbol('no-value');102 // Act103 const unmapper = buildValuesAndSeparateKeysToObjectUnmapper<any, typeof magicNoValue>(keys, magicNoValue);104 const values = unmapper(obj);105 // Assert106 expect(values).toEqual([magicNoValue, 'e', magicNoValue]);107 });108 it('should properly unmap instances of Object with "__proto__" as key when not there', () => {109 // Arrange110 const obj = {};111 const keys: (string | symbol)[] = ['toString', '__proto__', 'a'];112 const magicNoValue = Symbol('no-value');113 // Act114 const unmapper = buildValuesAndSeparateKeysToObjectUnmapper<any, typeof magicNoValue>(keys, magicNoValue);115 const values = unmapper(obj);116 // Assert117 expect(values).toEqual([magicNoValue, magicNoValue, magicNoValue]);118 });119 it.each`120 value | condition121 ${Object.create(null)} | ${'it has no prototype'}122 ${new (class A {})()} | ${'it is not just a simple object but a more complex type'}123 ${[]} | ${'it is an Array'}124 ${new Number(0)} | ${'it is a boxed-Number'}125 ${0} | ${'it is a number'}126 ${null} | ${'it is null'}127 ${undefined} | ${'it is undefined'}128 ${{ [Symbol('unknown')]: 5 }} | ${'it contains an unknown symbol property'}129 ${{ [Symbol('unknown')]: 5, a: 6, [Symbol.for('a')]: 7 }} | ${'it contains an unknown symbol property (even if others are there)'}130 ${{ unknown: 5 }} | ${'it contains an unknown named property'}131 ${{ unknown: 5, a: 6, [Symbol.for('a')]: 7 }} | ${'it contains an unknown named property (even if others are there)'}132 ${Object.defineProperty({}, 'a', { value: 5, configurable: false })} | ${'it contains a non-configurable property'}133 ${Object.defineProperty({}, 'a', { value: 5, enumerable: false })} | ${'it contains a non-enumerable property'}134 ${Object.defineProperty({}, 'a', { value: 5, writable: false })} | ${'it contains a non-writable property'}135 ${Object.defineProperty({}, 'a', { get: () => 5 })} | ${'it contains a get property'}136 ${Object.defineProperty({}, 'a', { set: () => {} })} | ${'it contains a set property'}137 `('should reject unmap on instance when $condition', ({ value }) => {138 // Arrange139 const keys: (string | symbol)[] = ['a', Symbol.for('a')];140 const magicNoValue = Symbol('no-value');141 const unmapper = buildValuesAndSeparateKeysToObjectUnmapper<any, typeof magicNoValue>(keys, magicNoValue);142 // Act / Assert143 expect(() => unmapper(value)).toThrowError();144 });...
PartialRecordArbitraryBuilder.spec.ts
Source:PartialRecordArbitraryBuilder.spec.ts
1import { fakeArbitrary } from '../../__test-helpers__/ArbitraryHelpers';2import { buildPartialRecordArbitrary } from '../../../../../src/arbitrary/_internals/builders/PartialRecordArbitraryBuilder';3import * as OptionMock from '../../../../../src/arbitrary/option';4import * as TupleMock from '../../../../../src/arbitrary/tuple';5import * as ValuesAndSeparateKeysToObjectMock from '../../../../../src/arbitrary/_internals/mappers/ValuesAndSeparateKeysToObject';6function beforeEachHook() {7 jest.resetModules();8 jest.restoreAllMocks();9}10beforeEach(beforeEachHook);11describe('buildPartialRecordArbitrary', () => {12 it('should never wrap arbitraries linked to required keys and forward all keys to mappers', () => {13 // Arrange14 const { instance: mappedInstance } = fakeArbitrary<any>();15 const { instance: tupleInstance, map } = fakeArbitrary<any[]>();16 const option = jest.spyOn(OptionMock, 'option');17 const tuple = jest.spyOn(TupleMock, 'tuple');18 tuple.mockReturnValue(tupleInstance);19 map.mockReturnValue(mappedInstance);20 const mapper = jest.fn();21 const buildValuesAndSeparateKeysToObjectMapper = jest.spyOn(22 ValuesAndSeparateKeysToObjectMock,23 'buildValuesAndSeparateKeysToObjectMapper'24 );25 buildValuesAndSeparateKeysToObjectMapper.mockReturnValue(mapper);26 const unmapper = jest.fn();27 const buildValuesAndSeparateKeysToObjectUnmapper = jest.spyOn(28 ValuesAndSeparateKeysToObjectMock,29 'buildValuesAndSeparateKeysToObjectUnmapper'30 );31 buildValuesAndSeparateKeysToObjectUnmapper.mockReturnValue(unmapper);32 const arbKey1 = fakeArbitrary();33 const arbKey2 = fakeArbitrary();34 const recordModel = {35 a: arbKey1,36 b: arbKey2,37 };38 const requiredKeys: (keyof typeof recordModel)[] = ['a', 'b'];39 const allKeys: (keyof typeof recordModel)[] = ['a', 'b'];40 // Act41 const arb = buildPartialRecordArbitrary(recordModel, requiredKeys);42 // Assert43 expect(arb).toBe(mappedInstance);44 expect(option).not.toHaveBeenCalled();45 expect(tuple).toHaveBeenCalledTimes(1);46 expect(tuple).toHaveBeenCalledWith(recordModel.a, recordModel.b);47 expect(buildValuesAndSeparateKeysToObjectMapper).toHaveBeenCalledTimes(1);48 expect(buildValuesAndSeparateKeysToObjectMapper).toHaveBeenCalledWith(allKeys, expect.any(Symbol));49 expect(buildValuesAndSeparateKeysToObjectUnmapper).toHaveBeenCalledTimes(1);50 expect(buildValuesAndSeparateKeysToObjectUnmapper).toHaveBeenCalledWith(allKeys, expect.any(Symbol));51 expect(map).toHaveBeenCalledTimes(1);52 expect(map).toHaveBeenCalledWith(mapper, unmapper);53 });54 it('should wrap arbitraries not linked to required keys into option and forward all keys to mappers', () => {55 // Arrange56 const { instance: mappedInstance } = fakeArbitrary<any>();57 const { instance: tupleInstance, map } = fakeArbitrary<any[]>();58 const { instance: optionInstance1 } = fakeArbitrary();59 const { instance: optionInstance2 } = fakeArbitrary();60 const option = jest.spyOn(OptionMock, 'option');61 const tuple = jest.spyOn(TupleMock, 'tuple');62 const optionInstance1Old = optionInstance1;63 const optionInstance2Old = optionInstance2;64 option.mockReturnValueOnce(optionInstance1Old).mockReturnValueOnce(optionInstance2Old);65 tuple.mockReturnValue(tupleInstance);66 map.mockReturnValue(mappedInstance);67 const mapper = jest.fn();68 const buildValuesAndSeparateKeysToObjectMapper = jest.spyOn(69 ValuesAndSeparateKeysToObjectMock,70 'buildValuesAndSeparateKeysToObjectMapper'71 );72 buildValuesAndSeparateKeysToObjectMapper.mockReturnValue(mapper);73 const unmapper = jest.fn();74 const buildValuesAndSeparateKeysToObjectUnmapper = jest.spyOn(75 ValuesAndSeparateKeysToObjectMock,76 'buildValuesAndSeparateKeysToObjectUnmapper'77 );78 buildValuesAndSeparateKeysToObjectUnmapper.mockReturnValue(unmapper);79 const arbKey1 = fakeArbitrary();80 const arbKey2 = fakeArbitrary();81 const arbKey3 = fakeArbitrary();82 const recordModel = {83 a: arbKey1,84 b: arbKey2,85 c: arbKey3,86 };87 const requiredKeys: (keyof typeof recordModel)[] = ['b'];88 const allKeys: (keyof typeof recordModel)[] = ['a', 'b', 'c'];89 // Act90 const arb = buildPartialRecordArbitrary(recordModel, requiredKeys);91 // Assert92 expect(arb).toBe(mappedInstance);93 expect(option).toHaveBeenCalledTimes(2);94 expect(option).toHaveBeenCalledWith(recordModel.a, { nil: expect.any(Symbol) });95 expect(option).toHaveBeenCalledWith(recordModel.c, { nil: expect.any(Symbol) });96 expect(tuple).toHaveBeenCalledTimes(1);97 expect(tuple).toHaveBeenCalledWith(optionInstance1Old, recordModel.b, optionInstance2Old);98 expect(buildValuesAndSeparateKeysToObjectMapper).toHaveBeenCalledTimes(1);99 expect(buildValuesAndSeparateKeysToObjectMapper).toHaveBeenCalledWith(allKeys, expect.any(Symbol));100 expect(buildValuesAndSeparateKeysToObjectUnmapper).toHaveBeenCalledTimes(1);101 expect(buildValuesAndSeparateKeysToObjectUnmapper).toHaveBeenCalledWith(allKeys, expect.any(Symbol));102 expect(map).toHaveBeenCalledTimes(1);103 expect(map).toHaveBeenCalledWith(mapper, unmapper);104 });105 it('should not wrap any arbitrary when required keys is not specified (all required) and forward all keys to mappers', () => {106 // Arrange107 const { instance: mappedInstance } = fakeArbitrary<any>();108 const { instance: tupleInstance, map } = fakeArbitrary<any[]>();109 const option = jest.spyOn(OptionMock, 'option');110 const tuple = jest.spyOn(TupleMock, 'tuple');111 tuple.mockReturnValue(tupleInstance);112 map.mockReturnValue(mappedInstance);113 const mapper = jest.fn();114 const buildValuesAndSeparateKeysToObjectMapper = jest.spyOn(115 ValuesAndSeparateKeysToObjectMock,116 'buildValuesAndSeparateKeysToObjectMapper'117 );118 buildValuesAndSeparateKeysToObjectMapper.mockReturnValue(mapper);119 const unmapper = jest.fn();120 const buildValuesAndSeparateKeysToObjectUnmapper = jest.spyOn(121 ValuesAndSeparateKeysToObjectMock,122 'buildValuesAndSeparateKeysToObjectUnmapper'123 );124 buildValuesAndSeparateKeysToObjectUnmapper.mockReturnValue(unmapper);125 const arbKey1 = fakeArbitrary();126 const arbKey2 = fakeArbitrary();127 const recordModel = {128 a: arbKey1,129 b: arbKey2,130 };131 const requiredKeys = undefined;132 const allKeys: (keyof typeof recordModel)[] = ['a', 'b'];133 // Act134 const arb = buildPartialRecordArbitrary(recordModel, requiredKeys);135 // Assert136 expect(arb).toBe(mappedInstance);137 expect(option).not.toHaveBeenCalled();138 expect(tuple).toHaveBeenCalledTimes(1);139 expect(tuple).toHaveBeenCalledWith(recordModel.a, recordModel.b);140 expect(buildValuesAndSeparateKeysToObjectMapper).toHaveBeenCalledTimes(1);141 expect(buildValuesAndSeparateKeysToObjectMapper).toHaveBeenCalledWith(allKeys, expect.any(Symbol));142 expect(buildValuesAndSeparateKeysToObjectUnmapper).toHaveBeenCalledTimes(1);143 expect(buildValuesAndSeparateKeysToObjectUnmapper).toHaveBeenCalledWith(allKeys, expect.any(Symbol));144 expect(map).toHaveBeenCalledTimes(1);145 expect(map).toHaveBeenCalledWith(mapper, unmapper);146 });...
PartialRecordArbitraryBuilder.ts
Source:PartialRecordArbitraryBuilder.ts
1import { Arbitrary } from '../../../check/arbitrary/definition/Arbitrary';2import { safeIndexOf, safePush } from '../../../utils/globals';3import { option } from '../../option';4import { tuple } from '../../tuple';5import { EnumerableKeyOf, extractEnumerableKeys } from '../helpers/EnumerableKeysExtractor';6import {7 buildValuesAndSeparateKeysToObjectMapper,8 buildValuesAndSeparateKeysToObjectUnmapper,9} from '../mappers/ValuesAndSeparateKeysToObject';10const noKeyValue: unique symbol = Symbol('no-key');11type NoKeyType = typeof noKeyValue;12/** @internal */13export function buildPartialRecordArbitrary<T, TKeys extends EnumerableKeyOf<T>>(14 recordModel: { [K in keyof T]: Arbitrary<T[K]> },15 requiredKeys: TKeys[] | undefined16): Arbitrary<Partial<T> & Pick<T, TKeys>> {17 const keys = extractEnumerableKeys(recordModel);18 const arbs: Arbitrary<T[keyof T] | NoKeyType>[] = [];19 for (let index = 0; index !== keys.length; ++index) {20 const k: EnumerableKeyOf<T> = keys[index];21 const requiredArbitrary = recordModel[k];22 if (requiredKeys === undefined || safeIndexOf(requiredKeys, k as TKeys) !== -1) {23 safePush(arbs, requiredArbitrary);24 } else {25 safePush(arbs, option(requiredArbitrary, { nil: noKeyValue as NoKeyType }));26 }27 }28 return tuple(...arbs).map(29 buildValuesAndSeparateKeysToObjectMapper<T, NoKeyType>(keys, noKeyValue),30 buildValuesAndSeparateKeysToObjectUnmapper<T, NoKeyType>(keys, noKeyValue)31 );...
Using AI Code Generation
1const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check');2const { buildStringArbitrary } = require('fast-check/lib/arbitrary/StringArbitrary');3const { buildObjectConstraints } = require('fast-check/lib/check/model/ObjectConstraints');4const { buildObjectUnmapper } = require('fast-check/lib/check/model/ObjectUnmapper');5const objectConstraints = buildObjectConstraints();6const objectUnmapper = buildObjectUnmapper(objectConstraints);7const stringArbitrary = buildStringArbitrary();8const valuesAndSeparateKeysToObjectUnmapper = buildValuesAndSeparateKeysToObjectUnmapper(objectUnmapper, stringArbitrary);9const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check');10const { buildStringArbitrary } = require('fast-check/lib/arbitrary/StringArbitrary');11const { buildObjectConstraints } = require('fast-check/lib/check/model/ObjectConstraints');12const { buildObjectUnmapper } = require('fast-check/lib/check/model/ObjectUnmapper');13const objectConstraints = buildObjectConstraints();14const objectUnmapper = buildObjectUnmapper(objectConstraints);15const stringArbitrary = buildStringArbitrary();16const valuesAndSeparateKeysToObjectUnmapper = buildValuesAndSeparateKeysToObjectUnmapper(objectUnmapper, stringArbitrary);17const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check');18const { buildStringArbitrary } = require('fast-check/lib/arbitrary/StringArbitrary');19const { buildObjectConstraints } = require('fast-check/lib/check/model/ObjectConstraints');20const { buildObjectUnmapper } = require('fast-check/lib/check/model/ObjectUnmapper');21const objectConstraints = buildObjectConstraints();22const objectUnmapper = buildObjectUnmapper(objectConstraints);23const stringArbitrary = buildStringArbitrary();24const valuesAndSeparateKeysToObjectUnmapper = buildValuesAndSeparateKeysToObjectUnmapper(objectUnmapper, stringArbitrary);25const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check');26const { buildStringArbitrary } = require('fast-check/lib/arbitrary/StringArbitrary');27const { buildObjectConstraints } = require
Using AI Code Generation
1const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check-monorepo');2const arbitrary = buildValuesAndSeparateKeysToObjectUnmapper({3 a: fc.integer({ min: 0, max: 100 }),4 b: fc.string(),5 c: fc.string(),6});7fc.assert(fc.property(arbitrary, ({ a, b, c }) => {8}));9const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check-monorepo');10const arbitrary = buildValuesAndSeparateKeysToObjectUnmapper({11 a: fc.integer({ min: 0, max: 100 }),12 b: fc.string(),13 c: fc.string(),14});15fc.assert(fc.property(arbitrary, ({ a, b, c }) => {16}));17const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check-monorepo');18const arbitrary = buildValuesAndSeparateKeysToObjectUnmapper({19 a: fc.integer({ min: 0, max: 100 }),20 b: fc.string(),21 c: fc.string(),22});23fc.assert(fc.property(arbitrary, ({ a, b, c }) => {24}));
Using AI Code Generation
1import { buildValuesAndSeparateKeysToObjectUnmapper } from 'fast-check';2const arb = fc.object({ a: fc.integer(), b: fc.string() });3const { unmapper, values } = buildValuesAndSeparateKeysToObjectUnmapper(arb);4const obj = unmapper(values);5import { buildValuesAndSeparateKeysToObjectUnmapper } from 'fast-check';6const arb = fc.object({ a: fc.integer(), b: fc.string() });7const { unmapper, values } = buildValuesAndSeparateKeysToObjectUnmapper(arb);8const obj = unmapper(values);9import { buildValuesAndSeparateKeysToObjectUnmapper } from 'fast-check';10const arb = fc.object({ a: fc.integer(), b: fc.string() });11const { unmapper, values } = buildValuesAndSeparateKeysToObjectUnmapper(arb);12const obj = unmapper(values);13import { buildValuesAndSeparateKeysToObjectUnmapper } from 'fast-check';14const arb = fc.object({ a: fc.integer(), b: fc.string() });15const { unmapper, values } = buildValuesAndSeparateKeysToObjectUnmapper(arb);16const obj = unmapper(values);17import { buildValuesAndSeparateKeysToObjectUnmapper } from 'fast-check';18const arb = fc.object({ a: fc.integer(), b: fc.string() });19const { unmapper, values } = buildValuesAndSepar
Using AI Code Generation
1const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check');2const { values, keys } = buildValuesAndSeparateKeysToObjectUnmapper()(obj);3const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check');4const { values, keys } = buildValuesAndSeparateKeysToObjectUnmapper()(obj);5const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check');6const { values, keys } = buildValuesAndSeparateKeysToObjectUnmapper()(obj);7const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check');8const { values, keys } = buildValuesAndSeparateKeysToObjectUnmapper()(obj);9const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check');10const { values, keys } = buildValuesAndSeparateKeysToObjectUnmapper()(obj);
Using AI Code Generation
1const { buildValuesAndSeparateKeysToObjectUnmapper } = require('fast-check-monorepo/src/check/arbitrary/UnmappedArbitraryHelper')2const { buildObjectArbitrary } = require('fast-check-monorepo/src/check/arbitrary/ObjectArbitraryBuilder')3const objectArbitrary = buildObjectArbitrary({ a: fc.integer(), b: fc.integer(), c: fc.integer() })4const { values, keys } = buildValuesAndSeparateKeysToObjectUnmapper(objectArbitrary)5fc.assert(6 fc.property(values, (value) => {7 })8fc.assert(9 fc.property(keys, (key) => {10 })11fc.assert(12 fc.property(values, keys, (value, key) => {13 })14fc.assert(15 fc.property(values, keys, (value, key) => {16 const obj = {}17 for (let i = 0; i < value.length; i++) {18 }19 })20fc.assert(21 fc.property(values, keys, (value, key) => {22 const obj = {}23 const shuffledValues = value.sort(() => 0.5 - Math.random())24 const shuffledKeys = key.sort(() => 0.5 - Math.random())25 for (let i = 0; i < shuffledValues.length; i++) {26 }27 })28fc.assert(29 fc.property(values, keys, (value, key) => {30 const obj = {}31 const shuffledValues = value.sort(() => 0.5 - Math.random())32 const shuffledKeys = key.sort(() => 0.5 - Math.random())33 for (let i = 0; i < shuffledValues.length; i++) {34 if (i % 2 === 0) {
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!!