data-test selectors are not stripped from colocated component templates
See original GitHub issueI noticed that not all data-test-*
selectors are being stripped from my production build. It seems that the commonality among those that remain is that the selectors that remain are all from component templates that are using the new colocated component file structure (i.e. having the component.hbs
file inside the app/component
directory alongside the corresponding component.js
file.
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (14 by maintainers)
Top Results From Across the Web
data-test selectors are not stripped from colocated component ...
It seems that the commonality among those that remain is that the selectors that remain are all from component templates that are using...
Read more >ember-test-selectors | Yarn - Package Manager
Removes attributes starting with data-test- from HTML tags and component/helper invocations in your templates for production builds.
Read more >ember-test-selectors - UNPKG
The CDN for ember-test-selectors. ... Other than that, no further breaking ... stripping works for inline template compilation and co-located components ...
Read more >New features for ember-test-selectors | Mainmatter - Simplabs
Tobias Bieniek announces new features in ember-test-selectors such as automatic binding of data-test-* properties and how these are stripped ...
Read more >v2 Addon Format (Embroider Compatibility) - Ember RFCs
Own Javascript: Co-located Component Templates. Modules in Own Javascript get no automatic component template co-location.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ZOMG, I spent a while debugging this 😭, and have a fix. Basically, what is happen (in order) is:
included
hook runs, and does: 1a. gather all AST plugins registered ashtmlbars-ast-plugin
in the registry 1b. add babel-plugin-htmlbars-inline-precompile to the babel configurationincluded
hook runs, and registers a newhtmlbars-ast-plugin
Specifically, the babel config is already locked down before
ember-test-selectors
. I do not think this issue is related to colocation at all (I doubt this ever ran against inline compiled templates), but the fact that colocation happens to desugar into using inline templates (e.g.hbs
) makes it much more common to care.The simplest fix, is to ensure that
ember-test-selectors
runs beforeember-cli-htmlbars
, and I’ve confirmed that works when manually tweaked into void-mAlex/test-selector-repro. See https://github.com/simplabs/ember-test-selectors/pull/521.not from my side. I think it’s a bug in the build pipeline somewhere, but not related to the implementation here.