From e817e1bd474ea2ca5bb80a3dcf26907d8651956b Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Sat, 19 Feb 2022 09:48:23 +0100 Subject: [PATCH] chore: Updated mocha settins and added terser reporter --- config/scripts.yaml | 22 +++++++++++----------- tests/reporters/terse.js | 13 +++++++++++++ 2 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 tests/reporters/terse.js diff --git a/config/scripts.yaml b/config/scripts.yaml index 37319e087dc..7dd5c0f2674 100644 --- a/config/scripts.yaml +++ b/config/scripts.yaml @@ -2,7 +2,7 @@ _: clean: 'rimraf dist' build: 'rollup -c' cibuild_step1: 'rollup -c' - test: 'echo "{{name}}: No tests configured. Perhaps you''d like to do this?" && exit 0' + test: ¬ests 'echo "{{name}}: No tests configured. Perhaps you''d like to do this?" && exit 0' pubtest: 'npm publish --registry http://localhost:6662' pubforce: 'npm publish' symlink: 'mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -' @@ -10,11 +10,11 @@ _: _types: pattern: netlify: 'echo "Not configured yet"' - test: 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs --require @babel/register' - testci: 'BABEL_ENV=production ./node_modules/.bin/_mocha tests/*.test.mjs --require @babel/register' + test: &test 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs --require @babel/register' + testci: &testci "BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs --require @babel/register --jobs 4 --parallel --reporter ../../tests/reporters/terse.js" plugin: - test: 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs --require @babel/register' - testci: 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs --require @babel/register' + test: *test + testci: *testci prettier: "npx prettier --write 'src/*.js' 'tests/*.mjs'" create-freesewing-pattern: clean: '!' @@ -22,14 +22,14 @@ create-freesewing-pattern: modulebuild: '!' cibuild_step1: '!' build: '!' - test: 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs' - testci: 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.mjs' + test: *test + testci: *testci css-theme: cibuild_step1: 'npx node-sass --output-style compressed src/theme.scss dist/theme.css' build: 'npx node-sass --output-style compressed src/theme.scss dist/theme.css' watch: 'npx node-sass --watch --output-style compressed src/theme.scss dist/theme.css' components: - test: 'echo "{{name}}: No tests configured. Perhaps you''d like to do this?" && exit 0' + test: *notests storybook: 'start-storybook -p 6663' # react-scripts doesn't handle .mjs files correctly modulebuild: '!' @@ -40,14 +40,14 @@ components: core: testonly: 'BABEL_ENV=production mocha tests/*.test.js' test: 'BABEL_ENV=production nyc -x node_modules -x tests/fixtures -x bin-pack mocha tests/*.test.js' - testci: 'BABEL_ENV=production nyc -x node_modules -x tests/fixtures -x bin-pack mocha tests/*.test.js' + testci: "BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.js --require @babel/register --jobs 4 --parallel --reporter ../../tests/reporters/terse.js" report: 'BABEL_ENV=production nyc report --reporter=html' coverage: 'BABEL_ENV=production nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && ./node_modules/.bin/codecov' i18n: # react-scripts doesn't handle .mjs files correctly modulebuild: '!' - test: 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.js --require @babel/register' - testci: 'BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.js --require @babel/register' + test: *test + testci: *testci prebuild: 'node src/prebuild.mjs' pattern-info: cibuild_step1: '!' diff --git a/tests/reporters/terse.js b/tests/reporters/terse.js new file mode 100644 index 00000000000..ad7799e7289 --- /dev/null +++ b/tests/reporters/terse.js @@ -0,0 +1,13 @@ +const Mocha = require('mocha') +const { EVENT_TEST_FAIL } = Mocha.Runner.constants + +// This output very little info and is intended for CI runs +class TerseReporter { + constructor(runner) { + runner.on(EVENT_TEST_FAIL, (test, err) => { + console.log(` FAIL: ${test.fullTitle()}`) + }) + } +} + +module.exports = TerseReporter