Getting the below error while running pact test in...
# general
s
Getting the below error while running pact test in the consumer side... i might be doing something really stupid but just can't figure out what...
Copy code
'use strict'

process.env.REACT_APP_ENGINE_SERVICE_URL = '<http://localhost:8992>'

import { expect } from 'chai'
import path from 'path'
import { Pact } from '@pact-foundation/pact'
import { fetchACEFields } from '../api/index'

describe('fetch ACE fields', () => {
  const port = 8992
  const objectType = 'dummy'
  const provider = new Pact({
    port: port,
    log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'),
    dir: path.resolve(process.cwd(), 'pacts'),
    spec: 2,
    consumer: 'webapp',
    provider: 'engine-service',
    pactfileWriteMode: 'merge',
  })

  const expectedBody = { status: true, data: [{ fullName: 'dummy' }] }

  before(() => provider.setup())

  after(() => provider.finalize())

  afterEach(() => provider.verify())

  describe('request to fetch fields', () => {
    before(done => {
      const interaction = {
        state: 'fetch ace fields',
        uponReceiving: 'a request to get all ace fields',
        withRequest: {
          method: 'GET' as const,
          path: `/ace-fields?object_type=${objectType}`,
          headers: {
            Accept: 'application/json',
          },
        },
        willRespondWith: {
          status: 200,
          headers: {
            'Content-Type': 'application/json',
          },
          body: expectedBody,
        },
      }
      provider.addInteraction(interaction).then(() => {
        done()
      })
    })

    it('verify it returns the correct response', async () => {
      const res = await fetchACEFields(objectType)
      expect(res).equal(expectedBody)
    })
  })
})

Error: 
   ReferenceError: navigator is not defined
    at Object.<anonymous> (/Users/snehasingh/Documents/webapp/node_modules/flags/node_modules/supports-color/browser.js:3:58)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Object.require.extensions.<computed> [as .js] (/Users/snehasingh/Documents/webapp/node_modules/ts-node/src/index.ts:1445:43)
m
It looks like something needs a web runtime but you're running in a node environment?
s
Okay, so I believe that my tsconfig.json file may be to blame since I'm attempting to run a front-end test with backend configuration. That could be it?? @Matt (pactflow.io / pact-js / pact-go)
m
could be
It doesn’t look like a Pact issue though. Remove all of the pact bits and see if you get the same issue - then you’ll know