From d337f40d0efd59e163f871ed7a73e900322473a6 Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Wed, 1 Jan 2020 21:21:24 +0100 Subject: [PATCH] test: show diff when test:bin fails --- package-lock.json | 17 +++++++++++++++++ package.json | 3 ++- tasks/test-bin.js | 13 ++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d119122f..2223f0b86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1394,6 +1394,23 @@ "type-detect": "^4.0.5" } }, + "chai-diff": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/chai-diff/-/chai-diff-1.0.1.tgz", + "integrity": "sha1-bGaJRwDYDNkDUKtORANiXU9TocE=", + "dev": true, + "requires": { + "diff": "^2.2.1" + }, + "dependencies": { + "diff": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz", + "integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=", + "dev": true + } + } + }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", diff --git a/package.json b/package.json index 19f096a5a..c164ea9c2 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "babel-runtime": "^5.1.10", "benchmark": "~1.0", "chai": "^4.2.0", + "chai-diff": "^1.0.1", "concurrently": "^5.0.0", "dirty-chai": "^2.0.1", "dtslint": "^0.5.5", @@ -84,7 +85,7 @@ "scripts": { "format": "prettier --write '**/*.js' && eslint --fix .", "check-format": "prettier --check '**/*.js'", - "lint": "eslint --max-warnings 0 . ", + "lint": "eslint --max-warnings 0 .", "dtslint": "dtslint types", "test": "grunt", "extensive-tests-and-publish-to-aws": "npx mocha tasks/task-tests/ && grunt --stack extensive-tests-and-publish-to-aws", diff --git a/tasks/test-bin.js b/tasks/test-bin.js index 8873c9f01..077e6d4f3 100644 --- a/tasks/test-bin.js +++ b/tasks/test-bin.js @@ -1,7 +1,10 @@ -const childProcess = require('child_process'), - fs = require('fs'), - os = require('os'), - expect = require('chai').expect; +const childProcess = require('child_process'); +const fs = require('fs'); +const os = require('os'); + +const chai = require('chai'); +chai.use(require('chai-diff')); +const expect = chai.expect; module.exports = function(grunt) { grunt.registerTask('test:bin', function() { @@ -18,7 +21,7 @@ module.exports = function(grunt) { const normalizedOutput = normalizeCrlf(stdout); const normalizedExpectedOutput = normalizeCrlf(expectedOutput); - expect(normalizedOutput).to.equal(normalizedExpectedOutput); + expect(normalizedOutput).not.to.be.differentFrom(normalizedExpectedOutput); }); };