Skip to content

Commit

Permalink
Fix unit test package scripts (#12278)
Browse files Browse the repository at this point in the history
This PR fixes our local unit test package scripts. When the state migration unit tests were migrated to Jest in #12106, it left the `test:unit` script in a broken state, because it didn't tell `mocha` to ignore the state migration tests.

Arguably, that script was already broken, since the most reasonably expectation from its name is that it runs _all_ unit tests. The PR makes it so that it does just that, by means of `concurrently`.

Unfortunately, `concurrently` only outputs errors from child processes once (at the time when they exit, open-cli-tools/concurrently#134). This means that we have to search/navigate the output for this combined script to identify the failure. That said, it's better than the status quo.
  • Loading branch information
rekmarks committed Oct 6, 2021
1 parent cd09e5b commit 822ce5b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -24,9 +24,10 @@
"dapp-chain": "GANACHE_ARGS='-b 2' concurrently -k -n ganache,dapp -p '[{time}][{name}]' 'yarn ganache:start' 'sleep 5 && yarn dapp'",
"forwarder": "node ./development/static-server.js ./node_modules/@metamask/forwarder/dist/ --port 9010",
"dapp-forwarder": "concurrently -k -n forwarder,dapp -p '[{time}][{name}]' 'yarn forwarder' 'yarn dapp'",
"test:unit": "mocha --exit --require test/env.js --require test/setup.js --recursive './app/**/*.test.js'",
"test:unit": "./test/test-unit-combined.sh",
"test:unit:jest": "./test/test-unit-jest.sh",
"test:unit:global": "mocha --exit --require test/env.js --require test/setup.js --recursive test/unit-global/*.test.js",
"test:unit:jest": "./test/run-jest.sh",
"test:unit:mocha": "mocha --exit --require test/env.js --require test/setup.js --ignore './app/scripts/migrations/*.test.js' --recursive './app/**/*.test.js'",
"test:unit:lax": "mocha --exit --require test/env.js --require test/setup.js --ignore './app/scripts/controllers/permissions/*.test.js' --ignore './app/scripts/migrations/*.test.js' --recursive './app/**/*.test.js'",
"test:unit:strict": "mocha --exit --require test/env.js --require test/setup.js --recursive './app/scripts/controllers/permissions/*.test.js'",
"test:unit:path": "mocha --exit --require test/env.js --require test/setup.js --recursive",
Expand Down
11 changes: 11 additions & 0 deletions test/test-unit-combined.sh
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -x
set -e
set -u
set -o pipefail

concurrently --raw -n mocha,jest,global \
"yarn test:unit:mocha" \
"yarn test:unit:jest" \
"yarn test:unit:global"
2 changes: 1 addition & 1 deletion test/run-jest.sh → test/test-unit-jest.sh
Expand Up @@ -5,6 +5,6 @@ set -e
set -u
set -o pipefail

concurrently \
concurrently -n production,development \
"jest --config=./jest.config.js $*" \
"jest --config=./development/jest.config.js $*"

0 comments on commit 822ce5b

Please sign in to comment.