Sneha Singh
09/07/2022, 1:28 PM'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)
Matt (pactflow.io / pact-js / pact-go)
Sneha Singh
09/07/2022, 1:49 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)