-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option for enhanced debugging output during testing #561
base: master
Are you sure you want to change the base?
Conversation
|
ef79275
to
b64f4bb
Compare
ab7434a
to
ede2052
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for late review, I am excited to try this out. It is a very cool PR, and I realize that it needs dependencies added for it to work, since mappersmith/test
is not a separate package, it's all part of a single published package. So testing suffers from productions requirement of being zero dependency, and adding deps would make production build "look bad" since it is technically not zero dep any more...
But about optionalDependencies
, idk how that would work. It would install them anyway unless you did --no-optional
so it doesn't help much, even if we update install instructions. But even though, I still do not think this option helps a user to A) having it during development but B) not having it in a production build (as it is today) since they only have one lockfile.
If we really want to keep things zero dependency we have to go for a monorepo and publish a separate package for @mappersmith/test
for instance, which is a large effort and beyond the scope here. But in that future state we can have @mappersmith/forge
as the production part without dependencies. For now, I think we have to bite the bullet and just allow dependencies.
"dependencies": { | ||
"diff": "^7.0.0", | ||
"tty-table": "^4.2.3" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would this work?
https://docs.npmjs.com/cli/v7/configuring-npm/package-json#peerdependenciesmeta
"dependencies": { | |
"diff": "^7.0.0", | |
"tty-table": "^4.2.3" | |
} | |
"peerDependencies": { | |
"diff": "^7.0.0", | |
"tty-table": "^4.2.3" | |
}, | |
"peerDependenciesMeta": { | |
"diff": { | |
"optional": true | |
}, | |
"tty-table": { | |
"optional": true | |
} | |
} |
I guess since this PR aims to be in "experimentation" mode we could consider have it like this for now even though it is a wonkier install experience for the user.
I am not proposing this change, just asking if you have considered it and how you feel about it.
function MockRequest(id, props) { | ||
this.id = id | ||
|
||
this.mockName = props.mockName ? props.mockName : this.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe interpolate a name from the id, something like:
this.mockName = props.mockName ? props.mockName : this.id | |
this.mockName = props.mockName ? props.mockName : `Mock#${this.id}` |
enhancedDebugging: false, | ||
} | ||
) => { | ||
options.enhancedDebugging = enhancedDebugging | ||
originalGateway = configs.gateway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you think if there is a way to "globally" enable enhancedDebugging
via configs
(GlobalConfigs
) object? Would be very nice if a user could do perhaps something like
export const configs: GlobalConfigs = {
test: {
experimentalEnhancedMockResponseOutputFormat: true
}
}
@@ -11,3 +11,4 @@ tsconfig.tsbuildinfo | |||
tmp/ | |||
dist/ | |||
.vscode/ | |||
.yarn/cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, we are weird, but revert this. And check in the changes of yarn/cache
folder :)
Otherwise CI breaks, it wants the cached entries (faster CI).
@@ -0,0 +1,285 @@ | |||
import { sortedUrl, toSortedQueryString } from '../mocks/mock-utils' | |||
import { Request } from '../request' | |||
import colors from '@colors/colors' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dependency is missing, and the test suite fails without it on CI. For you it might work due to a transitive dependency from Karma.
UPDATE:
Actually, this is not working for TSUP which wants to emit ESM output. You can reproduce with yarn tsup
.
I think that due to these packages are not ESM, it will be quite hard (dare I say impossible?) to get it to work... 😭
Are there any alternative ESM packages we can use instead?
No problem with later review. Been equally busy on my end tbh. It was mostly this dependency discussion I wanted to raise before moving forward with the PR. Another alternative would ofc. to internalize all the dependent code in a neat place under /test while we are evaluating this? I could try doing that if you think it’s a good idea. There is a great cleanliness of having zero deps and I really do not want to ruin that either. |
As you can see, I tried my best to get this branch working in #563 But even if the mappersmith PR looks green, the smoke test fails when trying to use This means we have to solve this problem before merging. I can try to get it working in it's current state, but it might be best if you find ESM compatible options and relieve me from the stress and pain of trying to cover up of the anti pattern of using non-ESM modules in a library whose goal it is to emit ESM. |
@olofd and Jens and Vaibav, Feel free to join mappersmith discord server to get quicker discussion and a way to ping each other https://discord.gg/TfAk625Z |
Hello fellow maintainers and old friends (@klippx @tulios), hope all is well!
This PR is a joint effort between me, @J3MPA and @vaibhavar
One thing that we have struggled with a lot with in mappersmith is to know why your installed mock does not match
an outgoing request. This PR aims to change that by giving the developer much more detailed information on why their mock does not match the request. (See attached screenshot).
It should only affect test-code.
We have put the behaviour behind a new flag that you can pass to
install({ enhancedDebugging: true })
My thinking is that we might want to dog food it a bit before it would replace the existing behaviour.
Unfortunately the PR includes two dependencies that you might object to, but let's have a discussion on how we can solve that. Should we add them as
optionalDependencies
and give instructions ifenhancedDebugging
is enabled?Let us know what you think.
Olof Dahlbom