Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning for empty inputs #128

Closed
aeschli opened this issue Dec 7, 2020 · 4 comments
Closed

Warning for empty inputs #128

aeschli opened this issue Dec 7, 2020 · 4 comments

Comments

@aeschli
Copy link

aeschli commented Dec 7, 2020

There's now a message when an test input is not provided:

const missingAnswerMessage = `yeoman-test: question ${this.question.name} was asked but answer was not provided`;

Unfortunately for us it's a false positive for cases where we allow empty inputs:
https://github.com/microsoft/vscode-generator-code/blob/07ae7522143dd5d32c8d6402eb6274cb8393765e/generators/app/generate-language.js#L66

In our test this.question.type is input, and answer is ""

isSet = Boolean(answer);

results in isSet ===false

@mshima
Copy link
Member

mshima commented Dec 7, 2020

I don't think this is a bug.

You should pass { tmLanguageURL: '' } answer to yeoman-test in this case.
It should not print the warning due to

if (answer === undefined) {

As far as I remember inquirer never returns undefined if the prompt was shown.
So undefined is not a valid answer for that case.

@aeschli
Copy link
Author

aeschli commented Dec 8, 2020

You should pass { tmLanguageURL: '' } answer to yeoman-test in this case.

That's what I do. https://github.com/microsoft/vscode-generator-code/blob/07ae7522143dd5d32c8d6402eb6274cb8393765e/test/test.js#L444

answer = this.question.default

I probably should set the default to `` as well. But the message is misleading here as the answer was provided.

@mshima
Copy link
Member

mshima commented Dec 10, 2020

Ok. It’s a bug.

This assignment should be moved after the warning.

answer = this.question.default;

This condition should test if default is undefined too.

if (answer === undefined) {

@mshima
Copy link
Member

mshima commented Dec 22, 2020

Fixed in 4f466bb

@mshima mshima closed this as completed Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants