From 8f496fb4475f9611e097cf6c89baffede104ab75 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Mon, 5 Jul 2021 10:42:27 +0100 Subject: [PATCH] Added `yarn test:slow` tool to show slow tests - We have a lot of tests, so it can be hard to see if any are problematic - We have a problem with some tests being too slow, this highlights these in particular - Very slow tests that take seconds are not really unit tests, we should look for different ways to run these - Also we should tailor our mocha settings more, so that we have more lenient settings for acceptance/regression tests but not for unit tests - Note: You have to wait for all tests to run to see the output --- package.json | 2 ++ yarn.lock | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/package.json b/package.json index 913daca388..35cdb729cf 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "start": "node index", "dev": "DEBUG=ghost:* grunt dev", "test": "grunt validate", + "test:slow": "grunt validate --reporter=mocha-slow-test-reporter", "ci": "grunt validate --verbose", "ci:regression": "grunt test-regression --verbose", "setup": "yarn install && knex-migrator init && grunt symlink && grunt init || (exit 0)", @@ -176,6 +177,7 @@ "grunt-update-submodules": "0.4.1", "jwks-rsa": "2.0.3", "mocha": "9.0.2", + "mocha-slow-test-reporter": "^0.1.2", "mock-knex": "0.4.10", "nock": "13.1.1", "papaparse": "5.3.1", diff --git a/yarn.lock b/yarn.lock index 8478289f3b..3f673cd848 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6928,6 +6928,16 @@ mobiledoc-text-renderer@0.4.0: resolved "https://registry.yarnpkg.com/mobiledoc-text-renderer/-/mobiledoc-text-renderer-0.4.0.tgz#473fbe50aa6cde2c3b449752f3b984834dc824d2" integrity sha512-+Tzfo0hhUFxS0n5FWZ0nf6WUrvnVmsxaIdq0CyeLYD1lk8oW2ml+6WLdeLlzKM5OYYi3PWV6NR9HCUG01cdvWQ== +mocha-slow-test-reporter@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/mocha-slow-test-reporter/-/mocha-slow-test-reporter-0.1.2.tgz#e1d8138f8c2b8a2d72a727e6a14d808e406221c4" + integrity sha1-4dgTj4wrii1ypyfmoU2AjkBiIcQ= + dependencies: + chalk "^1.1.1" + string-length "^1.0.1" + text-table "^0.2.0" + wordwrap "^1.0.0" + mocha@9.0.2: version "9.0.2" resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.0.2.tgz#e84849b61f406a680ced85af76425f6f3108d1a0" @@ -9449,6 +9459,13 @@ streamsearch@0.1.2: resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" integrity sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo= +string-length@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string-length/-/string-length-1.0.1.tgz#56970fb1c38558e9e70b728bf3de269ac45adfac" + integrity sha1-VpcPscOFWOnnC3KL894mmsRa36w= + dependencies: + strip-ansi "^3.0.0" + string-template@~0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add"