[CLJS-2758] Improving tracability of cljs.spec.test instrumented function call conform errors Created: 24/May/18 Updated: 19/Jun/18
|Labels:||bug, enhancement, spec|
|Attachments:||0001-Change-target-to-default-which-indicates-a-browser.patch 0002-Use-location.hostname-for-port-less-hostname.patch 0003-Infer-UA-product-for-error-parsing-from-error-stack-.patch 0004-Correct-namespace-for-locating-caller-in-spec.test.patch|
Context: Use `cljs.spec.test.alpha/instrument` to instrument `fdef`-ed functions. Call one of said functions with data that fails the argument spec. The thrown exception currently does not provide a lot of context:
1. The exception message contains "missing filename" and "missing line number" - ideally those should contain the file and line number of the offending call
The result is that failure to conform to an fdef argument spec leaves no trace back to the call - it only tells you which function's spec was not satiesfied.
I've started to investigate, and found a few glitches, but I do not have a complete suggestion. I'm offering my patches so far, hoping to get some input on whether or not it would be desirable for me to continue investigating.
Here's what I found so far:
1. `target` was assumed to be `"browser"`, while it is documented to be `"default"` in browsers. Fixed in first patch
With these patches, the caller is set reliably, although it doesn't seem to reflect the originating call-site. Also, the thrown exception still lacks file name and line number. I'd be happy to continue investigating, and add some tests if you are interested in eventually accepting these patches.
As a side-note: It seems to me that the function that infers user agent from stack trace more appropriately belongs in stacktrace.cljs, and I feel strongly that this should be the default behavior when no `user-agent-product` is provided (instead of the current: returning the stack trace string unmodified). I'll be happy to fix this as well, and add some tests, if the interest is there. Note that the current approach allows Safari to go down the Firefox route, which works like a charm.
Lastly: sorry if I put too many things in one place, I'll be happy to split up as instructed.
|Comment by David Nolen [ 15/Jun/18 3:52 PM ]|
Thanks! Have you submitted a CA?
|Comment by Christian Johansen [ 19/Jun/18 4:21 AM ]|
I sure have