How to use withRequestBody method in pact-foundation-pact

Best JavaScript code snippet using pact-foundation-pact

request-body.spec.ts

Source:request-body.spec.ts Github

copy

Full Screen

...27 const createSpecWithRequestBodyWithoutSchema = () => {28 return openApi3SpecBuilder29 .withPath(defaultPath, openApi3PathItemBuilder30 .withOperation(defaultMethod, openApi3OperationBuilder31 .withRequestBody(openApi3RequestBodyBuilder32 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder))));33 };34 const createSpecWithRequestBodySchema = (schema: OpenApi3Schema): OpenApi3SpecBuilder => {35 return openApi3SpecBuilder36 .withPath(defaultPath, openApi3PathItemBuilder37 .withOperation(defaultMethod, openApi3OperationBuilder38 .withRequestBody(openApi3RequestBodyBuilder39 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder40 .withJsonContentSchema(schema)))));41 };42 it('should return no differences for the same spec', async () => {43 const aSpec = createSpecWithRequestBodySchema({type: 'string'});44 const outcome = await whenSpecsAreDiffed(aSpec, aSpec);45 expect(outcome).toContainDifferences([]);46 });47 it('should return a breaking and non-breaking differences if request schema scope is changed', async () => {48 const sourceSpec = createSpecWithRequestBodySchema({type: 'string'});49 const destinationSpec = createSpecWithRequestBodySchema({type: 'number'});50 const outcome = await whenSpecsAreDiffed(sourceSpec, destinationSpec);51 expect(outcome).toContainDifferences([52 nonBreakingDiffResultBuilder53 .withAction('add')54 .withCode('request.body.scope.add')55 .withEntity('request.body.scope')56 .withSource('json-schema-diff')57 .withSourceSpecEntityDetails([58 specEntityDetailsBuilder59 .withLocation(defaultTypeChangeLocation)60 .withValue({type: 'string'})61 ])62 .withDestinationSpecEntityDetails([63 specEntityDetailsBuilder64 .withLocation(defaultTypeChangeLocation)65 .withValue({type: 'number'})66 ])67 .withDetails({differenceSchema: jasmine.any(Object)})68 .build(),69 breakingDiffResultBuilder70 .withAction('remove')71 .withCode('request.body.scope.remove')72 .withEntity('request.body.scope')73 .withSource('json-schema-diff')74 .withSourceSpecEntityDetails([75 specEntityDetailsBuilder76 .withLocation(defaultTypeChangeLocation)77 .withValue({type: 'string'})78 ])79 .withDestinationSpecEntityDetails([80 specEntityDetailsBuilder81 .withLocation(defaultTypeChangeLocation)82 .withValue({type: 'number'})83 ])84 .withDetails({differenceSchema: jasmine.any(Object)})85 .build()86 ]);87 });88 it('should find differences for request bodies in all operations', async () => {89 const sourceSpec = openApi3SpecBuilder90 .withPath(defaultPath, openApi3PathItemBuilder91 .withOperation('put', openApi3OperationBuilder92 .withRequestBody(openApi3RequestBodyBuilder93 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder94 .withJsonContentSchema({type: 'string'}))))95 .withOperation('post', openApi3OperationBuilder96 .withRequestBody(openApi3RequestBodyBuilder97 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder98 .withJsonContentSchema({type: 'string'})))));99 const destinationSpec = openApi3SpecBuilder100 .withPath(defaultPath, openApi3PathItemBuilder101 .withOperation('put', openApi3OperationBuilder102 .withRequestBody(openApi3RequestBodyBuilder103 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder104 .withJsonContentSchema({type: 'number'}))))105 .withOperation('post', openApi3OperationBuilder106 .withRequestBody(openApi3RequestBodyBuilder107 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder108 .withJsonContentSchema({type: 'number'})))));109 const outcome = await whenSpecsAreDiffed(sourceSpec, destinationSpec);110 expect(outcome.nonBreakingDifferences.length).toBe(2, 'find differences in all operations of a path');111 });112 it('should return breaking differences, when a request body was added', async () => {113 const sourceSpec = createSpecWithNoRequestBody();114 const destinationSpec = createSpecWithRequestBodySchema({type: 'string'});115 const outcome = await whenSpecsAreDiffed(sourceSpec, destinationSpec);116 expect(outcome).toContainDifferences([117 breakingDiffResultBuilder118 .withAction('remove')119 .withCode('request.body.scope.remove')120 .withEntity('request.body.scope')121 .withSource('json-schema-diff')122 .withSourceSpecEntityDetails([])123 .withDestinationSpecEntityDetails([124 specEntityDetailsBuilder125 .withLocation(defaultTypeChangeLocation)126 .withValue({type: 'string'})127 ])128 .withDetails({differenceSchema: jasmine.any(Object)})129 .build()130 ]);131 });132 it('should return non-breaking differences, when a request body was removed', async () => {133 const sourceSpec = createSpecWithRequestBodySchema({type: 'string'});134 const destinationSpec = createSpecWithNoRequestBody();135 const outcome = await whenSpecsAreDiffed(sourceSpec, destinationSpec);136 expect(outcome).toContainDifferences([137 nonBreakingDiffResultBuilder138 .withAction('add')139 .withCode('request.body.scope.add')140 .withEntity('request.body.scope')141 .withSource('json-schema-diff')142 .withSourceSpecEntityDetails([143 specEntityDetailsBuilder144 .withLocation(defaultTypeChangeLocation)145 .withValue({type: 'string'})146 ])147 .withDestinationSpecEntityDetails([])148 .withDetails({differenceSchema: jasmine.any(Object)})149 .build()150 ]);151 });152 it('should return breaking differences, when a schema was added onto a request body', async () => {153 const sourceSpec = createSpecWithRequestBodyWithoutSchema();154 const destinationSpec = createSpecWithRequestBodySchema({type: 'string'});155 const outcome = await whenSpecsAreDiffed(sourceSpec, destinationSpec);156 expect(outcome).toContainDifferences([157 breakingDiffResultBuilder158 .withAction('remove')159 .withCode('request.body.scope.remove')160 .withEntity('request.body.scope')161 .withSource('json-schema-diff')162 .withSourceSpecEntityDetails([])163 .withDestinationSpecEntityDetails([164 specEntityDetailsBuilder165 .withLocation(defaultTypeChangeLocation)166 .withValue({type: 'string'})167 ])168 .withDetails({differenceSchema: jasmine.any(Object)})169 .build()170 ]);171 });172 it('should return non-breaking differences, when the schema was removed from a request body', async () => {173 const sourceSpec = createSpecWithRequestBodySchema({type: 'string'});174 const destinationSpec = createSpecWithRequestBodyWithoutSchema();175 const outcome = await whenSpecsAreDiffed(sourceSpec, destinationSpec);176 expect(outcome).toContainDifferences([177 nonBreakingDiffResultBuilder178 .withAction('add')179 .withCode('request.body.scope.add')180 .withEntity('request.body.scope')181 .withSource('json-schema-diff')182 .withSourceSpecEntityDetails([183 specEntityDetailsBuilder184 .withLocation(defaultTypeChangeLocation)185 .withValue({type: 'string'})186 ])187 .withDestinationSpecEntityDetails([])188 .withDetails({differenceSchema: jasmine.any(Object)})189 .build()190 ]);191 });192 it('should find differences in request bodies with references', async () => {193 const sourceSpec = openApi3SpecBuilder194 .withComponents(openApi3ComponentsBuilder195 .withSchema('stringSchema', {type: 'string'})196 .withSchema('requestBodySchema', {$ref: '#/components/schemas/stringSchema'})197 .withRequestBody(198 'RequestBody', openApi3RequestBodyBuilder199 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder200 .withSchemaRef('#/components/schemas/requestBodySchema'))))201 .withPath(defaultPath, openApi3PathItemBuilder202 .withOperation(defaultMethod, openApi3OperationBuilder203 .withRequestBody(refObjectBuilder.withRef('#/components/requestBodies/RequestBody'))));204 const destinationSpec = createSpecWithRequestBodySchema({type: 'number'});205 const outcome = await whenSpecsAreDiffed(sourceSpec, destinationSpec);206 expect(outcome.nonBreakingDifferences.length).toBe(1);207 expect((outcome as DiffOutcomeFailure).breakingDifferences.length).toBe(1);208 });209 it('should handle the case of a circular requestBody schema', async () => {210 const spec = openApi3SpecBuilder211 .withComponents(openApi3ComponentsBuilder212 .withSchema('stringSchema',213 {214 additionalProperties: {$ref: '#/components/schemas/stringSchema'},215 type: 'object'216 }))217 .withPath(defaultPath, openApi3PathItemBuilder218 .withOperation(defaultMethod, openApi3OperationBuilder219 .withRequestBody(openApi3RequestBodyBuilder220 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder221 .withSchemaRef('#/components/schemas/stringSchema')))));222 const error = await expectToFail(whenSpecsAreDiffed(spec, spec));223 expect(error.message).toContain('Circular $ref pointer found');224 expect((error as OpenApiDiffError).code).toEqual('OPENAPI_DIFF_DIFF_ERROR');225 });226 it('should handle the case of a circular requestBody schema when requestBody is a reference itself', async () => {227 const spec = openApi3SpecBuilder228 .withComponents(openApi3ComponentsBuilder229 .withSchema('stringSchema',230 {231 additionalProperties: {$ref: '#/components/schemas/stringSchema'},232 type: 'object'233 })234 .withRequestBody('requestBodyReference', openApi3RequestBodyBuilder235 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder236 .withSchemaRef('#/components/schemas/stringSchema'))))237 .withPath('/some/path', openApi3PathItemBuilder238 .withOperation('post', openApi3OperationBuilder239 .withRequestBody(refObjectBuilder240 .withRef('#/components/requestBodies/requestBodyReference'))));241 const error = await expectToFail(whenSpecsAreDiffed(spec, spec));242 expect(error.message).toContain('Circular $ref pointer found');243 expect((error as OpenApiDiffError).code).toEqual('OPENAPI_DIFF_DIFF_ERROR');244 });245 it('should handle the case of a circular requestBody schema when requestBody is a deep reference', async () => {246 const sourceSpec = openApi3SpecBuilder247 .withComponents(openApi3ComponentsBuilder248 .withRequestBody('nonCircularReferenceA', refObjectBuilder249 .withRef('#/components/requestBodies/nonCircularReferenceB'))250 .withRequestBody('nonCircularReferenceB', openApi3RequestBodyBuilder251 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder252 .withJsonContentSchema({type: 'string'}))253 .withMediaType('application/xml', openApi3MediaTypeBuilder254 .withSchemaRef('#/x-circular-schema/schemaThatPreventsDereferencing'))))255 .withPath('/some/path', openApi3PathItemBuilder256 .withOperation('post', openApi3OperationBuilder257 .withRequestBody(refObjectBuilder258 .withRef('#/components/requestBodies/nonCircularReferenceA'))))259 .withTopLevelXProperty('x-circular-schema', {260 schemaThatPreventsDereferencing: {261 additionalProperties: {262 $ref: '#/x-circular-schema/schemaThatPreventsDereferencing'263 },264 type: 'object'265 }266 });267 const destinationSpec = openApi3SpecBuilder268 .withPath('/some/path', openApi3PathItemBuilder269 .withOperation('post', openApi3OperationBuilder270 .withRequestBody(openApi3RequestBodyBuilder271 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder272 .withJsonContentSchema({type: 'number'}))273 .withMediaType('application/xml', openApi3MediaTypeBuilder274 .withSchemaRef('#/x-circular-schema/schemaThatPreventsDereferencing')))))275 .withTopLevelXProperty('x-circular-schema', {276 schemaThatPreventsDereferencing: {277 additionalProperties: {278 $ref: '#/x-circular-schema/schemaThatPreventsDereferencing'279 },280 type: 'object'281 }282 });283 const outcome = await whenSpecsAreDiffed(sourceSpec, destinationSpec);284 expect((outcome as DiffOutcomeFailure).breakingDifferences.length).toBe(1);285 });286 // Can't be properly tested until json-schema-diff can detect differences in number schemas287 it('should convert requestBodies with falsy exclusiveMinimum to a valid JSON schema to diff', async () => {288 const spec = createSpecWithRequestBodySchema({289 exclusiveMinimum: false,290 minimum: 0,291 type: 'number'292 });293 const outcome = await whenSpecsAreDiffed(spec, spec);294 expect(outcome).toContainDifferences([]);295 });296 // Can't be properly tested until json-schema-diff can detect differences in number schemas297 it('should convert requestBodies with truthy exclusiveMinimum to a valid JSON schema to diff', async () => {298 const spec = createSpecWithRequestBodySchema({299 exclusiveMinimum: true,300 minimum: 0,301 type: 'number'302 });303 const outcome = await whenSpecsAreDiffed(spec, spec);304 expect(outcome).toContainDifferences([]);305 });306 // Can't be properly tested until json-schema-diff can detect differences in number schemas307 it('should convert requestBodies with falsy exclusiveMaximum to a valid JSON schema to diff', async () => {308 const spec = createSpecWithRequestBodySchema({309 exclusiveMaximum: false,310 maximum: 10,311 type: 'number'312 });313 const outcome = await whenSpecsAreDiffed(spec, spec);314 expect(outcome).toContainDifferences([]);315 });316 // Can't be properly tested until json-schema-diff can detect differences in number schemas317 it('should convert requestBodies with truthy exclusiveMaximum to a valid JSON schema to diff', async () => {318 const spec = createSpecWithRequestBodySchema({319 exclusiveMaximum: true,320 minimum: 0,321 type: 'number'322 });323 const outcome = await whenSpecsAreDiffed(spec, spec);324 expect(outcome).toContainDifferences([]);325 });326 it('should convert schemas with incompatible additionalProperties to a valid JSON schema to diff', async () => {327 const spec = createSpecWithRequestBodySchema({328 additionalProperties: {329 exclusiveMinimum: true,330 type: 'number'331 },332 type: 'object'333 });334 const outcome = await whenSpecsAreDiffed(spec, spec);335 expect(outcome).toContainDifferences([]);336 });337 it('should not modify schemas with boolean additionalProperties when sending them to diff', async () => {338 const aSpecWithFalseAdditionalProperties = createSpecWithRequestBodySchema({339 additionalProperties: false,340 type: 'object'341 });342 const aSpecWithTrueAdditionalProperties = createSpecWithRequestBodySchema({343 additionalProperties: true,344 type: 'object'345 });346 const outcome = await whenSpecsAreDiffed(aSpecWithFalseAdditionalProperties, aSpecWithTrueAdditionalProperties);347 expect(outcome.nonBreakingDifferences.length).toBeGreaterThan(0);348 });349 it('should convert schemas with incompatible allOf to a valid JSON schema by json-schema-diff', async () => {350 const spec = createSpecWithRequestBodySchema({351 allOf: [{352 exclusiveMinimum: true,353 type: 'number'354 }]355 });356 const outcome = await whenSpecsAreDiffed(spec, spec);357 expect(outcome).toContainDifferences([]);358 });359 it('should convert schemas with incompatible anyOf to a valid JSON schema by json-schema-diff', async () => {360 const spec = createSpecWithRequestBodySchema({361 anyOf: [{362 exclusiveMinimum: true,363 type: 'number'364 }]365 });366 const outcome = await whenSpecsAreDiffed(spec, spec);367 expect(outcome).toContainDifferences([]);368 });369 it('should convert schemas with incompatible items to a valid JSON schema by json-schema-diff', async () => {370 const spec = createSpecWithRequestBodySchema({371 items: {372 exclusiveMinimum: true,373 type: 'number'374 },375 type: 'array'376 });377 const outcome = await whenSpecsAreDiffed(spec, spec);378 expect(outcome).toContainDifferences([]);379 });380 it('should convert schemas with incompatible "not" to a valid JSON schema by json-schema-diff', async () => {381 const spec = createSpecWithRequestBodySchema({382 not: {383 exclusiveMinimum: true,384 type: 'number'385 },386 type: 'object'387 });388 const outcome = await whenSpecsAreDiffed(spec, spec);389 expect(outcome).toContainDifferences([]);390 });391 it('should convert schemas with incompatible oneOf to a valid JSON schema by json-schema-diff', async () => {392 const spec = createSpecWithRequestBodySchema({393 oneOf: [{394 exclusiveMinimum: true,395 type: 'number'396 }]397 });398 const outcome = await whenSpecsAreDiffed(spec, spec);399 expect(outcome).toContainDifferences([]);400 });401 it('should convert schemas with incompatible properties to a valid JSON schema by json-schema-diff', async () => {402 const spec = createSpecWithRequestBodySchema({403 properties: {404 property: {405 exclusiveMinimum: true,406 type: 'number'407 }408 },409 type: 'object'410 });411 const outcome = await whenSpecsAreDiffed(spec, spec);412 expect(outcome).toContainDifferences([]);413 });414 // This test always passes as references are generally dereferenced, and json-schema validation ignores "components"415 it('should convert schemas with incompatible schema reference sources to a valid schema to diff', async () => {416 const spec = openApi3SpecBuilder417 .withComponents(openApi3ComponentsBuilder418 .withSchema('numberSchema', {419 exclusiveMaximum: false,420 maximum: 1,421 type: 'number'422 }))423 .withPath(defaultPath, openApi3PathItemBuilder424 .withOperation(defaultMethod, openApi3OperationBuilder425 .withRequestBody(openApi3RequestBodyBuilder426 .withMediaType(defaultMediaType, openApi3MediaTypeBuilder427 .withJsonContentSchema({428 properties: {429 numberProperty: {430 $ref: '#/components/schemas/numberSchema'431 }432 },433 type: 'object'434 })))));435 const outcome =436 await whenSpecsAreDiffed(spec, spec);437 expect(outcome).toContainDifferences([]);438 });439});

