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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to properly create object for testing? #482
Comments
I know it would be possible to fix the TS compilation on |
The literal reason you're seeing this is probably because In ~13 years (yikes) of practicing TDD on-and-off-again with mocks, I have become pretty fixed in my conviction that values (stuff with Second, I only fake dependencies that expose some kind of feature/business functions that do the work needed by the subject under test. That means I'd be more likely to replace a module that had a |
Hi Justin! Thanks for the guidance 馃槃 Do you think this API would make sense? If so I think that would unlock my use case, even if it's not the best practice 馃槄
In case that's not possible, I'll add a few questions on the rest of your answer 馃榾 Thanks! |
The impression I get is the above already works at runtime. If that seems okay, then perhaps it would be possible to change main/index.d.ts#L224-L232 to the following /**
* Create a fake object that is deep copy of the given object.
*
* @export
* @template T
* @param {Partial<T>} object Object to copy.
* @returns {DoubledObject<T>}
*/
export function object<T>(object: Partial<T>): DoubledObject<T>; Let me know what you think of that 馃榾 I can try it against my tests to see how it would work |
This might technically work, but I'm still fuzzy on the problem being solved here. As far as I can tell there are at least two issues:
I'm speculating a lot above, but am I off base here? Is |
Hi Justin and team! Hope you're all doing well 馃槃
Description
I would like to create a dummy object that satisfies types in my test and allows me to target different cases in my tests.
Issue
Say I have a type defined
And I have a function that depends on this type
I would like to satisfy the
Dog
type in my tests, and also assert a specific behavior.These are the two ways I imagined doing that
The part about name being a
Function
really confuses me 馃槄Let me know if I'm doing something wrong, or if there's something to address in the lib that I could help out with! Thanks y'all 馃榾
Environment
node -v
output: v16.14.0npm -v
(oryarn --version
) output: 8.3.1npm ls testdouble
(oryarn list testdouble
) version: 3.16.4Repl.it Notebook
https://replit.com/@JuanCaicedo1/TDTestObjects2
The text was updated successfully, but these errors were encountered: