As discussed in #1687, also mentioned in #1650
- Running the tests in a browser using
npx serve works without problems
- Running in headless mode with
npm run test though, raises 4 errors related to hx-boost
Adding logs to htmx, I found out the following:
Take this test for example, in hx-boost/handles basic anchor properly
var div = make('<div hx-target="this" hx-boost="true"><a id="a1" href="/test">Foo</a></div>');
Logs:
Boost HTMLAnchorElement
href resolves to file:///E:/test
raw attribute : /test
should swap ? false
Response Status Error Code 404 from file:///E:/test
So the test is failing here because the request fails: it doesn't call the mocked server's endpoint, tries to access a file URL instead, thus no swapping occurs
So it turns out that the /test URL, which is meant to be caught by the mocked server, resolves to a local file URL instead
I've noticed a line in htmx core (in function boostElement) about that:
path = elt.href; // DOM property gives the fully resolved href of a relative link
Replacing the current .href property access by getRawAttribute(elt, "href"), gets all tests to pass.
There's a single test failing, but it's explicitly checking href against the URL, so it's normal that it fails here, given that href's value is the issue
@alexpetros suggested using git blame to find out what was the initial issue that led to use the href property access instead of getting the raw attribute value. I'm going to try that and update this issue with what I find out.
As discussed in #1687, also mentioned in #1650
npx serveworks without problemsnpm run testthough, raises 4 errors related to hx-boostAdding logs to htmx, I found out the following:
Take this test for example, in
hx-boost/handles basic anchor properlyLogs:
So the test is failing here because the request fails: it doesn't call the mocked server's endpoint, tries to access a file URL instead, thus no swapping occurs
So it turns out that the
/testURL, which is meant to be caught by the mocked server, resolves to a local file URL insteadI've noticed a line in htmx core (in
function boostElement) about that:Replacing the current
.hrefproperty access bygetRawAttribute(elt, "href"), gets all tests to pass.There's a single test failing, but it's explicitly checking href against the URL, so it's normal that it fails here, given that href's value is the issue
@alexpetros suggested using git blame to find out what was the initial issue that led to use the
hrefproperty access instead of getting the raw attribute value. I'm going to try that and update this issue with what I find out.