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

Hide passed tests by default. #3068

Merged
merged 2 commits into from
Jan 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion blueprints/app/files/testem.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"framework": "qunit",
"test_page": "tests/index.html",
"test_page": "tests/index.html?hidepassed",
"launch_in_ci": [
"PhantomJS"
],
Expand Down
7 changes: 5 additions & 2 deletions lib/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ module.exports = Command.extend({
var customPath = path.join(tmpPath, 'testem.json');
var originalContents = JSON.parse(fs.readFileSync(options.configFile, { encoding: 'utf8' }));

originalContents['test_page'] = originalContents['test_page'] + this.buildTestPageQueryString(options);
var containsQueryString = originalContents['test_page'].indexOf('?') > -1;
var testPageJoinChar = containsQueryString ? '&' : '?';

originalContents['test_page'] = originalContents['test_page'] + testPageJoinChar + this.buildTestPageQueryString(options);
fs.writeFileSync(customPath, JSON.stringify(originalContents));

return customPath;
Expand All @@ -68,7 +71,7 @@ module.exports = Command.extend({
params.push('filter=' + options.filter);
}

return params.length ? '?' + params.join('&') : '';
return params.join('&');
},

run: function(commandOptions) {
Expand Down
11 changes: 11 additions & 0 deletions tests/fixtures/tasks/testem-config/testem-with-query-string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"framework": "qunit",
"test_page": "tests/index.html?hidepassed",
"launch_in_ci": [
"PhantomJS"
],
"launch_in_dev": [
"PhantomJS",
"Chrome"
]
}
22 changes: 15 additions & 7 deletions tests/unit/commands/test-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('test command', function() {
var fixturePath;

beforeEach(function() {
fixturePath = path.join(__dirname, '..', '..', 'fixtures', 'tasks', 'default-testem-config');
fixturePath = path.join(__dirname, '..', '..', 'fixtures', 'tasks', 'testem-config');
command = new TestCommand(options);
runOptions = {
configFile: path.join(fixturePath, 'testem.json')
Expand Down Expand Up @@ -163,39 +163,47 @@ describe('test command', function() {
var newPath = command._generateCustomConfigFile(runOptions);
var contents = JSON.parse(fs.readFileSync(newPath, { encoding: 'utf8' }));

expect(contents['test_page'].indexOf('fooModule') > -1);
expect(contents['test_page'].indexOf('bar') > -1);
expect(contents['test_page']).to.be.equal('tests/index.html?module=fooModule&filter=bar');
});

it('when module and filter option is present uses buildTestPageQueryString for test_page queryString', function() {
runOptions.filter = 'bar';
command.buildTestPageQueryString = function(options) {
expect(options).to.deep.equal(runOptions);

return '?blah=zorz';
return 'blah=zorz';
};

var newPath = command._generateCustomConfigFile(runOptions);

var contents = JSON.parse(fs.readFileSync(newPath, { encoding: 'utf8' }));

expect(contents['test_page'].indexOf('?blah=zorz') > -1);
expect(contents['test_page']).to.be.equal('tests/index.html?blah=zorz');
});

it('new file returned contains the filter option value in test_page', function() {
runOptions.filter = 'foo';
var newPath = command._generateCustomConfigFile(runOptions);
var contents = JSON.parse(fs.readFileSync(newPath, { encoding: 'utf8' }));

expect(contents['test_page'].indexOf('foo') > -1);
expect(contents['test_page']).to.be.equal('tests/index.html?filter=foo');
});

it('adds with a `&` if query string contains `?` already', function() {
runOptions.filter = 'foo';
runOptions.configFile = path.join(fixturePath, 'testem-with-query-string.json');
var newPath = command._generateCustomConfigFile(runOptions);
var contents = JSON.parse(fs.readFileSync(newPath, { encoding: 'utf8' }));

expect(contents['test_page']).to.be.equal('tests/index.html?hidepassed&filter=foo');
});

it('new file returned contains the module option value in test_page', function() {
runOptions.module = 'fooModule';
var newPath = command._generateCustomConfigFile(runOptions);
var contents = JSON.parse(fs.readFileSync(newPath, { encoding: 'utf8' }));

expect(contents['test_page'].indexOf('fooModule') > -1);
expect(contents['test_page']).to.be.equal('tests/index.html?module=fooModule');
});
});
});