diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c9a0ea6..5d6d793 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -61,4 +61,4 @@ jobs: echo "Tests from code:" npm test echo "Tests from file with TARGET_FILE_PATH env variable:" - TARGET_FILE_PATH='./README.md' npm test + TARGET_FILE_PATH='./README.md' node index.js diff --git a/tests/links.test.js b/tests/links.test.js index dc86f06..f33f592 100644 --- a/tests/links.test.js +++ b/tests/links.test.js @@ -1,9 +1,17 @@ const { checkFile } = require('../index.js'); -checkFile( - './README.md', - [ - 'https://github.com/Marketionist/img-link-checker/actions', - 'https://www.linkedin.com/in/test/' - ] -); +(async () => { + const brokenLinks = await checkFile( + './README.md', + [ + 'https://github.com/Marketionist/img-link-checker/actions', + 'https://www.linkedin.com/in/test/' + ] + ); + + // Print a list of broken links and exit the process (will mark the CI/CD build as failed) + if (brokenLinks.length > 0) { + console.error('Broken links list:', brokenLinks); + process.exit(1); + } +})();