Git Product home page Git Product logo

Comments (3)

rixo avatar rixo commented on May 13, 2024

I've opened a new issue to suggest a more general feature that would also cover this use case.

@pjacekm I'm curious to why you want to introduce randomness, that is unpredictability, in the behaviour of the mock layer. For testing, that you want systematic and interpretable, you need the mocks to be predictable and deterministic. Are you using dyson in the context of some kind of stress test maybe?

Regarding this issue, I must disagree on the idea to use an arbitrary score system to express probability rather than a 0-1 ratio that is the universal standard in this respect.

from dyson.

webpro avatar webpro commented on May 13, 2024

Why not override the render function, you can do any kind of custom stuff in there:

module.exports = {
    path: '/path',
    render: function(req, res) {
        if(Math.random() > .5) {
            res.status(500).send('Random error');
        } else {
            res.set('Content-Type', 'application/json');
            res.send(200).send(res.body);
        }
    },
    template: {}
};

or

var request = require('request');

module.exports = {
    path: '/path',
    render: function(req, res) {
        if(Math.random() > .5) {
            res.status(500).send('Random error');
        } else {
            req.pipe(request('http://real.org/path')).pipe(res);
        }
    },
    template: {}
};

from dyson.

pjacekm avatar pjacekm commented on May 13, 2024

Thank you for your comments and suggestions. I was able to meet with our team, and we agreed on the fact that randomness would introduce unpredictability, which is not good. Closing the issue.

from dyson.

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.