https://pact.io logo
#pact-js
Title
# pact-js
j

Jacek

05/27/2022, 9:40 AM
When I use pact-js on my corporate laptop pact file is not written to the disk although log says that it was written. I try to investigate the issue by checking sources but I get stuch in the chain of references. Can anyone give me some tips on how to investigate the issue?
m

Matt (pactflow.io / pact-js / pact-go)

05/27/2022, 9:45 AM
Strange! What does the consumer test setup look like?
j

Jacek

05/27/2022, 9:46 AM
Copy code
const path = require('path');
const Pact = require('@pact-foundation/pact').Pact;

global.port = 8080;
global.provider = new Pact({
    cors: true,
    port: global.port,
    log: path.resolve(process.cwd(), 'logs', 'pact.log'),
    loglevel: 'debug',
    dir: path.resolve(process.cwd(), 'pacts'),
    spec: 2,
    pactfileWriteMode: 'update',
    consumer: 'hero-consumer',
    provider: 'hero-provider',
    host: '127.0.0.1'
});
👍 1
The cases is very strange
the same code works on my private laptop but not on corporate
👍 1
m

Matt (pactflow.io / pact-js / pact-go)

05/27/2022, 9:46 AM
What does that log file contain? Can you please share the contents?
j

Jacek

05/27/2022, 9:56 AM
It is hard since access to my corporate laptop is restricted
what I can tell
is that on private laptop I have following entry
I, [2022-05-27T115408.407874 #28252] INFO -- : Updating pact for hero-provider at C:/projects/pact-js/pact-consumer/pacts/hero-consumer-hero-provider.json
and I don't see similar line on the other laptop
m

Matt (pactflow.io / pact-js / pact-go)

05/27/2022, 9:56 AM
Really? How locked down is your machine?
j

Jacek

05/27/2022, 9:57 AM
super locked down, I work for bank
m

Matt (pactflow.io / pact-js / pact-go)

05/27/2022, 9:57 AM
Like, you can install an nom package but you can't read a log file? How... Do you do any work?
😅 1
j

Jacek

05/27/2022, 9:57 AM
I can read
I can not use slack to send it to you
m

Matt (pactflow.io / pact-js / pact-go)

05/27/2022, 9:58 AM
Right. Well thats going to make debugging this hard. Logs and she'll output are going to be the primary means here
I'd you can find a way to share that here or as a GitHub issue that would help
(I'm on mobile btw so was just trying to quickly see if I could help)
j

Jacek

05/27/2022, 10:02 AM
How about this 😀
m

Matt (pactflow.io / pact-js / pact-go)

05/27/2022, 10:04 AM
And the terminal output? From that log I can't see any message saying the pact was written, so I think the test failed somewhere
j

Jacek

05/27/2022, 10:07 AM
Here you are
m

Matt (pactflow.io / pact-js / pact-go)

05/27/2022, 10:21 AM
Thanks. Nothing stands out to me now sorry. We'll need a code base to reproduce I think. Ideally, a GH issue is raised with an example project that reproduces the issue, alongside that log file and full terminal output so we can properly assess
j

Jacek

05/27/2022, 10:22 AM
that will be hard
but maybe we manage to do this
any clues for now
My investigation points to ruby server that handle /pact request
but I have no idea which part of code is responsible for writing file to disk
can you point me to such file?
or if I am wrong to the place where I can check on my own what is going on ?
m

Matt (pactflow.io / pact-js / pact-go)

05/27/2022, 10:25 AM
Not sure either sorry.
j

Jacek

05/27/2022, 10:46 AM
Thanks a lot for help
m

Matt (pactflow.io / pact-js / pact-go)

05/27/2022, 10:47 AM
np
sorry, I wish I could have spotted it for you!
j

Jacek

05/27/2022, 10:47 AM
we I will continue and try to rise the issue if I fail
👍 1