Skip to content

Commit

Permalink
Use new test data. Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
inikulin committed Jul 7, 2016
1 parent ed00b42 commit d3c163b
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 209 deletions.
13 changes: 13 additions & 0 deletions .publishrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"validations": {
"vulnerableDependencies": true,
"uncommittedChanges": true,
"untrackedFiles": true,
"sensitiveData": true,
"branch": "master",
"gitTag": true
},
"confirm": true,
"publishTag": "latest",
"prePublishScript": "npm test"
}
15 changes: 5 additions & 10 deletions generators/app/templates/Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var eslint = require('gulp-eslint');
var babel = require('gulp-babel');
var mocha = require('gulp-mocha');
var del = require('del');
var publish = require('publish-please');

gulp.task('clean', function (cb) {
del('lib', cb);
Expand Down Expand Up @@ -39,20 +38,16 @@ gulp.task('test', ['build'], function () {
});

gulp.task('preview', ['build'], function () {
var pluginTestingUtils = require('testcafe').pluginTestingUtils;
var pluginFactory = require('./lib');
var testCalls = require('./test/data/test-calls');
var plugin = pluginTestingUtils.buildReporterPlugin(pluginFactory);
var buildReporterPlugin = require('testcafe').embeddingUtils.buildReporterPlugin;
var pluginFactory = require('./lib');
var reporterTestCalls = require('./test/utils/reporter-test-calls');
var plugin = buildReporterPlugin(pluginFactory);

console.log();

testCalls.forEach(function (call) {
reporterTestCalls.forEach(function (call) {
plugin[call.method].apply(plugin, call.args);
});

process.exit(0);
});

gulp.task('publish', ['test'], function () {
return publish();
});
8 changes: 6 additions & 2 deletions generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"lib"
],
"scripts": {
"test": "gulp test"
"test": "gulp test",
"publish-please": "publish-please",
"prepublish": "publish-please guard"
},
"keywords": [
"testcafe",
Expand All @@ -23,14 +25,16 @@
"license": "MIT",
"devDependencies": {
"babel-eslint": "^4.0.10",
"callsite-record": "^3.2.0",
"del": "^1.2.0",
"gulp": "^3.9.0",
"gulp-babel": "^5.2.1",
"gulp-eslint": "^1.1.1",
"gulp-mocha": "^2.2.0",
"normalize-newline": "^1.0.2",
"publish-please": "^1.0.1",
"publish-please": "^2.1.4",
"read-file-relative": "^1.2.0",
"testcafe": "0.0.7-alpha"
"testcafe": "^0.0.21"
}
}
151 changes: 0 additions & 151 deletions generators/app/templates/test/data/test-calls.js

This file was deleted.

47 changes: 4 additions & 43 deletions generators/app/templates/test/test.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,7 @@
var assert = require('assert');
var normalizeNewline = require('normalize-newline');
var read = require('read-file-relative').readSync;
var pluginTestingUtils = require('testcafe').pluginTestingUtils;
var pluginFactory = require('../lib');
var testCalls = require('./data/test-calls');

function createReport (withColors) {
var outStream = {
data: '',

write: function (text) {
this.data += text;
}
};

var plugin = pluginTestingUtils.buildReporterPlugin(pluginFactory, outStream);

plugin.chalk.enabled = !plugin.noColors && withColors;
plugin.symbols = { ok: '✓', err: '✖' };

// NOTE: disable errors coloring if we don't have custom
// error decorator. Default error colors may be prone to changing.
if (plugin.chalk.enabled && !pluginFactory().createErrorDecorator) {
var origFormatError = plugin.formatError;

plugin.formatError = function () {
plugin.chalk.enabled = false;

var result = origFormatError.apply(plugin, arguments);

plugin.chalk.enabled = true;

return result;
};
}

testCalls.forEach(function (call) {
plugin[call.method].apply(plugin, call.args);
});

return outStream.data;
}
var assert = require('assert');
var normalizeNewline = require('normalize-newline');
var read = require('read-file-relative').readSync;
var createReport = require('./utils/create-report');

it('Should produce report with colors', function () {
var report = createReport(true);
Expand Down
41 changes: 41 additions & 0 deletions generators/app/templates/test/utils/create-report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var buildReporterPlugin = require('testcafe').embeddingUtils.buildReporterPlugin;
var pluginFactory = require('../../lib');
var reporterTestCalls = require('./reporter-test-calls');

module.exports = function createReport (withColors) {
var outStream = {
data: '',

write: function (text) {
this.data += text;
}
};

var plugin = buildReporterPlugin(pluginFactory, outStream);

plugin.chalk.enabled = !plugin.noColors && withColors;
plugin.symbols = { ok: '✓', err: '✖' };

// NOTE: disable errors coloring if we don't have custom
// error decorator. Default error colors may be prone to changing.
if (plugin.chalk.enabled && !pluginFactory().createErrorDecorator) {
var origFormatError = plugin.formatError;

plugin.formatError = function () {
plugin.chalk.enabled = false;

var result = origFormatError.apply(plugin, arguments);

plugin.chalk.enabled = true;

return result;
};
}

reporterTestCalls.forEach(function (call) {
plugin[call.method].apply(plugin, call.args);
});

// NOTE: mock stack entries
return outStream.data.replace(/\s*?\(.+?:\d+:\d+\)/g, ' (some-file:1:1)');
};
Loading

0 comments on commit d3c163b

Please sign in to comment.