Comments (5)
@alastairs : I've added logDir
and logFileName
in v0.8.0, which I'm releasing today. This should make life easier for this use case.
In lieu of the ability to do nicer things like tell what the filename is, I'll close this out for now. Feel free to reopen if you have further issues.
from jest-pact.
I remember now - this is a bit annoying to fix nicely. I've just released v0.6.0, which includes any explicit port numbers in the log filename. Read on for some discussion and a workaround:
Ideally, each test file would have its own log file, making it easy to debug. Here are some candidates for naming them automatically, in order of preference:
- File names / test names: As far as I am aware, there isn't a nice way to determine the test file (or test name) from Jest.
- Port number of the mock server: Since the mock server writes the log file, and is told what the log file should be named at startup, we can only do this when we are specifying the port manually (I have just added a commit that does this)
- Add a sequential string: Jest runs each test file in a separate environment, so we can't do this without adding extra setup steps
- Add a random string: This would work, but I'm reluctant to do this before we automatically clear out the log directory on startup (which in itself is a bit annoying - to do this, I think we're going to have to require that users modify their jest config, which I was hoping to avoid/minimise)
Alternatively, you can work around this by specifying log: "pact/logs/whatever.log"
in your pactWith
options.
We can make that workaround less clunky, by allowing separate logDir
and logFileName
options for pactWith
.
What do you think?
from jest-pact.
@TimothyJones sorry for the delay responding, I moved onto a different team and so have put down my jest-pact work for a while. Thank you for the mitigation nonetheless. The file/test name would be ideal, of course, but my own research came to the same conclusion. Might there be a route to achieving this with, e.g., Object.prototype.constructor
?
Anyway, if you're open to changing the API in the way you describe, I'd suggest a logDir
option defaulting "pact/logs"
and logFileName
defaulting to the current generated filename if that's possible. It feels like this may be a relatively niche use case.
from jest-pact.
In evaluating Jest-Pact last week I discovered that, with multiple Pact tests executing with --runInBand, the log file is overwritten for each test in the run.
--runInBand
is for running in serial not parallel. I have several provider-consumer tests split into seperate pact tests in a single code base and each one generates its own log file. We use random ports on each instantiation and I run them in parallel for speed.
My config is below for a single test file, each file is for either a different consumer or provider
jestpact.pactWith(
{
consumer: "consumer-service",
provider: "provider-service",
dir: "src/pact/pacts",
},
And I get a separate log file for each pair in pact/logs
from jest-pact.
@YOU54F - you do get a separate log file for each pair of consumer / providers, yes.
However, if you have multiple spec files for the same consumer / provider pairs, then the logs get overwritten because the file name is generated from the consumer/provider names.
from jest-pact.
Related Issues (20)
- Pact tests fail with timeout on pact server setup HOT 2
- Add cors flag in PactOptions HOT 5
- Pact Verification Failed for multipart/form-data request HOT 2
- Support newer jest versions HOT 1
- future proofing `jest-pact` / `jasmine is undefined` HOT 2
- Race condition HOT 3
- Pact V3 support HOT 13
- Typescript Compiler failing with error TS2307 HOT 2
- jest-pact depends on Jasmine HOT 3
- Readme example - incorrect method name HOT 2
- Jest 27 support HOT 2
- "jest-pact": "0.9.0-beta.v3" not compatible "@pact-foundation/pact": "10.0.0-beta.45", HOT 3
- Error occurred in mock service: JSON::ParserError - 757: unexpected token at '"[{}]"' HOT 3
- Logging in jest-pact V3 Beta HOT 2
- move to pact-foundation org/scope HOT 6
- ci: move to GH actions
- pact-js 10.0.0 not compatible with jest-pact 0.9.0-beta.v3 HOT 2
- V3 DSL Feedback HOT 6
- Jest 29 support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-pact.