Skip to content

Logging inside a Command #2967

Answered by dubzzz
tjenkinson asked this question in Q&A
May 20, 2022 · 2 comments · 7 replies
Discussion options

You must be logged in to vote

Here is probably a first working version to make the logs visible by using fc.context but it suffers from the fact that it makes use of chain which does not shrink as well as map, filter or others:

const commandsArbitrary = fc.context().chain((context) =>
  fc.record({
    context,
    commands: fc.commands(
      [fc.nat(10 * 1000).map((someNumber) => myCommand(context, someNumber))],
      { size: 'medium' }
    ),
  })
);

fc.assert(
  fc.property(commandsArbitrary, ({ commands }) => {
    const real = {};
    const model = {};
    fc.modelRun(() => ({ model, real }), commands);
  })
);

Option 1

Another way to have the logs without this issue would be:

function myCommand(context, someN…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@tjenkinson
Comment options

@dubzzz
Comment options

Comment options

You must be logged in to vote
5 replies
@tjenkinson
Comment options

@tjenkinson
Comment options

@dubzzz
Comment options

@tjenkinson
Comment options

@tjenkinson
Comment options

Answer selected by tjenkinson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants