pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.58k stars 343 forks source link

TypeError: createColors is not a function (Umi3) #1130

Closed Canoe-Silhouette closed 1 month ago

Canoe-Silhouette commented 8 months ago

TypeError: createColors is not a function (Umi3)

Software versions

Please provide at least OS and version of pact-js

Issue Checklist

Please confirm the following:

Expected behaviour

Run PactV3 tests in Umi(v3.5).

Actual behaviour

Our team use Umi(v3.5) as the front-end framework, but we can't run the pact tests.

PS D:\workspace\umi3> yarn test
yarn run v1.22.11
$ umi-test
 FAIL  tests/pact.test.js
  ● Test suite failed to run

    TypeError: createColors is not a function

      1 | import { string} from "@pact-foundation/pact/src/dsl/matchers";
    > 2 | const { MatchersV3} = require('@pact-foundation/pact');
        |                       ^
      3 | const { atLeastOneLike} = MatchersV3;
      4 | export const data = {
      5 |     code:0,

      at Object.<anonymous> (node_modules/pino-pretty/lib/colors.js:19:25)
      at Object.<anonymous> (node_modules/pino-pretty/index.js:8:16)
      at Object.<anonymous> (node_modules/@pact-foundation/pact-core/src/logger/pino.ts:2:1)
      at Object.<anonymous> (node_modules/@pact-foundation/pact-core/src/logger/index.ts:2:1)
      at Object.<anonymous> (node_modules/@pact-foundation/pact-core/src/spawn/spawn.ts:5:1)
      at Object.<anonymous> (node_modules/@pact-foundation/pact-core/src/spawn/index.ts:1:1)
      at Object.<anonymous> (node_modules/@pact-foundation/pact-core/src/service.ts:11:1)
      at Object.<anonymous> (node_modules/@pact-foundation/pact-core/src/server.ts:6:1)
      at Object.<anonymous> (node_modules/@pact-foundation/pact-core/src/pact.ts:5:1)
      at Object.<anonymous> (node_modules/@pact-foundation/pact-core/src/index.ts:1:1)
      at Object.<anonymous> (node_modules/@pact-foundation/src/httpPact/index.ts:1:1)
      at Object.<anonymous> (node_modules/@pact-foundation/src/index.ts:25:1)
      at Object.<anonymous> (tests/overview.js:2:23)
      at Object.<anonymous> (tests/pact.test.js:3:1)

We've tried to use Pact JS v9.11.1, this version can run properly in Umi(v3.5), but the matching rules in PactV2 can't meet our needs. So we want to use PactV3 in our project. In addition, Pact JS v12.1.0 can run in Umi4, but it's difficult for us to upgrade the old project.

Steps to reproduce

https://github.com/Canoe-Silhouette/pact-umi

mefellows commented 8 months ago

Do you know why it works with Umi4 and not Umi3? If there is a way we can make it work for you, a PR would be nice.

It sounds like it has something to do with Umi. If it's using a transpiler that could be part of the challenge. The library in which that function is being called (pino and pino-pretty) use ES modules, so that could be it.

Whilst I appreciate the repro project (thank you!), because the issue appears to be with Umi (or at least, related to it) that would fall outside of the reasonable scope of support here - i.e. the details of why it works with one framework and not another are not something you could expect a maintainer of Pact to review.

Canoe-Silhouette commented 8 months ago

Do you know why it works with Umi4 and not Umi3? If there is a way we can make it work for you, a PR would be nice.

It sounds like it has something to do with Umi. If it's using a transpiler that could be part of the challenge. The library in which that function is being called (pino and pino-pretty) use ES modules, so that could be it.

Whilst I appreciate the repro project (thank you!), because the issue appears to be with Umi (or at least, related to it) that would fall outside of the reasonable scope of support here - i.e. the details of why it works with one framework and not another are not something you could expect a maintainer of Pact to review.

Thank you very much for your reply!!! I'm sorry I don't know the reason why it works with Umi4 and not Umi3. It seems like I need to ask this question in Umi. If I find something, I'll add it in the comments.

mefellows commented 1 month ago

Closing due to inactivity.