requestFilter is for the provider side
# pact-js
m
requestFilter is for the provider side
m
Yes, my mistake. I saw in the examples that they are build similiar to the consumer tests and just assumed.
Copy code
describe("Pact Verification", () => {
    it("validates the expectations of ProductService", () => {
        const opts = {
            logLevel: "INFO",
            providerBaseUrl: "<http://localhost:8080>",
            provider: "ProductService",
            providerVersion: "1.0.0",
            pactUrls: [
                path.resolve(__dirname, '../../consumer/pacts/frontendwebsite-productservice.json')
            ]
        };

        return new Verifier(opts).verifyProvider().then(output => {
            console.log(output);
        }).finally(() => {
            server.close();
        });
    })
and there you add the request filter. My Setup looks different:,
Copy code
@RestIntegrationTest
@Provider("X")
@Consumer("X")
@PactBroker(
    providerTags = ["master"],
    enablePendingPacts = "false",
    host = "localhost",
    port = "9292",
    scheme = "http",
    authentication=PactBrokerAuth(username =  "X", password = "X")
    )


class BXBXProviderTest {

    @BeforeEach
    fun before(context: PactVerificationContext) {
        val myProviderUrl = "<Http://localhost:8080>"
        context.target = HttpTestTarget.fromUrl(URL(myProviderUrl))
        

    }

    companion object {
        @BeforeAll
        fun setup() {
            System.setProperty("pact.verifier.publishResults", "true")
            System.setProperty("pact.provider.version", "1.0.1")
            System.setProperty("pact.provider.tag", "master")
        }
    }

    @TestTemplate
    @ExtendWith(PactVerificationInvocationContextProvider::class)
    fun pactVerificationTestTemplate(context: PactVerificationContext) {
        context.verifyInteraction()

    }

    @Test
    @State("given search results")
    fun testGetAdverts() {
    }
    @Test
    @State("given searchAgent found")
    fun testSearchAgentWasFound() {
    }
    @Test
    @State("given no SearchAgent was found")
    fun testNoSearchAgentWasFound() {
    }
y
is that java using junit5?
m
it's actually typescript
y
oh, I just saw the @TestTemplate annotations, and had seen them in JVM land
m
yeah i copied them from my java test and it seemed to work and i didn't bother looking up the correct way it seems.
y
🙂 It's on my list to make things like our features, easier to see across languages/implementations on the website, so you could see an example in java/js/ruby etc, as currently it involves a bit of searching around
m
Thank you.
y
Let us know how you get on with the request filters, pact-js docs are here (for v2) https://github.com/pact-foundation/pact-js#modify-requests-prior-to-verification-request-filters there is a 2nd section for v3, https://github.com/pact-foundation/pact-js#request-filters let us know how you get on, and give us a shout if you get stuck