S
S
somevalue2019-12-03 20:12:19
Behavior-driven development
somevalue, 2019-12-03 20:12:19

Mocha, chai. How to run tests with prompt?

I master javascript and write tests for tasks in one, I get used to it.
Often in tasks you need to take data from the user, now the question is how to emulate the damn prompt?
now I have a function lying around in a file with tests

let defPrompt = prompt;
prompt = function(returnValue) {
  return returnValue;
}

How bad is this approach? And is there a good solution to this problem?
And if anyone has a link to testing lessons, I will also be grateful

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2019-12-03
@firedragon

Better use selenium or a headless browser.
https://pptr.dev/#?product=Puppeteer&version=v1.7....
https://habr.com/ru/company/oleg-bunin/blog/421137/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question