Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid character-set error while uploading verification results from provider #544

Closed
5 of 6 tasks
ankur-malik-sky opened this issue Dec 22, 2020 · 3 comments
Closed
5 of 6 tasks

Comments

@ankur-malik-sky
Copy link

Issue Classification

  • Feature request
  • Bug report

Bug Report

Hi Team, I am facing one issue when I am using Provider verification without broker URL and token my tests are passing, but when I add pact broker URL (pactflow.io) and token it gave me below error

Software versions

  • OS: Mac Big Sur 11.1
  • Consumer Pact library: Pact JS v9.13.0
  • Provider Pact library: Pact Js v9.13.0
  • Node Version: v14.15.1

Issue Checklist

Confirm the following:

  • I have upgraded to the latest
  • I have created a reproducable git repository (see below) to illuminate the problem
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code

Expected behaviour

Should upload the verification results to the pactflow

Actual behaviour

Gives invalid character-set error

Steps to reproduce

https://pact-foundation.slack.com/files/U01GVR4BB63/F01J2GAGY6L/pact.zip

download above code and run yarn pact

Relevant log files

https://pact-foundation.slack.com/archives/C9VBGLUM9/p1608631701063200?thread_ts=1608430770.046500&cid=C9VBGLUM9

@mefellows
Copy link
Member

Thanks @ankur-malik-sky for submitting.

After what was too long attempting to debug this, I think the issue is that you're simply not returning (or awaiting) the promise from the verification process.

i.e. this is an async function

    new Verifier(opts).verifyProvider().then((output) => {
      console.log(output);
    });

This is going to cause strange things to happen, because the test is closing down whilst running process down whilst the test. Can you please give this a go?

FWIW there are projects in the example repository you can use as a guide, or examples such as https://docs.pactflow.io/docs/examples/.

@ankur-malik-sky
Copy link
Author

Hi @mefellows, Thanks for your prompt response, I might be missing something very basic here and as you mentioned the issues is definitely the tearing down of the server before request complete but I am not sure how to fix this, I have already tried below settings (and all possible combinations of this):

`describe("provider pact tests", () => {
it("should validate pact provider", () => {
...

return new Verifier(opts).verifyProvider().then((output) => {
  console.log(output);
});

});`

`describe("provider pact tests", () => {
it("should validate pact provider", async () => {
...

return await new Verifier(opts).verifyProvider().then((output) => {
  console.log(output);
});

});`

@mefellows
Copy link
Member

The first problem is that you don't have a provider running (at least not in the example you shared), so it's hard to tell what the problem is because that is an important aspect of the provider test.

I've modified the code base you shared and pushed here: https://github.com/mefellows/pact-js-issue-544 (adding a basic express API to show how it works).

I'm going to close this issue. If you can reproduce a problem with pact in the example I shared, happy to re-open. As mentioned, there are other e2e examples in this repo you can also use as a guide or to reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants