This codemod transform is to replace deprecated this.render() with render() from '@ember/test-helpers' package
npx ember-test-helpers-codemod this-render-migration path/of/files/ or/some**/*glob.js
# or
yarn global add ember-test-helpers-codemod
ember-test-helpers-codemod this-render-migration path/of/files/ or/some**/*glob.js
Input (basic.input.js):
import { click } from '@ember/test-helpers';
test('It handles switching selected option on click and fires onSelect event', async function(assert) {
this.onSelectMock = this.sandbox.stub();
await this.render(hbs`
<Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}>
</Common::TimeCommitmentSelector>
`);
})
Output (basic.input.js):
import { click, render } from '@ember/test-helpers';
test('It handles switching selected option on click and fires onSelect event', async function(assert) {
this.onSelectMock = this.sandbox.stub();
await render(hbs`
<Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}>
</Common::TimeCommitmentSelector>
`);
})
has-no-ember-test-helpers-import
Input (has-no-ember-test-helpers-import.input.js):
test('It handles switching selected option on click and fires onSelect event', async function(assert) {
this.onSelectMock = this.sandbox.stub();
await this.render(hbs`
<Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}>
</Common::TimeCommitmentSelector>
`);
})
Output (has-no-ember-test-helpers-import.input.js):
import { render } from '@ember/test-helpers';
test('It handles switching selected option on click and fires onSelect event', async function(assert) {
this.onSelectMock = this.sandbox.stub();
await render(hbs`
<Common::TimeCommitmentSelector @timeCommitmentOptions={{timeCommitmentOptionsMock}} @onSelect={{onSelectMock}}>
</Common::TimeCommitmentSelector>
`);
})