I am trying to test my entire cli dialogs using oclif and @oclif/test.
Prompts are made with inquirer.
Everything work fine, except the use of the .stdin( mock.
Feature extract looks like this:
...
const { sessionToken } = await inquirer.prompt([{
    type: 'password',
    name: 'sessionToken',
    message: 'Paste your token:',
    validate: token => 'Invalid token.',
}]);
...
Test code is:
  describe('with an invalid token', () => {
    fancy
      .stdout({ print: true })
      .command(['login', '-e', 'some@mail.com'])
      .stdin("bad_token")
      .it('should display invalid token', ctx => {
        process.stdin.setEncoding('utf8');
        process.stdin.once('data', data => {
          expect(data).toEquals("bad_token");
          expect(ctx.stdout).to.contain('Invalid token.');
        });
      });
  });
Actual: The test stop on "Paste your token:"
Expected: The test continues and displays "Invalid token.", like when manually testing.