Giter Site home page Giter Site logo

Comments (6)

NagRock avatar NagRock commented on May 21, 2024 1

Thanks for reporting, I will add this functionality soon. Currently you can use thenCall to capture and return value as workaround.

from ts-mockito.

NagRock avatar NagRock commented on May 21, 2024 1

Thanks for appreciation. As I wrote earlier I will add functionality to capture and stub mock with API that you tried to use: when(mock.smthn(anything())) .thenCapture(firstCaptor); .thenReturn("something");

from ts-mockito.

NagRock avatar NagRock commented on May 21, 2024 1

Should be fixed in 2.0 version. Please reopen if something is still wrong.

from ts-mockito.

bulldetektor avatar bulldetektor commented on May 21, 2024

Yes, that's what I ended up doing. Works fine, just not as fluent as I'd wish it was. But apart from that; ts-mockito is just lovely to work with :)

from ts-mockito.

alexleen avatar alexleen commented on May 21, 2024

Should be fixed in 2.0 version. Please reopen if something is still wrong.

What was the end result? I'm using 2.6.1 and can't seem to find a way to do this. What I would like is something similar to your comment above: when(mock.smthn(anything())).thenCapture(firstCaptor).thenReturn(firstCaptor);
i.e. I'd like to return whatever was passed as the argument.

from ts-mockito.

matitalatina avatar matitalatina commented on May 21, 2024

@alexleen I had your issue and I ended up using https://github.com/NagRock/ts-mockito/#custom-function
Just create a function that returns the first argument.

from ts-mockito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.