ember-codemods / ember-test-helpers-codemod

Codemod to transform your Ember tests to use @ember/test-helpers
MIT License
29 stars 14 forks source link

add transform to replace deprecated this.render() #43

Closed zhanwang626 closed 3 years ago

zhanwang626 commented 3 years ago

Description

add transform to replace deprecated this.render() with render() from '@ember/test-helpers' package. Example: From

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>
    `);
})

to

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>
    `);
})

Test

PASS transforms/find/test.js PASS transforms/native-dom/test.js PASS transforms/this-render-migration/test.js PASS transforms/acceptance/test.js PASS transforms/integration/test.js

Test Suites: 5 passed, 5 total Tests: 90 passed, 90 total Snapshots: 0 total Time: 3.301s, estimated 4s Ran all test suites matching /test/i.

simonihmig commented 3 years ago

https://github.com/ember-codemods/ember-test-helpers-codemod/releases/tag/v0.3.0