-
Notifications
You must be signed in to change notification settings - Fork 3
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
Log errors thrown when filling a form #217
Conversation
8878a88
to
fa490f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great start here! nice work
@@ -9,6 +9,7 @@ on: | |||
jobs: | |||
test: | |||
runs-on: ubuntu-latest | |||
timeout-minutes: 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one more minor tweak it seems
test/app-forms.spec.js
Outdated
@@ -276,4 +276,11 @@ describe('forms that have caused bugs', () => { | |||
const bikramDate = await harness.page.evaluate(() => window.$$('[data-itext-id="/pregnancy/summary/r_pregnancy_details:label"]').text()); | |||
expect(bikramDate).to.include('महिनावारी भएको अन्तिम मिति : १५ कारà¥'); | |||
}); | |||
it('should log error thrown during filling an app form', async () => { | |||
try { | |||
await harness.fillForm('mother_name', ['Jane"s']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test will pass even if an error is not thrown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/contact-forms.spec.js
Outdated
@@ -188,4 +188,11 @@ describe('contact forms', () => { | |||
reported_date: now.valueOf() | |||
}); | |||
}); | |||
it('should log error thrown during filling a contact form', async () => { | |||
try { | |||
await harness.fillContactCreateForm('household', ['Peter"s']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
test/contact-forms.spec.js
Outdated
@@ -188,4 +188,11 @@ describe('contact forms', () => { | |||
reported_date: now.valueOf() | |||
}); | |||
}); | |||
it('should log error thrown during filling a contact form', async () => { | |||
try { | |||
await harness.fillContactCreateForm('household', ['Peter"s']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like that you re-used an existing form here. is that not possible for the app-forms test? less to maintain if we don't add a new form
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not possible for 2 reasons.
- When attempting to use the same form for the app-forms test, an error occurs because it is located in the contact forms folder rather than the app forms folder.
- Currently, none of the existing app forms are suitable for testing this particular scenario.
@kennsippell
e80e6f7
to
fa27e99
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice progress.
package.json
Outdated
@@ -12,6 +12,7 @@ | |||
"travis": "npm run build && npm run eslint && npm test" | |||
}, | |||
"dependencies": { | |||
"chai-as-promised": "^7.1.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a devDependency not a dependency since it is not required
https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file
const fillResult = await this.page.evaluate(async innerAnswer => await window.formFiller.fillAppForm(innerAnswer), answers); | ||
const fillResult = await this.page.evaluate(async innerAnswer => { | ||
try { | ||
return await window.formFiller.fillAppForm(innerAnswer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the late feedback on this one: but i'm a little unsure on the value we are adding here... why catch an exception to just rethrow it? what problem are we solving?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't catch the exception, we see a confusing error in the stack trace like
Error: Evaluation failed: FormLogicError
at ExecutionContext._evaluateInternal (node_modules/puppeteer-core/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at process._tickCallback (internal/process/next_tick.js:68:7)
When we catch and rethrow, the error in the stack trace makes more sense for the user like
Error: Evaluation failed: Error: Error encountered while filling form: FormLogicError: Could not evaluate: concat(../mother_name, ' baby'), message: Failed to execute 'evaluate' on 'Document': The string 'concat("Jane"s", " baby")' is not a valid XPath expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can your test also make an assertion about not just the boilerplate you're adding but also the more descriptive error message like 'error.includes('mother_name')`?
|
The error does not exist in 3.x, only 2.x |
Please run |
This PR ensures that errors thrown during filling a form a displayed in the terminal in a readable format.