whoever decided that using `import.meta` out-of-pocket should throw a SyntaxError (meaning you can’t really feature test for it in code) made a choice that I do not agree with
Also posted to Bluesky.
14 replies
does anyone else feel like feature testing as a front-end practice went out of style? (wrongly so — it’s still super valuable!)
@zachleat Which is a real shame, because in my long term experience developing for the web, it's only gotten easier. Modern tooling (e.g. vue test utils, happydom) has grown to be pretty capable, and integration (e.g. cypress, playwright) is better than ever.
@zachleat by feature testing, do you mean "does this environment support feature x?", as in early days of HTML5 where SVG as image src, media tags, and a great many other features were not reliably available in a browser (and would require polyfill)?
@ahoyboyhoy yeah, writing JavaScript to test for features, a la Modernizr: https://modernizr.com/
@zachleat The jump to APIs not being prepared for this sort of testing seemed to go by the wayside with the `type="module"`/`no-module` toggle. There was a glimmer of a hope we'd be given some form of successor to this...but, no.
@westbrook https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/supports_static#speculationrules seems like at least someone is thinking about it!
-
-
BTW, I’ve been following Zach’s work for years and these are the harshest words I ever seen from Zach 😬
oh no should I dial it back 😅