Best JavaScript code snippet using pact-foundation-pact
AnimalRandom.js
Source:AnimalRandom.js
1ROME = {};2ROME.Animal = function (geometry, parseMorphTargetsNames) {3 var result = ROME.AnimalAnimationData.init(geometry, parseMorphTargetsNames);4 var that = {};5 that.morph = 0.0;6 that.animalA = {7 frames: undefined,8 currentFrame: 0,9 lengthInFrames: 0,10 currentTime: 0,11 lengthInMS: 0,12 timeScale: 1.0,13 name: ""14 };15 that.animalB = {16 frames: undefined,17 currentFrame: 0,18 lengthInFrames: 0,19 currentTime: 0,20 lengthInMS: 0,21 timeScale: 1.0,22 name: ""23 };24 that.availableAnimals = result.availableAnimals;25 that.mesh = new THREE.Mesh(geometry, result.material);26 var isPlaying = false;27 var morphTargetOrder = that.mesh.morphTargetForcedOrder;28 var material = result.material;29 that.play = function (animalA, animalB, morph, startTimeAnimalA, startTimeAnimalB) {30 if (!isPlaying) {31 isPlaying = true;32 that.morph = 0;33 THREE.AnimationHandler.addToUpdate(that);34 }35 animalB = animalB !== undefined ? animalB : animalA;36 morph = morph !== undefined ? morph : 0;37 setAnimalData(animalA, that.animalA);38 setAnimalData(animalB, that.animalB);39 that.animalA.currentTime = startTimeAnimalA ? startTimeAnimalA : 0;40 that.animalB.currentTime = startTimeAnimalB ? startTimeAnimalB : 0;41 that.update(0);42 };43 that.update = function (deltaTimeMS) {44 if (that.mesh._modelViewMatrix) {45 var data, dataNames = ["animalA", "animalB"];46 var d, dl;47 var f, fl;48 var frame, nextFrame;49 var time, nextTime;50 var unloopedTime;51 var lengthInMS;52 var lenghtInFrames;53 var morphTarget;54 var scale;55 for (d = 0, dl = dataNames.length, morphTarget = 0; d < dl; d++) {56 data = that[dataNames[d]];57 unloopedTime = data.currentTime;58 data.currentTime = (data.currentTime + deltaTimeMS * data.timeScale) % data.lengthInMS;59 if (unloopedTime > data.currentTime) {60 data.currentFrame = 0;61 }62 frame = 0;63 for (f = data.currentFrame, fl = data.lengthInFrames - 1; f < fl; f++) {64 if (data.currentTime >= data.frames[f].time && data.currentTime < data.frames[f + 1].time) {65 frame = f;66 break;67 }68 }69 data.currentFrame = frame;70 nextFrame = frame + 1 < fl ? frame + 1 : 0;71 morphTargetOrder[morphTarget++] = data.frames[frame].index;72 morphTargetOrder[morphTarget++] = data.frames[nextFrame].index;73 time = data.frames[frame].time;74 nextTime = data.frames[nextFrame].time > time ? data.frames[nextFrame].time : data.frames[nextFrame].time + data.lengthInMS;75 scale = (data.currentTime - time) / (nextTime - time);76 material.uniforms[dataNames[d] + "Interpolation"].value = scale;77 }78 material.uniforms.animalMorphValue.value = that.morph;79 if (material.attributes[that.animalA.name] !== undefined) {80 material.attributes.colorAnimalA.buffer = material.attributes[that.animalA.name].buffer;81 }82 if (material.attributes[that.animalB.name] !== undefined) {83 material.attributes.colorAnimalB.buffer = material.attributes[that.animalB.name].buffer;84 }85 }86 };87 that.setNewTargetAnimal = function (animal, startTimeAnimalB) {88 if (that.morph === 1) {89 for (var property in that.animalA) {90 that.animalA[property] = that.animalB[property];91 }92 that.animalB.currentTime = startTimeAnimalB ? startTimeAnimalB : 0;93 setAnimalData(animal, that.animalB);94 setFrame(that.animalB);95 that.morph = 0;96 } else {97 console.log("Error: Cannot change animal target if morph != 1. Skipping.");98 }99 };100 var setAnimalData = function (name, data) {101 if (ROME.AnimalAnimationData[name] !== undefined) {102 data.frames = ROME.AnimalAnimationData[name];103 data.lengthInFrames = data.frames.length;104 data.lengthInMS = data.frames[data.lengthInFrames - 1].time;105 data.name = name.toLowerCase();106 data.normalsOffset = Math.floor(data.frames.length * 0.5, 10);107 } else {108 console.log("Error: Couldn't find data for animal " + name);109 }110 };111 var setFrame = function (data) {112 var f, fl;113 var currentTime = data.currentTime;114 var frames = data.frames;115 for (f = 0, fl < frames.length; f < fl; f++) {116 if (currentTime >= frames[f].time) {117 data.currentFrame = f;118 return;119 }120 }121 };122 var setCurrentFrame = function (data) {123 };124 return that;125};126ROME.AnimalShader = {127 uniforms: function () {128 return THREE.UniformsUtils.merge([THREE.UniformsLib["common"],129 THREE.UniformsLib["lights"], {130 "animalAInterpolation": {131 type: "f",132 value: 0.0133 },134 "animalBInterpolation": {135 type: "f",136 value: 0.0137 },138 "animalMorphValue": {139 type: "f",140 value: 0.0141 },142 "lightScale": {143 type: "f",144 value: 1.0145 },146 "lightOffset": {147 type: "v3",148 value: new THREE.Vector3(0.0, 0.0, 0.0)149 }150 }151 ]);152 },153 attributes: function () {154 return {155 "colorAnimalA": {156 type: "c",157 boundTo: "faces",158 value: []159 },160 "colorAnimalB": {161 type: "c",162 boundTo: "faces",163 value: []164 }165 }166 },167 vertexShader: [168 "uniform float animalAInterpolation;",169 "uniform float animalBInterpolation;",170 "uniform float animalMorphValue;",171 "attribute vec3 colorAnimalA;",172 "attribute vec3 colorAnimalB;",173 "varying vec3 vColor;",174 "varying vec3 vLightWeighting;",175 THREE.ShaderChunk["lights_pars_vertex"],176 "uniform float lightScale;",177 "uniform vec3 lightOffset;",178 "void main() {",179 "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",180 "vColor = mix( colorAnimalA, colorAnimalB, animalMorphValue );",181 "vec3 animalA = mix( morphTarget0, morphTarget1, animalAInterpolation );",182 "vec3 animalB = mix( morphTarget2, morphTarget3, animalBInterpolation );",183 "vec3 morphed = mix( animalA, animalB, animalMorphValue );",184 "vec3 transformedNormal = normalize( normalMatrix * normal );",185 "vLightWeighting = vec3( 0.2 );",186 "vec4 lDirection = viewMatrix * vec4( vec3( 0.0, 1.0, 1.0 ), 0.0 );",187 "float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );",188 "vLightWeighting += vec3( 1.0 ) * directionalLightWeighting;",189 "gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );",190 "}"191 ].join("\n"),192 fragmentShader: [193 "uniform vec3 diffuse;",194 "uniform float opacity;",195 THREE.ShaderChunk["fog_pars_fragment"],196 THREE.ShaderChunk["lights_pars_fragment"],197 "varying vec3 vLightWeighting;",198 "varying vec3 vColor;",199 "void main() {",200 "gl_FragColor = vec4( vLightWeighting, 1.0 );",201 "float depth = gl_FragCoord.z / gl_FragCoord.w;",202 "float near = 0.0;",203 "float far = 2400.0;",204 "float fog = 0.0 + smoothstep( near, far, depth );",205 "gl_FragColor = gl_FragColor * vec4( vColor, 1.0 );",206 "gl_FragColor = mix( gl_FragColor, vec4( vec3(0.25,0.54,0.57), gl_FragColor.w ), fog );",207 "}"208 ].join("\n")209}210ROME.AnimalAnimationData = {211 animalNames: ["fisha", "fishb", "fishc", "fishd"],212 colorVariations: {213 "fish": {214 hRange: 0.00,215 sRange: 0.00,216 vRange: 0.00,217 hOffset: 0.00,218 sOffset: 0.00,219 vOffset: 0.00220 }221 },222 animalVariationMap: {223 "fisha": "fish",224 "fishb": "fish",225 "fishc": "fish",226 "fishd": "fish",227 },228 init: function (geometry, parseMorphTargetNames) {229 if (!geometry.initialized) {230 geometry.initialized = true;231 var availableAnimals = [];232 var animal, animalName;233 var charCode, morphTargetName, morphTarget, morphTargets = geometry.morphTargets;234 var a, al, m, ml, currentTime;235 if (parseMorphTargetNames) {236 for (m = 0, ml = morphTargets.length; m < ml; m++) {237 for (a = 0, al = this.animalNames.length; a < al; a++) {238 animalName = this.animalNames[a];239 if (morphTargets[m].name.indexOf(animalName) !== -1) {240 break;241 }242 }243 if (a === al) {244 morphTargetName = morphTargets[m].name;245 for (a = 0; a < morphTargetName.length; a++) {246 charCode = morphTargetName.charCodeAt(a);247 if (!((charCode >= 65 && charCode <= 90) ||248 (charCode >= 97 && charCode <= 122))) {249 break;250 }251 }252 this.animalNames.push(morphTargetName.slice(0, a));253 }254 }255 }256 for (a = 0, al = this.animalNames.length; a < al; a++) {257 animalName = this.animalNames[a];258 animal = this[animalName];259 currentTime = 0;260 if (animal === undefined || animal.length === 0) {261 animal = this[animalName] = [];262 for (m = 0, ml = morphTargets.length; m < ml; m++) {263 if (morphTargets[m].name.indexOf(animalName) !== -1) {264 animal.push({265 index: m,266 time: currentTime267 });268 currentTime += parseInt(1000 / 24, 10);269 if (availableAnimals.indexOf(animalName) === -1) {270 availableAnimals.push(animalName);271 }272 }273 }274 } else {275 for (m = 0, ml = morphTargets.length; m < ml; m++) {276 if (availableAnimals.indexOf(animalName) === -1 && morphTargets[m].name.indexOf(animalName) !== -1) {277 availableAnimals.push(animalName);278 }279 }280 }281 }282 var material = new THREE.MeshShaderMaterial({283 uniforms: ROME.AnimalShader.uniforms(),284 attributes: ROME.AnimalShader.attributes(),285 vertexShader: ROME.AnimalShader.vertexShader,286 fragmentShader: ROME.AnimalShader.fragmentShader,287 lights: true,288 morphTargets: true,289 vertexColors: THREE.VertexColors290 });291 var c, cl, morphColor, morphColors = geometry.morphColors;292 var attributes = material.attributes;293 if (geometry.morphColors && geometry.morphColors.length) {294 for (c = 0, cl = morphColors.length; c < cl; c++) {295 morphColor = morphColors[c];296 morphTargetName = morphColor.name;297 for (a = 0; a < morphTargetName.length; a++) {298 charCode = morphTargetName.charCodeAt(a);299 if (!((charCode >= 65 && charCode <= 90) ||300 (charCode >= 97 && charCode <= 122))) {301 break;302 }303 }304 morphTargetName = morphTargetName.slice(0, a).toLowerCase();305 attributes[morphTargetName] = {306 type: "c",307 boundTo: "faces",308 value: morphColor.colors309 };310 var variations = this.colorVariations["zero"];311 if (this.animalVariationMap[morphTargetName] !== undefined) {312 variations = this.colorVariations[this.animalVariationMap[morphTargetName]];313 }314 if (variations.lScale) {315 material.uniforms.lightScale.value = variations.lScale;316 } else {317 material.uniforms.lightScale.value = 0.5;318 }319 if (variations.lOffset) {320 material.uniforms.lightOffset.value.set(variations.lOffset[0], variations.lOffset[1], variations.lOffset[2]);321 } else {322 material.uniforms.lightOffset.value.set(0.6, 0.6, 0.6);323 }324 randomizeColors(attributes[morphTargetName].value, variations);325 }326 attributes.colorAnimalA.value = morphColors[0].colors;327 attributes.colorAnimalB.value = morphColors[0].colors;328 for (a = 0, al = availableAnimals.length; a < al; a++) {329 animalName = availableAnimals[a].toLowerCase();330 for (c = 0, cl = morphColors.length; c < cl; c++) {331 morphColor = morphColors[c].name.toLowerCase();332 if (morphColor.indexOf(animalName) !== -1) {333 break;334 }335 }336 if (c === cl) {337 console.error("Animal.constructor: Morph Color missing for animal " + animalName + ". Deploying backup plan.");338 attributes[animalName] = {339 type: "c",340 boundTo: "faces",341 value: []342 };343 for (c = 0, cl = geometry.faces.length; c < cl; c++) {344 attributes[animalName].value.push(new THREE.Color(0xff0000));345 }346 }347 }348 } else {349 console.error("Animal.constructor: Morph Colors doesn't exist, deploying fallback!");350 for (c = 0, cl = geometry.faces.length; c < cl; c++) {351 attributes.colorAnimalA.value.push(new THREE.Color(0xff00ff));352 }353 attributes.colorAnimalB.value = attributes.colorAnimalA.value;354 for (a = 0, al = availableAnimals; a < al; a++) {355 attributes[availableAnimals[a]] = {356 type: "c",357 boundTo: "faces",358 value: attributes.colorAnimalA.value359 };360 }361 }362 geometry.availableAnimals = availableAnimals;363 geometry.customAttributes = material.attributes;364 } else {365 var material = new THREE.MeshShaderMaterial({366 uniforms: ROME.AnimalShader.uniforms(),367 attributes: {},368 vertexShader: ROME.AnimalShader.vertexShader,369 fragmentShader: ROME.AnimalShader.fragmentShader,370 fog: true,371 lights: true,372 morphTargets: true373 });374 for (var a in geometry.customAttributes) {375 var srcAttribute = geometry.customAttributes[a];376 if (a === "colorAnimalA" || a === "colorAnimalB") {377 material.attributes[a] = {378 type: "c",379 size: 3,380 boundTo: srcAttribute.boundTo,381 value: srcAttribute.value,382 array: undefined,383 buffer: undefined,384 needsUpdate: false,385 __webglInitialized: true386 };387 } else {388 material.attributes[a] = srcAttribute;389 }390 }391 }392 return {393 availableAnimals: geometry.availableAnimals,394 material: material395 };396 }397};398function randomizeColors(colors, variations) {399 var i, il, c, hd, sd, vd;400 for (i = 0, il = colors.length; i < il; i++) {401 c = colors[i];402 hd = variations.hRange * Math.random() + variations.hOffset;403 sd = variations.sRange * Math.random() + variations.sOffset;404 vd = variations.vRange * Math.random() + variations.vOffset;405 THREE.ColorUtils.adjustHSV(c, hd, sd, vd);406 }...
animalReducer.js
Source:animalReducer.js
1import {hasValue, verboseOutput} from "./projectReducer";2import {3 ANIMAL_ASSIGNED,4 ANIMAL_LIST_FILTERED,5 ANIMAL_LIST_RECEIVED,6 ANIMAL_LIST_REQUEST_FAILED, ASSIGNED_ANIMAL_LIST_FILTERED,7 AVAILABLE_ANIMAL_LIST_FILTERED, UPDATE_ASSIGNED_ANIMALS8} from "../actions/dataActions";9export default (state = { }, action) => {10 let nextState = { ...state };11 nextState.errors = [];12 switch (action.type) {13 case ANIMAL_LIST_RECEIVED:14 // action payload is the animal array15 nextState.allAnimals = action.payload.map((row) => {16 let newRow = {};17 for (let [key, value] of Object.entries(row)) {18 newRow[key] = value.value;19 }20 newRow.assigned = false;21 return newRow;22 });23 nextState.availableAnimals = nextState.allAnimals.map(row => {return row});24 nextState.assignedAnimals = [];25 break;26 case ANIMAL_LIST_REQUEST_FAILED:27 // action payload is the exception28 nextState.allAnimals = [];29 nextState.availableAnimals = [];30 nextState.assignedAnimals = [];31 nextState.errors.push(action.payload);32 break;33 case ANIMAL_ASSIGNED:34 // action payload is the exception35 nextState.availableAnimals = [];36 nextState.errors.push(action.payload);37 break;38 case UPDATE_ASSIGNED_ANIMALS:39 // action payload is the timelineAnimalItems40 nextState.assignedAnimals = [];41 nextState.availableAnimals = [];42 if (nextState.allAnimals) {43 nextState.allAnimals.forEach(animal => {44 const assigned = action.payload.find(item => {45 return item.AnimalId === animal.Id && !item.IsDeleted;46 })47 if (assigned) {48 nextState.assignedAnimals.push({...animal, EndDate: assigned.EndDate});49 animal.assigned = true;50 }51 else {52 nextState.availableAnimals.push({...animal});53 }54 })55 }56 break;57 case AVAILABLE_ANIMAL_LIST_FILTERED:58 // action payload is the filter value59 const value = (action.payload + '').toUpperCase();60 nextState.availableAnimals = nextState.allAnimals.filter((animal) => {61 if (value !== '') {62 return (!animal.assigned && hasValue(animal.Id, value))63 }64 else {65 return (!animal.assigned)66 }67 })68 break;69 case ASSIGNED_ANIMAL_LIST_FILTERED:70 // action payload is the filter value71 const search = (action.payload + '').toUpperCase();72 nextState.assignedAnimals = nextState.allAnimals.filter((animal) => {73 if (search !== '') {74 return (animal.assigned && hasValue(animal.Id, search))75 }76 else {77 return (animal.assigned);78 }79 });80 break;81 }82 if (verboseOutput) {83 console.log('animalReducer() -> ' + action.type + '\nnext state:');84 console.log(nextState);85 }86 return nextState;...
getSchedule.js
Source:getSchedule.js
1const data = require('../data/zoo_data');2const getDayScheduleElse = (scheduleTarget, availableAnimals) => {3 const string = `Open from ${data.hours[scheduleTarget].open}am until `;4 const string2 = `${data.hours[scheduleTarget].close}pm`;5 const getFunctionResultDay = {6 [scheduleTarget]: {7 officeHour: string + string2,8 exhibition: availableAnimals,9 },10 };11 return getFunctionResultDay;12};13const getDaySchedule = (scheduleTarget) => {14 let result;15 const availableAnimals = data.species.filter((element) =>16 element.availability.includes(scheduleTarget)).map((element) => element.name);17 if (scheduleTarget === 'Monday') {18 result = {19 [scheduleTarget]: {20 officeHour: 'CLOSED',21 exhibition: 'The zoo will be closed!',22 },23 };24 } else {25 result = getDayScheduleElse(scheduleTarget, availableAnimals);26 }27 return result;28};29function getSchedule(scheduleTarget) {30 const days = Object.keys(data.hours);31 const specie = data.species.map((element) => element.name);32 let getFunctionResult = {};33 if (days.includes(scheduleTarget)) {34 getFunctionResult = getDaySchedule(scheduleTarget);35 } else if (specie.includes(scheduleTarget)) {36 getFunctionResult = data.species.find((element) => element.name === scheduleTarget)37 .availability;38 } else {39 let object;40 days.forEach((day) => {41 object = getDaySchedule(day);42 getFunctionResult[day] = object[day];43 });44 }45 return getFunctionResult;46}...
Using AI Code Generation
1const {Pact} = require('@pact-foundation/pact');2const path = require('path');3const {expect} = require('chai');4describe('Pact', () => {5 describe('availableAnimals', () => {6 it('returns a list of available animals', () => {7 const animals = Pact.availableAnimals();8 expect(animals).to.include('Cat');9 expect(animals).to.include('Dog');10 expect(animals).to.include('Pig');11 });12 });13});14const {Pact} = require('@pact-foundation/pact');15const path = require('path');16const {expect} = require('chai');17describe('Pact', () => {18 describe('availableAnimals', () => {19 it('returns a list of available animals', () => {20 const animals = Pact.availableAnimals();21 expect(animals).to.include('Cat');22 expect(animals).to.include('Dog');23 expect(animals).to.include('Pig');24 });25 });26});27const {Pact} = require('@pact-foundation/pact');28const path = require('path');29const {expect} = require('chai');30describe('Pact', () => {31 describe('availableAnimals', () => {32 it('returns a list of available animals', () => {33 const animals = Pact.availableAnimals();34 expect(animals).to.include('Cat');35 expect(animals).to.include('Dog');36 expect(animals).to.include('Pig');37 });38 });39});40const {Pact} = require('@pact-foundation/pact');41const path = require('path');42const {expect} = require('chai');43describe('Pact', () => {44 describe('availableAnimals', () => {45 it('returns a list of available animals', () => {46 const animals = Pact.availableAnimals();47 expect(animals).to.include('Cat');48 expect(animals).to.include('Dog');49 expect(animals).to.include('Pig');50 });51 });52});
Using AI Code Generation
1var Pact = require('pact-foundation-pact');2var pact = Pact();3var availableAnimals = pact.availableAnimals();4console.log(availableAnimals);5var Pact = require('pact-foundation-pact');6var pact = Pact();7var availableAnimals = pact.availableAnimals();8console.log(availableAnimals);9var Pact = require('pact-foundation-pact');10var pact = Pact();11var availableAnimals = pact.availableAnimals();12console.log(availableAnimals);13var Pact = require('pact-foundation-pact');14var pact = Pact();15var availableAnimals = pact.availableAnimals();16console.log(availableAnimals);17var Pact = require('pact-foundation-pact');18var pact = Pact();19var availableAnimals = pact.availableAnimals();20console.log(availableAnimals);21var Pact = require('pact-foundation-pact');22var pact = Pact();23var availableAnimals = pact.availableAnimals();24console.log(availableAnimals);25var Pact = require('pact-foundation-pact');26var pact = Pact();27var availableAnimals = pact.availableAnimals();28console.log(availableAnimals);29var Pact = require('pact-foundation-pact');30var pact = Pact();31var availableAnimals = pact.availableAnimals();32console.log(availableAnimals);33var Pact = require('pact-foundation-pact');34var pact = Pact();35var availableAnimals = pact.availableAnimals();36console.log(availableAnimals);
Using AI Code Generation
1const pact = require('pact-foundation/pact');2const path = require('path');3const expect = require('chai').expect;4const getMeSomeAnimals = require('./getMeSomeAnimals');5describe('Pact with Animals API', () => {6 const port = 1234;7 const provider = pact({8 log: path.resolve(process.cwd(), 'logs', 'pact.log'),9 dir: path.resolve(process.cwd(), 'pacts'),10 });11 before(() => provider.setup());12 after(() => provider.finalize());13 afterEach(() => provider.verify());14 describe('get a list of animals', () => {15 beforeEach(done => {16 const interaction = {17 withRequest: {18 headers: {19 }20 },21 willRespondWith: {22 headers: {23 'Content-Type': 'application/json; charset=utf-8'24 },25 body: pact.eachLike({26 animalType: pact.like('Dog'),27 legs: pact.integer(4)28 })29 }30 };31 provider.addInteraction(interaction)32 .then(() => done());33 });34 it('returns a successful body', done => {35 getMeSomeAnimals(url, port).then(response => {36 expect(response.data.length).to.be.above(0);37 done();38 });39 });40 });41});42const axios = require('axios');43const url = require('url');44module.exports = (baseUrl, port) => {45 const config = {46 headers: {47 }48 };49 const urlObj = {50 };51 return axios.get(url.format(urlObj), config);52};
Using AI Code Generation
1var pact = require('pact-foundation-pact');2var availableAnimals = pact.availableAnimals();3console.log(availableAnimals);4var pact = require('pact-foundation-pact');5var availableAnimals = pact.availableAnimals();6console.log(availableAnimals);7var pact = require('pact-foundation-pact');8var availableAnimals = pact.availableAnimals();9console.log(availableAnimals);10var pact = require('pact-foundation-pact');11var availableAnimals = pact.availableAnimals();12console.log(availableAnimals);13var pact = require('pact-foundation-pact');14var availableAnimals = pact.availableAnimals();15console.log(availableAnimals);16var pact = require('pact-foundation-pact');17var availableAnimals = pact.availableAnimals();18console.log(availableAnimals);19var pact = require('pact-foundation-pact');20var availableAnimals = pact.availableAnimals();21console.log(availableAnimals);22var pact = require('pact-foundation-pact');23var availableAnimals = pact.availableAnimals();24console.log(availableAnimals);
Using AI Code Generation
1var pact = require('pact-foundation/pact');2pact.availableAnimals(function (error, animals) {3 if (error) {4 console.log(error);5 } else {6 console.log(animals);7 }8});9var pact = require('pact-foundation/pact');10pact.availableAnimals().then(function (animals) {11 console.log(animals);12}, function (error) {13 console.log(error);14});15var pact = require('pact-foundation/pact');16pact.availableAnimals(function (error, animals) {17 if (error) {18 console.log(error);19 } else {20 console.log(animals.indexOf('cat') >= 0);21 }22});23var pact = require('pact-foundation/pact');24pact.availableAnimals(function (error, animals) {25 if (error) {26 console.log(error);27 } else {28 console.log(animals);29 }30});31var pact = require('pact-foundation/pact');32pact.availableAnimals(function (error, animals) {33 if (error) {34 console.log(error);35 } else {36 console.log(animals.indexOf('cat') >= 0);37 }38});
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!!