question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom examples for property(..., context(), ...)?

See original GitHub issue

💬 Question and Help

It is unclear to me how to provide a custom example for the following:

fc.assert(
  fc.property(fc.string(), fc.context(), (str, ctx) => /* ... */),
  { examples: [["x", /* what here? */]] }
);

context() seems to instantiate an class which is not exported. I would prefer not to make my own implementation of ContextValue.

It would be the most convenient not to have to include a value corresponding to the context in the examples at all – maybe the arbitraries provided to the property call could be used if there are more of them than elements in the example tuples – but any solution that gets this to work is good enough. Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dubzzzcommented, May 4, 2021

Hello,

There is today no way to build partial or incomplete examples. A proposal to do so was suggested in the issue https://github.com/dubzzz/fast-check/issues/710#issuecomment-657102743 but for the moment it has not been implemented.

Regarding ContextValue for the moment, the implementation is not exposed to the user. I should probably either expose the class or add something like fc.contextFor() as I did for fc.scheduler() (see fc.schedulerFor()).

Given what has been released so far, the only trick I’d have is:

const buildContext = () => fc.sample(fc.context(), {numRuns:1})[0];
fc.assert(
  fc.property(fc.string(), fc.context(), (str, ctx) => /* ... */),
  { examples: [["x", buildContext()]] }
);

Not perfect but it should work well.

0reactions
tskjcommented, Dec 8, 2022

Sure thing!

I have submitted a proper bug report here, and also two suggestions for improving the docs if fixing the bug will never be on the roadmap here and here!

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Complete Guide to Custom Properties | CSS-Tricks
A custom property is most commonly thought of as a variable in CSS. ... Here are some basic examples that you'd expect to...
Read more >
Using CSS custom properties (variables) - MDN Web Docs
For example, the same color might be used in hundreds of different places, requiring global search and replace if that color needs to...
Read more >
Context menu for the custom properties in the C# PropertyGrid
Context menu for the custom properties in the C# PropertyGrid, allowing the user to reset the properties, the same way as in Visual...
Read more >
Bind Custom Property to Context - Stack Overflow
I like to bind a custom property (owner Window) to my datacontext. How to do these in xaml. I can not access on...
Read more >
Custom Context Menu Items - MicroStrategy
For example, whether to show the Date Labels on your visualization, ... Most menu items can bind with custom properties. ... onClick: function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found