Ember.js V5 - Convert moduleFor to setupTest

This automation transforms from the older moduleFor* syntax of ember-qunit@2 to the newer setup*Test syntax.

Ember.js
jscodeshift
Estimated time saving
5 minutes/occurrence
Change mode
Autonomous
Applicability criteria

Ember.js version higher or equal to 2.4.

Made by
Robert Jackson
Robert Jackson

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod ember/5/convert-module-for-to-setup-test
copy CLI command icon

Codemod VS Code extension:

intalling vs code extension tooltip icon
vs code logo
Run in VS Code

Use/edit codemod in Codemod Studio:

intuita logo without text
Open in Codemod Studio

Description

This codemod transforms from the older moduleFor* syntax of ember-qunit@2 to the newer setup*Test syntax.

Example

Before:

import { moduleFor, test } from 'ember-qunit';

moduleFor('service:flash', 'Unit | Service | Flash', {
	unit: true,
});

test('should allow messages to be queued', function (assert) {
	let subject = this.subject();
});

After:

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Service | Flash', function (hooks) {
	setupTest(hooks);

	test('should allow messages to be queued', function (assert) {
		let subject = this.owner.lookup('service:flash');
	});
});