Full Screen

Full Screen

calculator-handler.test.js

Source:calculator-handler.test.js Github

copy

Full Screen

...6 it('Should add two numbers, return the result and a status code 200', async () => {7 const builder = new CloudContextBuilder();8 const context = await builder9 .asHttpRequest({})10 .withRequestBody(11 {12 firstOperand: '10',13 secondOperand: '15',14 operator: '+',15 },16 )17 .withRequestMethod('POST')18 .invokeHandler(handler);19 expect(context.res.status).toEqual(200);20 expect(context.res.body.result).toEqual(25);21 expect(context.res.body).toHaveProperty('sessionId');22 });23 it('Should add the number from the request and the number from storage, return the result and a status code 200', async () => {24 const builder = new CloudContextBuilder();25 const addMock = jest.spyOn(mock, 'readAsString');26 addMock.mockImplementation(() => '20');27 const context = await builder28 .asHttpRequest({})29 .withRequestBody(30 {31 sessionId: '0e1cb016-f9f0-46ba-89cb-6bf4669c94d6',32 secondOperand: '15',33 operator: '+',34 },35 )36 .withRequestMethod('POST')37 .invokeHandler(handler);38 expect(context.res.status).toEqual(200);39 expect(context.res.body.result).toEqual(35);40 expect(context.res.body).toHaveProperty('sessionId');41 });42 it('Should substract the number from the request to the number from storage, return the result and a status code 200', async () => {43 const builder = new CloudContextBuilder();44 const addMock = jest.spyOn(mock, 'readAsString');45 addMock.mockImplementation(() => '20');46 const context = await builder47 .asHttpRequest({})48 .withRequestBody(49 {50 sessionId: '0e1cb016-f9f0-46ba-89cb-6bf4669c94d6',51 secondOperand: '15',52 operator: '-',53 },54 )55 .withRequestMethod('POST')56 .invokeHandler(handler);57 expect(context.res.status).toEqual(200);58 expect(context.res.body.result).toEqual(5);59 expect(context.res.body).toHaveProperty('sessionId');60 });61 it('Should divide the number from the storage by the number from the request, return the result and a status code 200', async () => {62 const builder = new CloudContextBuilder();63 const addMock = jest.spyOn(mock, 'readAsString');64 addMock.mockImplementation(() => '20');65 const context = await builder66 .asHttpRequest({})67 .withRequestBody(68 {69 sessionId: '0e1cb016-f9f0-46ba-89cb-6bf4669c94d6',70 secondOperand: '4',71 operator: '/',72 },73 )74 .withRequestMethod('POST')75 .invokeHandler(handler);76 expect(context.res.status).toEqual(200);77 expect(context.res.body.result).toEqual(5);78 expect(context.res.body).toHaveProperty('sessionId');79 });80 it('Should multiply the number from the request and the number from storage, return the result and a status code 200', async () => {81 const builder = new CloudContextBuilder();82 const addMock = jest.spyOn(mock, 'readAsString');83 addMock.mockImplementation(() => '20');84 const context = await builder85 .asHttpRequest({})86 .withRequestBody(87 {88 sessionId: '0e1cb016-f9f0-46ba-89cb-6bf4669c94d6',89 secondOperand: '5',90 operator: '*',91 },92 )93 .withRequestMethod('POST')94 .invokeHandler(handler);95 expect(context.res.status).toEqual(200);96 expect(context.res.body.result).toEqual(100);97 expect(context.res.body).toHaveProperty('sessionId');98 });99 it('return NaN and status code 200 when divided by 0', async () => {100 const builder = new CloudContextBuilder();101 const context = await builder102 .asHttpRequest()103 .withRequestBody(104 {105 firstOperand: '10',106 secondOperand: '0',107 operator: '/',108 },109 )110 .withRequestMethod('POST')111 .invokeHandler(handler);112 expect(context.res.status).toEqual(200);113 expect(context.res.body.result).toEqual('NaN');114 expect(context.res.body).toHaveProperty('sessionId');115 });116 it('Should return Invalid Operand and status code 400 when at least one param is not a number', async () => {117 const builder = new CloudContextBuilder();118 const context = await builder119 .asHttpRequest()120 .withRequestBody(121 {122 firstOperand: '10',123 secondOperand: 'This is not a number',124 operator: '/',125 },126 )127 .withRequestMethod('POST')128 .invokeHandler(handler);129 expect(context.res.status).toEqual(400);130 expect(context.res.body).toEqual({ result: 'Invalid Operand' });131 });132 it('Should return Invalid Input and status code 400 when at least one param is undefined', async () => {133 const builder = new CloudContextBuilder();134 const context = await builder135 .asHttpRequest()136 .withRequestBody(137 {138 secondOperand: '1',139 operator: '/',140 },141 )142 .withRequestMethod('POST')143 .invokeHandler(handler);144 expect(context.res.status).toEqual(400);145 expect(context.res.body).toEqual({ result: 'Invalid Input' });146 });147 it('Should return Invalid Operator and status code 400 when a non supported operation is requested', async () => {148 const builder = new CloudContextBuilder();149 const context = await builder150 .asHttpRequest()151 .withRequestBody(152 {153 firstOperand: '10',154 secondOperand: '12',155 operator: 'ñ',156 },157 )158 .withRequestMethod('POST')159 .invokeHandler(handler);160 expect(context.res.status).toEqual(400);161 expect(context.res.body).toEqual({ result: 'Invalid Operator' });162 });...

