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.59k stars 343 forks source link

TypeError: createColors is not a function (pino-pretty dependency) #1115

Closed brucem1976 closed 10 months ago

brucem1976 commented 10 months ago

Software versions

Issue Checklist

Please confirm the following:

Expected behaviour

react-scripts test --testTimeout 30000 pact.spec.js runs the consumer test adapted from the Getting Started tutorial

Actual behaviour

  FAIL  src/builder/pact/api.pact.spec.js
  ● Test suite failed to run

    TypeError: createColors is not a function

    > 1 | import { PactV3 } from '@pact-foundation/pact';
        | ^
      2 |
      3 | const mockProvider = new PactV3({
      4 |     logLevel: 'debug',

      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)

Steps to reproduce

import { PactV3 } from '@pact-foundation/pact';

const mockProvider = new PactV3({
    logLevel: 'debug',
    consumer: 'pactflow-platform-ui',
    // provider:  'pactflow-graphql'
});

describe('GQL Pact tests', () => {
 });

Relevant log files

As above - log level set to debug on the configuration of PactV3

mefellows commented 10 months ago

Are you able to please share a repro? It's possible it's a configuration of the build causing this issue, otherwise I'd expect to see it in the CI builds for this repo.

brucem1976 commented 10 months ago

@mefellows thanks so much for taking a look - https://github.com/brucem1976/pact-test with yarn install and npm run test:pact reproduces it - seems to be something related to the specific package.json contents

brucem1976 commented 10 months ago

@mefellows I think I tracked down the issue - react-scripts@3.4.1 far too old, seems to work fine with react-scripts@5.0.1

mefellows commented 10 months ago

Thanks for this! That makes some sense, it looks like we'll need to upgrade the examples.

I'll close this for now, as it looks like a compatibility issue with react scripts. If there is something we could be doing, we can re-open and address.