diff --git a/.eslintignore b/.eslintignore index 390c521..23ddbc1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,4 @@ **/node_modules -build \ No newline at end of file +build +integrationTests/__fixtures__ +generator/fixtures diff --git a/lib/createJestRunner.js b/lib/createJestRunner.js index da01b32..8a42704 100644 --- a/lib/createJestRunner.js +++ b/lib/createJestRunner.js @@ -73,7 +73,17 @@ const createRunner = (runPath, { getExtraOptions } = {}) => { return runner(baseOptions); }); }) - .then(result => onResult(test, result)) + .then(testResult => { + if (Array.isArray(testResult)) { + testResult.forEach(result => + result.numFailingTests > 0 + ? onFailure(test, new Error(result.errorMessage)) + : onResult(test, result), + ); + return; + } + onResult(test, testResult); + }) .catch(err => onFailure(test, err)), ), Promise.resolve(), @@ -142,8 +152,18 @@ const createRunner = (runPath, { getExtraOptions } = {}) => { const runAllTests = Promise.all( tests.map(test => runTestInWorker(test) - .then(testResult => onResult(test, testResult)) - .catch(error => onError(error, test)), + .then(testResult => { + if (Array.isArray(testResult)) { + testResult.forEach(result => + result.numFailingTests > 0 + ? onError(new Error(result.errorMessage), test) + : onResult(test, result), + ); + return; + } + onResult(test, testResult); + }) + .catch(err => onError(err, test)), ), ); diff --git a/package.json b/package.json index 6c5596a..11bd3ed 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,13 @@ "generator/" ], "scripts": { - "test": "jest", - "lint": "eslint .", + "pre-commit": "yarn test && yarn lint", + "pretest": "yarn build", + "test": "jest --no-colors", + "lint": "eslint . --fix", "watch": "babel lib -w --ignore **/*.test.js,integration -d build", "build": "babel lib --ignore **/*.test.js,integration -d build", - "prepublish": "yarn build", + "prepublishOnly": "yarn pre-commit", "format": "prettier --single-quote --trailing-comma all --write \"!(build)/**/*.js\"" }, "dependencies": {