Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Coming from testGenerateCoupons, this line that waits for the batch to finish:
$this->getSession()->wait(180000, 'jQuery("#updateprogress").length === 0');
The error:
Drupal\Tests\commerce_promotion\FunctionalJavascript\CouponTest::testGenerateCoupons
Zumba\GastonJS\Exception\JavascriptError: One or more errors were raised in
the Javascript code on the page.
If you don't care about these errors, you can ignore them
by
setting js_errors: false in your Poltergeist configuration (see
documentation for details).
ReferenceError: Can't find variable: jQuery
Comment | File | Size | Author |
---|---|---|---|
#9 | 2952849-9.patch | 1.85 KB | Lendude |
| |||
#9 | interdiff-2952849-5-9.txt | 2.59 KB | Lendude |
#5 | 2952849-5.patch | 1.31 KB | Lendude |
Comments
Comment #2
bojanz CreditAttribution: bojanz at Centarro commentedAccording to lendude, we need to replace that line with $this->checkForMetaRefresh();
EDIT: Even though core uses it, it didn't work here. Also tried to replace the whole form submit with:
cause submitForm() calls checkForMetaRefresh() internally, but no change. The last HTML output I see is the batch itself, all next assertions fail.
Comment #3
mglamanPer
ReferenceError: Can't find variable: jQuery
is part of the problem invalid library definitions?Comment #4
lisastreeter CreditAttribution: lisastreeter at Centarro commentedSorry about the bad line in the coupon test code. FunctionalJavascript tests aren't currently working for me, so I can't try this. But maybe something like this could work:
$this->assertSession()->waitForElement('xpath', '//table/tbody/tr/td');
I see it being used in core FunctionalJavascript tests for testing Ajax. Not sure if it could work for batches.
Comment #5
LendudeI think (ok, know) we are lacking javascript + batch coverage in core, so there might not be a known way of handling this currently.
The simplest thing I see here, is just not making these tests javascript tests. They are not testing anything javascripty anyway. When converted to a browsertest, checkForMetaRefresh() works as advertised (well locally for me anyway).
Comment #7
mglamanComment #8
mglamanSeems solid, ran a bunch of custom tests.
Comment #9
LendudeBit of a clean up, removes an unused use and move the test to the Functional dir since it's no longer a javascript test.
Comment #11
bojanz CreditAttribution: bojanz at Centarro commentedThank you! Greatly appreciated.
Comment #13
juampynr CreditAttribution: juampynr at Lullabot commentedI experienced this kind of errors a few months ago with JavaScript tests. When I tried to do the same test with https://www.drupal.org/project/drupalextension, it worked consistently. Perhaps it's worth it to give that a go.