Full Screen

Full Screen

af-api-folder-accessor.ts

Source:af-api-folder-accessor.ts Github

copy

Full Screen

...23 (new AFEndpointRequestBuilder())24 .withHTTPMethod(HTTPMethod.GET)25 .withEndpointPath("/folder")26 .withToken(sessionToken)27 .withRequestBody({ id: folderID })28 .build()29 );30 31 }32 33 public static async getQuestions(sessionToken: string, folderID: string): Promise<ReadonlyArray<AFQuestionResponseStructure>> {34 35 return await AFAPI.makeRequest(36 (new AFEndpointRequestBuilder())37 .withHTTPMethod(HTTPMethod.GET)38 .withEndpointPath("/folder/questions")39 .withToken(sessionToken)40 .withRequestBody({ id: folderID })41 .build()42 );43 44 }45 46 public static async createForOrganization(sessionToken: string,47 name: string,48 shuffled: boolean,49 questionIDs: string[] = []): Promise<AFFolderResponseStructure> {50 51 return await AFAPI.makeRequest(52 (new AFEndpointRequestBuilder())53 .withHTTPMethod(HTTPMethod.POST)54 .withEndpointPath("/folder")55 .withToken(sessionToken)56 .withRequestBody({57 name,58 shuffled,59 questionIds: questionIDs60 })61 .build()62 );63 64 }65 66 public static async updateName(sessionToken: string, folderID: string, name: string): Promise<AFFolderResponseStructure> {67 68 return await AFAPI.makeRequest(69 (new AFEndpointRequestBuilder())70 .withHTTPMethod(HTTPMethod.PUT)71 .withEndpointPath("/folder/name")72 .withToken(sessionToken)73 .withRequestBody({74 id: folderID,75 name76 })77 .build()78 );79 80 }81 82 public static async updateShuffled(sessionToken: string, folderID: string, shuffled: boolean): Promise<AFFolderResponseStructure> {83 84 return await AFAPI.makeRequest(85 (new AFEndpointRequestBuilder())86 .withHTTPMethod(HTTPMethod.PUT)87 .withEndpointPath("/folder/shuffled")88 .withToken(sessionToken)89 .withRequestBody({90 id: folderID,91 shuffled92 })93 .build()94 );95 96 }97 98 public static async updateQuestions(sessionToken: string, folderID: string, questions: string[]): Promise<AFFolderResponseStructure> {99 100 return await AFAPI.makeRequest(101 (new AFEndpointRequestBuilder())102 .withHTTPMethod(HTTPMethod.PUT)103 .withEndpointPath("/folder/questions")104 .withToken(sessionToken)105 .withRequestBody({106 id: folderID,107 questions108 })109 .build()110 );111 112 }113 114}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Matchers } from '@pact-foundation/pact-web';2const { like, eachLike, term, somethingLike } = Matchers;3const body = {4 id: like(1),5 name: term({6 }),7 age: somethingLike(30),8 hobbies: eachLike('reading', { min: 1 })9};10export default body;11import { Matchers } from '@pact-foundation/pact-web';12const { like, eachLike, term, somethingLike } = Matchers;13const body = {14 id: like(1),15 name: term({16 }),17 age: somethingLike(30),18 hobbies: eachLike('reading', { min: 1 })19};20export default body;21import { Matchers } from '@pact-foundation/pact-web';22const { like, eachLike, term, somethingLike } = Matchers;23const body = {24 id: like(1),25 name: term({26 }),27 age: somethingLike(30),28 hobbies: eachLike('reading', { min: 1 })29};30export default body;31import { Matchers } from '@pact-foundation/pact-web';32const { like, eachLike, term, somethingLike } = Matchers;33const body = {34 id: like(1),35 name: term({36 }),37 age: somethingLike(30),38 hobbies: eachLike('reading', { min: 1 })39};40export default body;

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 pact-foundation-pact 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