diff --git a/lib/displayutils.js b/lib/displayutils.js deleted file mode 100644 index 995ac1dc..00000000 --- a/lib/displayutils.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict'; - -var util = require('util'); - -// Method to format test results. -var strutils = require('./strutils'); - -function resultDisplay(id, prefix, result) { - - var parts = []; - if (prefix) { - parts.push(prefix); - } - if (result.name) { - parts.push(result.name.trim()); - } - - var line = parts.join(' - '); - return (result.skipped ? 'skip ' : (result.passed ? 'ok ' : 'not ok ')) + id + ' ' + line; -} - -function yamlDisplay(err, logs) { - var testLogs; - var failed = Object.keys(err || {}) - .filter(function(key) { - return key !== 'passed'; - }) - .map(function(key) { - return key + ': >\n' + strutils.indent(String(err[key])); - }); - if (logs) { - testLogs = ['Log: |'].concat(logs.map(function(log) {return strutils.indent(util.inspect(log));})); - } else { - testLogs = []; - } - return strutils.indent([ - '---', - strutils.indent(failed.concat(testLogs).join('\n')), - '...'].join('\n')); -} - -function resultString(id, prefix, result, quietLogs) { - var string = resultDisplay(id, prefix, result) + '\n'; - if (result.error || (!quietLogs && result.logs && result.logs.length)) { - string += yamlDisplay(result.error, result.logs) + '\n'; - } - return string; -} - -exports.resultString = resultString; diff --git a/lib/old-tap-reporter.js b/lib/old-tap-reporter.js deleted file mode 100644 index 73ddeb4e..00000000 --- a/lib/old-tap-reporter.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copied from https://github.com/testem/testem/blob/79e75d850942804e197d4bb676b9cbc5c4026b53/lib/reporters/tap_reporter.js -'use strict'; - -var displayutils = require('./displayutils'); - -function TapReporter(silent, out, config) { - this.out = out || process.stdout; - this.silent = silent; - this.quietLogs = !!config.get('tap_quiet_logs'); - this.stoppedOnError = null; - this.id = 1; - this.total = 0; - this.pass = 0; - this.skipped = 0; - this.results = []; - this.errors = []; - this.logs = []; -} -TapReporter.prototype = { - report: function(prefix, data) { - this.results.push({ - launcher: prefix, - result: data - }); - this.display(prefix, data); - this.total++; - if (data.skipped) { - this.skipped++; - } else if (data.passed) { - this.pass++; - } - }, - summaryDisplay: function() { - var lines = [ - '1..' + this.total, - '# tests ' + this.total, - '# pass ' + this.pass, - '# skip ' + this.skipped, - '# fail ' + (this.total - this.pass - this.skipped) - ]; - - if (this.pass + this.skipped === this.total) { - lines.push(''); - lines.push('# ok'); - } - return lines.join('\n'); - }, - display: function(prefix, result) { - if (this.silent) { - return; - } - this.out.write(displayutils.resultString(this.id++, prefix, result, this.quietLogs)); - }, - finish: function() { - if (this.silent) { - return; - } - this.out.write('\n' + this.summaryDisplay() + '\n'); - } -}; - -module.exports = TapReporter; diff --git a/lib/strutils.js b/lib/strutils.js deleted file mode 100644 index 85bb0233..00000000 --- a/lib/strutils.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -// String padding function adapted from -function pad(str, l, s, t) { - var ol = l; - return (s || (s = ' '), (l -= str.length) > 0 ? - (s = new Array(Math.ceil(l / s.length) + 1).join(s)) - .substr(0, t = !t ? l : t === 1 ? 0 : - Math.ceil(l / 2)) + str + s.substr(0, l - t) : str).substring(0, ol); -} - -function indent(text, width) { - return text.split('\n').map(function(line) { - return new Array((width || 4) + 1).join(' ') + line; - }).join('\n'); -} - -function splitLines(text, colLimit) { - if (!text) { - return []; - } - var firstSplit = text.split('\n'); - var secondSplit = []; - firstSplit.forEach(function(line) { - while (line.length > colLimit) { - var first = line.substring(0, colLimit); - secondSplit.push(first); - line = line.substring(colLimit); - } - secondSplit.push(line); - }); - return secondSplit; -} - -// Simple template function. Replaces occurences of "" with param[name] -function template(str, params) { - return !str.replace ? str : str.replace(/<(.+?)>/g, function(unchanged, name) { - return name in params ? params[name] : unchanged; - }); -} - -exports.pad = pad; -exports.indent = indent; -exports.splitLines = splitLines; -exports.template = template; diff --git a/node-tests/test.js b/node-tests/test.js index c407b1df..d1ef4e76 100644 --- a/node-tests/test.js +++ b/node-tests/test.js @@ -3,14 +3,12 @@ var fs = require('fs-extra'); var exec = require('child_process').exec; -var expect = require('chai').expect; +var chai = require('chai'); +chai.use(require('chai-things')); +var expect = chai.expect; var FAILING_FILE = __dirname + '/../tests/dummy/app/unused.js'; -var execSync = require('child_process').execSync; - -var chromeVersion = execSync('google-chrome --product-version').toString(); -var browser = 'Chrome ' + chromeVersion.split('.').slice(0, 2).join('.'); var path = require('path'); var Promise = require('rsvp').Promise; @@ -27,16 +25,16 @@ describe('ember-cli-eslint', function() { return emberTest().then(function(result) { expect(result.error).to.not.exist; expect(result.stdout.match(/[^\r\n]+/g)) - .to.contain(`ok 1 ${browser} - ESLint | app.js: should pass ESLint`) - .to.contain(`ok 2 ${browser} - ESLint | controllers/thing.js: should pass ESLint`) - .to.contain(`ok 3 ${browser} - ESLint | helpers/destroy-app.js: should pass ESLint`) - .to.contain(`ok 4 ${browser} - ESLint | helpers/module-for-acceptance.js: should pass ESLint`) - .to.contain(`ok 5 ${browser} - ESLint | helpers/start-app.js: should pass ESLint`) - .to.contain(`ok 6 ${browser} - ESLint | models/thing.js: should pass ESLint`) - .to.contain(`ok 7 ${browser} - ESLint | resolver.js: should pass ESLint`) - .to.contain(`ok 8 ${browser} - ESLint | router.js: should pass ESLint`) - .to.contain(`ok 9 ${browser} - ESLint | test-helper.js: should pass ESLint`) - .to.not.contain(`not ok 10 ${browser} - ESLint | unused.js: should pass ESLint`); + .to.include.something.that.matches(/ok 1 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app.js: should pass ESLint/) + .to.include.something.that.matches(/ok 2 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| controllers\/thing.js: should pass ESLint/) + .to.include.something.that.matches(/ok 3 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| helpers\/destroy-app.js: should pass ESLint/) + .to.include.something.that.matches(/ok 4 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| helpers\/module-for-acceptance.js: should pass ESLint/) + .to.include.something.that.matches(/ok 5 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| helpers\/start-app.js: should pass ESLint/) + .to.include.something.that.matches(/ok 6 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| models\/thing.js: should pass ESLint/) + .to.include.something.that.matches(/ok 7 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| resolver.js: should pass ESLint/) + .to.include.something.that.matches(/ok 8 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| router.js: should pass ESLint/) + .to.include.something.that.matches(/ok 9 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| test-helper.js: should pass ESLint/) + .to.not.include.something.that.matches(/not ok 10 Chrome [0-9]+\.[0-9]+ \[[0-9]+ ms\] - ESLint \| unused.js: should pass ESLint/); }) }); @@ -48,16 +46,16 @@ describe('ember-cli-eslint', function() { return emberTest({ NO_GROUPING: true }).then(function(result) { expect(result.error).to.exist; expect(result.stdout.match(/[^\r\n]+/g)) - .to.contain(`ok 1 ${browser} - ESLint | app.js: should pass ESLint`) - .to.contain(`ok 2 ${browser} - ESLint | controllers/thing.js: should pass ESLint`) - .to.contain(`ok 3 ${browser} - ESLint | helpers/destroy-app.js: should pass ESLint`) - .to.contain(`ok 4 ${browser} - ESLint | helpers/module-for-acceptance.js: should pass ESLint`) - .to.contain(`ok 5 ${browser} - ESLint | helpers/start-app.js: should pass ESLint`) - .to.contain(`ok 6 ${browser} - ESLint | models/thing.js: should pass ESLint`) - .to.contain(`ok 7 ${browser} - ESLint | resolver.js: should pass ESLint`) - .to.contain(`ok 8 ${browser} - ESLint | router.js: should pass ESLint`) - .to.contain(`ok 9 ${browser} - ESLint | test-helper.js: should pass ESLint`) - .to.contain(`not ok 10 ${browser} - ESLint | unused.js: should pass ESLint`); + .to.include.something.that.matches(/ok 1 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app.js: should pass ESLint/) + .to.include.something.that.matches(/ok 2 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| controllers\/thing.js: should pass ESLint/) + .to.include.something.that.matches(/ok 3 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| helpers\/destroy-app.js: should pass ESLint/) + .to.include.something.that.matches(/ok 4 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| helpers\/module-for-acceptance.js: should pass ESLint/) + .to.include.something.that.matches(/ok 5 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| helpers\/start-app.js: should pass ESLint/) + .to.include.something.that.matches(/ok 6 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| models\/thing.js: should pass ESLint/) + .to.include.something.that.matches(/ok 7 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| resolver.js: should pass ESLint/) + .to.include.something.that.matches(/ok 8 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| router.js: should pass ESLint/) + .to.include.something.that.matches(/ok 9 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| test-helper.js: should pass ESLint/) + .to.include.something.that.matches(/not ok 10 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| unused.js: should pass ESLint/); }) }); @@ -67,18 +65,18 @@ describe('ember-cli-eslint', function() { return emberTest().then(function(result) { expect(result.error).to.not.exist; expect(result.stdout.match(/[^\r\n]+/g)) - .to.contain(`ok 1 ${browser} - ESLint | app: app.js`) - .to.contain(`ok 2 ${browser} - ESLint | app: controllers/thing.js`) - .to.contain(`ok 3 ${browser} - ESLint | app: models/thing.js`) - .to.contain(`ok 4 ${browser} - ESLint | app: resolver.js`) - .to.contain(`ok 5 ${browser} - ESLint | app: router.js`) - .to.not.contain(`not ok 6 ${browser} - ESLint | app: unused.js`); + .to.include.something.that.matches(/ok 1 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: app.js/) + .to.include.something.that.matches(/ok 2 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: controllers\/thing.js/) + .to.include.something.that.matches(/ok 3 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: models\/thing.js/) + .to.include.something.that.matches(/ok 4 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: resolver.js/) + .to.include.something.that.matches(/ok 5 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: router.js/) + .to.not.include.something.that.matches(/not ok 6 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: unused.js/); expect(result.stdout.match(/[^\r\n]+/g)) - .to.contain(`ok 6 ${browser} - ESLint | tests: helpers/destroy-app.js`) - .to.contain(`ok 7 ${browser} - ESLint | tests: helpers/module-for-acceptance.js`) - .to.contain(`ok 8 ${browser} - ESLint | tests: helpers/start-app.js`) - .to.contain(`ok 9 ${browser} - ESLint | tests: test-helper.js`); + .to.include.something.that.matches(/ok 6 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: helpers\/destroy-app.js/) + .to.include.something.that.matches(/ok 7 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: helpers\/module-for-acceptance.js/) + .to.include.something.that.matches(/ok 8 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: helpers\/start-app.js/) + .to.include.something.that.matches(/ok 9 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: test-helper.js/); }) }); @@ -90,18 +88,18 @@ describe('ember-cli-eslint', function() { return emberTest().then(function(result) { expect(result.error).to.exist; expect(result.stdout.match(/[^\r\n]+/g)) - .to.contain(`ok 1 ${browser} - ESLint | app: app.js`) - .to.contain(`ok 2 ${browser} - ESLint | app: controllers/thing.js`) - .to.contain(`ok 3 ${browser} - ESLint | app: models/thing.js`) - .to.contain(`ok 4 ${browser} - ESLint | app: resolver.js`) - .to.contain(`ok 5 ${browser} - ESLint | app: router.js`) - .to.contain(`not ok 6 ${browser} - ESLint | app: unused.js`); + .to.include.something.that.matches(/ok 1 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: app.js/) + .to.include.something.that.matches(/ok 2 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: controllers\/thing.js/) + .to.include.something.that.matches(/ok 3 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: models\/thing.js/) + .to.include.something.that.matches(/ok 4 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: resolver.js/) + .to.include.something.that.matches(/ok 5 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: router.js/) + .to.include.something.that.matches(/not ok 6 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: unused.js/); expect(result.stdout.match(/[^\r\n]+/g)) - .to.contain(`ok 7 ${browser} - ESLint | tests: helpers/destroy-app.js`) - .to.contain(`ok 8 ${browser} - ESLint | tests: helpers/module-for-acceptance.js`) - .to.contain(`ok 9 ${browser} - ESLint | tests: helpers/start-app.js`) - .to.contain(`ok 10 ${browser} - ESLint | tests: test-helper.js`); + .to.include.something.that.matches(/ok 7 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: helpers\/destroy-app.js/) + .to.include.something.that.matches(/ok 8 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: helpers\/module-for-acceptance.js/) + .to.include.something.that.matches(/ok 9 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: helpers\/start-app.js/) + .to.include.something.that.matches(/ok 10 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: test-helper.js/); }) }); @@ -111,19 +109,19 @@ describe('ember-cli-eslint', function() { return emberTest().then(function(result) { expect(result.error).to.not.exist; expect(result.stdout.match(/[^\r\n]+/g)) - .to.contain(`ok 1 ${browser} - ESLint | app: app.js`) - .to.contain(`ok 2 ${browser} - ESLint | app: controllers/thing.js`) - .to.contain(`ok 3 ${browser} - ESLint | app: models/thing.js`) - .to.contain(`ok 4 ${browser} - ESLint | app: resolver.js`) - .to.contain(`ok 5 ${browser} - ESLint | app: router.js`) - .to.contain(`ok 6 ${browser} - ESLint | app: routes/thing.jsx`) - .to.not.contain(`not ok 7 ${browser} - ESLint | app: unused.js`); + .to.include.something.that.matches(/ok 1 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: app.js/) + .to.include.something.that.matches(/ok 2 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: controllers\/thing.js/) + .to.include.something.that.matches(/ok 3 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: models\/thing.js/) + .to.include.something.that.matches(/ok 4 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: resolver.js/) + .to.include.something.that.matches(/ok 5 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: router.js/) + .to.include.something.that.matches(/ok 6 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: routes\/thing.jsx/) + .to.not.include.something.that.matches(/not ok 7 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| app: unused.js/); expect(result.stdout.match(/[^\r\n]+/g)) - .to.contain(`ok 7 ${browser} - ESLint | tests: helpers/destroy-app.js`) - .to.contain(`ok 8 ${browser} - ESLint | tests: helpers/module-for-acceptance.js`) - .to.contain(`ok 9 ${browser} - ESLint | tests: helpers/start-app.js`) - .to.contain(`ok 10 ${browser} - ESLint | tests: test-helper.js`); + .to.include.something.that.matches(/ok 7 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: helpers\/destroy-app.js/) + .to.include.something.that.matches(/ok 8 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: helpers\/module-for-acceptance.js/) + .to.include.something.that.matches(/ok 9 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: helpers\/start-app.js/) + .to.include.something.that.matches(/ok 10 Chrome [0-9]+\.[0-9]+ - \[[0-9]+ ms\] - ESLint \| tests: test-helper.js/); }) }); }); diff --git a/package.json b/package.json index 384d35eb..197d925c 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "devDependencies": { "broccoli-asset-rev": "^3.0.0", "chai": "^4.0.2", + "chai-things": "^0.2.0", "ember-cli": "~3.4.3", "ember-cli-babel": "^7.1.2", "ember-cli-blueprint-test-helpers": "^0.19.1", diff --git a/testem.js b/testem.js index 2ac9a229..a51b4178 100644 --- a/testem.js +++ b/testem.js @@ -1,9 +1,6 @@ -var CustomReporter = require('./lib/old-tap-reporter'); - module.exports = { "test_page": "tests/index.html?hidepassed", "disable_watching": true, - "reporter": CustomReporter, "launch_in_ci": [ "Chrome" ], diff --git a/yarn.lock b/yarn.lock index 1131948f..48988182 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2548,6 +2548,11 @@ chai-files@^1.0.0, chai-files@^1.1.0: dependencies: assertion-error "^1.0.1" +chai-things@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/chai-things/-/chai-things-0.2.0.tgz#c55128378f9bb399e994f00052151984ed6ebe70" + integrity sha1-xVEoN4+bs5nplPAAUhUZhO1uvnA= + chai@^3.3.0: version "3.5.0" resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247"