Search code examples
regexscalaperformance-testinggatling

gatling jsonPath partial string match


My full code is as below

 val TC04 = feed(accountNumberFeeder04).exec(http(testCase04).post(appendPathToUrl).headers(common_header).body(postPayload).asJSON
    .check(jsonPath("$..errorMessage").is(errorMessage04))
   )

So my HTTP response have a some dynamic text.

say bla bla bla part in my message is get changed every time.

So, How can I match partial string using Gatling DSL or using some regex expressions.

.check(jsonPath("My error message is bla bla bla ....").is("My error message"))

Solution

  • If you can express the correct jsonPath but the .is() condition is too restrictive you can try with .exists() which simply checks if anything in given jsonPath was matched.