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.61k stars 344 forks source link

All generated pact files are the same and contain all interactions #193

Closed cakeinpanic closed 6 years ago

cakeinpanic commented 6 years ago

Software versions

Expected behaviour

I create two providers with different provider and consumers

const pactA = new  PactWeb({provider:'A', consumer: 'A', port: '1234'})
const pactB = new  PactWeb({provider:'B', consumer: 'B', port: '1234'})
pactA.addInteraction(interactionA);
pactB.addInteraction(interactionB);

karma config

 pact: [{
            cors: true,
            port: 1234,
            dir: 'pact/pacts',
            spec: 2,
            logLevel: 'DEBUG',
            log: path.resolve(process.cwd(), 'pact', 'pact.log'),
            pactfileWriteMode: true
        }],

I expect that there would be two files A-A.json and B-B.json with different content

Actual behaviour

I have two files A-A.json and B-B.json with same content – each file includes all interactions

cakeinpanic commented 6 years ago

I have found this issue: https://github.com/pact-foundation/pact-js/issues/59

but it doesn't help When I specify

 pact: [
            {
                consumer: 'A',
                provider: 'A',
                cors: true,
                port: 1234,
                dir: 'pact/pacts',
                spec: 2,
                logLevel: 'DEBUG',
                log: path.resolve(process.cwd(), 'pact', 'pact.log'),
                pactfileWriteMode: true
            },
            {
                consumer: 'B',
                provider: 'B',
                cors: true,
                port: 4567,
                dir: 'pact/pacts',
                spec: 2,
                logLevel: 'DEBUG',
                log: path.resolve(process.cwd(), 'pact', 'pact.log'),
                pactfileWriteMode: true
            }
        ],

tests fail with Unable to connect to "http://127.0.0.1:1234/interactions"

cakeinpanic commented 6 years ago

As usual, on third try everything worked fine

There are really some strange caches hidden somewhere, I'm working with pact for a week and really often need to restart it on my local machine because of something strange. Once I even needed to restart machine because(I guess) some process was not killed and I instantly got error 'interaction with same state is registered already' and all that could help me(except restarting) - adding some random string to state in each interaction((

bethesque commented 6 years ago

and really often need to restart it on my local machine because of something strange

The mock service is very stateful (by necessity). It must be restarted at every test run. It is not designed to be a long running process.

bethesque commented 6 years ago

If it is not shutting down correctly between test runs, that is an issue that needs to be raised and addressed.