From: Eduardo San Martin Morote Date: Tue, 16 Apr 2019 15:57:13 +0000 (+0200) Subject: test: allow inline snapshot testing with mocha X-Git-Tag: v4.0.0-alpha.0~439 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61b65e9a87c2d339457a578e82d0d1fb1ec50e78;p=thirdparty%2Fvuejs%2Frouter.git test: allow inline snapshot testing with mocha --- diff --git a/__tests__/helper.js b/__tests__/helper.js index 5ce707b5..293187ab 100644 --- a/__tests__/helper.js +++ b/__tests__/helper.js @@ -1,4 +1,17 @@ if (typeof global !== 'undefined' && typeof global.beforeAll === 'undefined') { global.beforeAll = global.before global.afterAll = global.after + + const expect = require('expect') + // monkey patch jest snapshots + expect.extend({ + toMatchInlineSnapshot(received, snapshot) { + const text = `[${received.toString()}]` + const pass = text === snapshot + return { + pass, + message: () => 'Snapshot not maching: ' + text, + } + }, + }) } diff --git a/package.json b/package.json index d520a0b8..9e566bab 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "jsdom": "^14.0.0", "mocha": "^6.1.3", "nyc": "^13.3.0", + "prettier": "^1.17.0", "ts-jest": "^24.0.2", "ts-loader": "^5.3.3", "ts-node": "^8.0.3", diff --git a/yarn.lock b/yarn.lock index dfc5e82f..80ae8006 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4810,6 +4810,11 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= +prettier@^1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.17.0.tgz#53b303676eed22cc14a9f0cec09b477b3026c008" + integrity sha512-sXe5lSt2WQlCbydGETgfm1YBShgOX4HxQkFPvbxkcwgDvGDeqVau8h+12+lmSVlP3rHPz0oavfddSZg/q+Szjw== + pretty-error@^2.0.2: version "2.1.1" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"