pact-foundation/pact-js

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

Closed this issue · 4 comments

Software versions

  • OS: Mac OSX 13.5.1
  • Consumer Pact library: Pact JS v12.1.0
  • Node Version: 18.16.0

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

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

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.

@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

@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

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.