From 4a5c1fb727e4776c8e88b4e2ffdc1194a4ae793b Mon Sep 17 00:00:00 2001 From: David First Date: Fri, 29 May 2020 14:55:11 -0400 Subject: [PATCH] show a descriptive error when unit-tests fail to load requirejs package on some node versions --- .../filing-cabinet/index.spec.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/consumer/component/dependencies/files-dependency-builder/filing-cabinet/index.spec.ts b/src/consumer/component/dependencies/files-dependency-builder/filing-cabinet/index.spec.ts index 120daa52fc47..36e1b373bf52 100644 --- a/src/consumer/component/dependencies/files-dependency-builder/filing-cabinet/index.spec.ts +++ b/src/consumer/component/dependencies/files-dependency-builder/filing-cabinet/index.spec.ts @@ -20,7 +20,17 @@ require('resolve-dependency-path'); require('sass-lookup'); require('app-module-path'); require('module-definition'); -require('module-lookup-amd'); +try { + require('module-lookup-amd'); +} catch (err) { + console.log(`mocha suppresses the error, so console.error is needed to show the error on the screen. +the problem is with module-lookup-amd that calls requirejs package, which requires a file r.js, which is an invalid js file. +the error occurs on some specific node versions, such as v12.16.3. +if you get the error, please change your node version. (e.g. v12.7.0 is fine). +`); + console.error(err); + throw err; +} describe('filing-cabinet', () => { describe('JavaScript', () => {