This codemod is to migrate deprecated package ember-test-helpers to package @ember/test-helpers
npx ember-test-helpers-codemod ember-test-helper-api-migration path/of/files/ or/some**/*glob.js
# or
yarn global add ember-test-helpers-codemod
ember-test-helpers-codemod ember-test-helper-api-migration path/of/files/ or/some**/*glob.js
- basic
- do-not-have-@ember-test-helpers-import
- do-not-have-ember-test-helpers-import
- test-context-specifier
Input (basic.input.js):
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import { setResolver } from 'ember-test-helpers';
setResolver(engineResolverFor('shared-components'));
setApplication(Application.create(config.APP));
preloadAssets(manifest).then(start);Output (basic.output.js):
import { setApplication, setResolver } from '@ember/test-helpers';
import { start } from 'ember-qunit';
setResolver(engineResolverFor('shared-components'));
setApplication(Application.create(config.APP));
preloadAssets(manifest).then(start);do-not-have-@ember-test-helpers-import
Input ([email protected]):
import { start } from 'ember-qunit';
import { setResolver } from 'ember-test-helpers';
setResolver(engineResolverFor('shared-components'));
setApplication(Application.create(config.APP));
preloadAssets(manifest).then(start); Output ([email protected]):
import { setResolver } from '@ember/test-helpers';
import { start } from 'ember-qunit';
setResolver(engineResolverFor('shared-components'));
setApplication(Application.create(config.APP));
preloadAssets(manifest).then(start); do-not-have-ember-test-helpers-import
Input (do-not-have-ember-test-helpers-import.input.js):
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
integration: true
});Output (do-not-have-ember-test-helpers-import.output.js):
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
integration: true
});Input (test-context-specifier.input.js):
import { click } from '@ember/test-helpers';
import { TestContext } from 'ember-test-helpers';
import { setupRenderingTest } from 'ember-qunit';
import { module, test } from 'qunit';
module(
'Integration | Component | c-pages/recommendations/collections/detail/collection-detail-card-list',
function (hooks) {
setupRenderingTest(hooks);
/** @type {TestContext['setProperties']} */
let setProperties;
hooks.beforeEach(function () {
setProperties = this.setProperties;
this.owner.register(
'service:lls-content-library@configuration',
ConfigurationStub
);
});
test('it renders detail view', async function (assert) {
await renderComponent({
learningCollectionItems,
locale,
isEditable: false
});
assert
.dom(SELECTORS.DROPDOWN_BUTTON)
.doesNotExist(
'It does not render dropdown button when `isEditable` is falsey'
);
});
}
);Output (test-context-specifier.output.js):
import { click, TestContext } from '@ember/test-helpers';
import { setupRenderingTest } from 'ember-qunit';
import { module, test } from 'qunit';
module(
'Integration | Component | c-pages/recommendations/collections/detail/collection-detail-card-list',
function (hooks) {
setupRenderingTest(hooks);
/** @type {TestContext['setProperties']} */
let setProperties;
hooks.beforeEach(function () {
setProperties = this.setProperties;
this.owner.register(
'service:lls-content-library@configuration',
ConfigurationStub
);
});
test('it renders detail view', async function (assert) {
await renderComponent({
learningCollectionItems,
locale,
isEditable: false
});
assert
.dom(SELECTORS.DROPDOWN_BUTTON)
.doesNotExist(
'It does not render dropdown button when `isEditable` is falsey'
);
});
}
);