Giter Club home page Giter Club logo

mock-inquirer's People

Contributors

andreasbomholtz avatar ron537 avatar simonepri avatar yibn2008 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mock-inquirer's Issues

Doesn't work with Jest (prompt is not overwriten)

Hello,

There is an issue when mock-inquirer is running with Jest. In this case it doesn't work at all - the inquirer is not mocked. I'm not sure if I'm misuning mock-inquirer, or there is something specific to be done to make it working with Jest?

I created the smallest possible amount of reproducible code here:
reproducible-code.zip

If you run npm install and then start the only one test there with npm run test, you will see that inquirer is not mocked.

What am I doing wrong?

Prompt validators not running

Current behavior

Mocking answers returns the mocked data without running validations before

Expected behavior

mock-inquirer should run validators and throw error when mocked answer is not valid

Reproduction

const mockInquirer = require('mock-inquirer')
const inquirer = require('inquirer')
const co = require('co')

// start mock
co(function * () {
  let reset = mockInquirer([{
    number: 'hello'
  }, {}])

  let anwser = yield inquirer.prompt([{
    type: 'input',
    message: 'Enter number',
    name: 'number',
    validate: function(input) {
            if(/\d+/.test(input)) return true;
            return 'Invalid number entered';
    }
  }]);

  // print anwser:
  // { number: 'hello' }
  console.log(anwsers)

  // reset mock
  reset()
}).catch(err => {
  console.error(err)
})

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.