Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Allow testem to run specific test module #2532

Merged
merged 3 commits into from
Nov 19, 2014
Merged

Feature: Allow testem to run specific test module #2532

merged 3 commits into from
Nov 19, 2014

Conversation

JarrodCTaylor
Copy link
Contributor

Adds --module command line option to ember test and ember test --server. The --module option tells QUnit to run the specified test module.

Example usage ember test --module "Module Name Here"

Adds `--module` command line option to `ember test` and `ember test
--server`. The `--module` option tells QUnit to run the specified test
module.

Example usage `ember test --module "Module Name Here"`
@toranb
Copy link
Contributor

toranb commented Nov 19, 2014

Nice work on this Jarrod! +1


var tmpPath = this.quickTemp.makeOrRemake(this, '-customConfigFile');
var customPath = path.join(tmpPath, 'testem.json');
var originalContents = JSON.parse(fs.readFileSync(options.configFile, { encoding: 'utf8' }));

originalContents['test_page'] = originalContents['test_page'] + '?filter=' + options.filter;
if (options.filter) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to build up te query string. You should be able to use BOTH filter and module.

@rwjblue
Copy link
Member

rwjblue commented Nov 19, 2014

This looks great!

Needs a slight tweak to allow both filter and module at the same time. Along with a test confirming.

@joostdevries
Copy link
Member

👍

3 similar comments
@saygun
Copy link

saygun commented Nov 19, 2014

👍

@mattjmorrison
Copy link
Contributor

👍

@quaertym
Copy link
Contributor

👍

@JarrodCTaylor
Copy link
Contributor Author

I was unaware that the QUnite syntax allowed both filter and module at the same time. I will updated the PR.

This allows testing a specific module for all tests containing a given
string.

Example usage all tests in the `fooModule` containing the word `bar`
`ember test --module "fooModule" --filter "bar"`
@JarrodCTaylor
Copy link
Contributor Author

It now accepts both module and filter together or each individually.

If anyone has a more elegant way to implement this just let me know.

@JarrodCTaylor
Copy link
Contributor Author

Not sure what is up with the failing build for 0.10.18 Travis says 0.11 is green and 0.10.X passes locally.

@jakecraige
Copy link
Member

rerunning, looks like travis may have broke


var tmpPath = this.quickTemp.makeOrRemake(this, '-customConfigFile');
var customPath = path.join(tmpPath, 'testem.json');
var originalContents = JSON.parse(fs.readFileSync(options.configFile, { encoding: 'utf8' }));

originalContents['test_page'] = originalContents['test_page'] + '?filter=' + options.filter;
if (options.module && options.filter) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, something like:

var params = [];

if (options.module) {
  params.push('module=' + options.module);
}

if (options.filter) {
  params.push('filter=' + options.filter);
}

originalContents['test_page'] = originalContents['test_page'] + '?' + params.join('&');

@taddeimania
Copy link
Contributor

👍 thanks Jarrod

@JarrodCTaylor
Copy link
Contributor Author

@rwjblue I like it. Thanks for sticking with me on this one.

@stefanpenner stefanpenner added this to the 0.1.3 milestone Nov 19, 2014
rwjblue added a commit that referenced this pull request Nov 19, 2014
Feature: Allow testem to run specific test module
@rwjblue rwjblue merged commit dc2aef6 into ember-cli:master Nov 19, 2014
@rwjblue
Copy link
Member

rwjblue commented Nov 19, 2014

Awesome! Thank you!

@rchrd2
Copy link

rchrd2 commented Mar 5, 2015

Trying to use this to run a test I am writing. Can't figure out how to call it properly though. Could someone please give a quick concrete example?

I have a test file "/tests/unit/components/image-upload-test.js".
I tried various calls such as the following, but none of them seem to have run the test.

 ember test --module tests/unit/components/image-upload-test.js
 ember test --module tests/unit/components/image-upload-test
 ember test --module unit/components/image-upload-test.js
 ember test --module unit/components/image-upload-test
 ember test --module components/image-upload-test.js
 ember test --module components/image-upload-test

Thank you.

@rchrd2
Copy link

rchrd2 commented Mar 5, 2015

Looks like I figured it out. I had to run the following command.

ember test --module ImageUploadComponent

@rwjblue
Copy link
Member

rwjblue commented Mar 5, 2015

@rchrd2 - --module here refers to what QUnit considers the module, not the actual ES6 module on disk. I agree that it is confusing.

@heyjinkim
Copy link

😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.