diff --git a/curriculum/test/utils/extract-js-comments.test.js b/curriculum/test/utils/extract-js-comments.test.js index ead1f5da5a..79d2a9767d 100644 --- a/curriculum/test/utils/extract-js-comments.test.js +++ b/curriculum/test/utils/extract-js-comments.test.js @@ -13,6 +13,8 @@ var y = '// single line comment'; `; +const someInvalidJS = `const isChange;`; + describe('extractJSComments', () => { it('should return an object with comment keys and count values', () => { const commentCounts = { @@ -21,4 +23,13 @@ describe('extractJSComments', () => { }; expect(extractJSComments(someJS)).toEqual(commentCounts); }); + + it('should throw an informative error if the JS is invalid', () => { + expect(() => extractJSComments(someInvalidJS)).toThrow( + `extract-js-comments could not parse the code below, this challenge have invalid syntax: + +${someInvalidJS} +` + ); + }); });