@@ -60,7 +60,7 @@ This addon will perform the following transformations suitable for integration t
6060If you want to run only selected transforms on your code, you can pick just the needed transform:
6161
6262``` bash
63- jscodeshift -t .. /ember-test-helpers-codemod/lib/transforms/integration/click.js tests/integration
63+ jscodeshift -t path/to /ember-test-helpers-codemod/lib/transforms/integration/click.js tests/integration
6464```
6565
6666### Acceptance tests
@@ -104,7 +104,24 @@ These transformations are available for tests based on `ember-native-dom-helpers
104104If you want to run only selected transforms on your code, you can pick just the needed transform:
105105
106106``` bash
107- jscodeshift -t .. /ember-test-helpers-codemod/lib/transforms/native-dom/find.js tests/integration
107+ jscodeshift -t path/to /ember-test-helpers-codemod/lib/transforms/native-dom/find.js tests/integration
108108```
109109
110+ ### Replace find/findAll
110111
112+ By default this codemod will use the ` find() ` and ` findAll() ` helpers from ` @ember/test-helpers ` where required.
113+ If you want to use the native query functions ` this.element.querySelector() ` / ` this.element.querySelectorAll() ` instead,
114+ you can use the ` find.js ` transform after you have run the other transformations:
115+
116+ ``` bash
117+ jscodeshift -t path/to/ember-test-helpers-codemod/lib/transforms/find.js tests
118+ ```
119+
120+ | Before | After | Transform |
121+ | ----------------------| -----------------------------------------| ----------------|
122+ | ` find('.foo') ` | ` this.element.querySelector('.foo') ` | ` find.js ` |
123+ | ` findAll('.foo') ` | ` this.element.querySelectorAll('.foo') ` | ` find.js ` |
124+
125+ Note that this will require all instances of ` find ` /` findAll ` to have the correct ` this ` context, otherwise you will run
126+ into ` Cannot read property 'querySelector' of undefined ` exceptions, as ` this.element ` will not be defined. This can
127+ happen outside of the main ` test ` function, for example inside of custom test helper functions.
0 commit comments