diff --git a/config/jest/jest.config.js b/config/jest/jest.config.js index 17c36671..97d5266e 100644 --- a/config/jest/jest.config.js +++ b/config/jest/jest.config.js @@ -23,7 +23,15 @@ const rbConst = name => const iLibDirs = ['node_modules/@enact/i18n/ilib', 'node_modules/ilib', 'ilib']; const globals = { __DEV__: true, - ILIB_BASE_PATH: iLibDirs.find(f => fs.existsSync(path.join(app.context, f))) || iLibDirs[1], + // Support npm workspaces where ilib may be hoisted to a parent node_modules + ILIB_BASE_PATH: iLibDirs.find(f => fs.existsSync(path.join(app.context, f))) || + (() => { + try { + return path.relative(app.context, path.dirname(require.resolve('ilib/package.json', {paths: [app.context]}))); + } catch { + return iLibDirs[1]; + } + })(), ILIB_RESOURCES_PATH: 'resources', ILIB_CACHE_ID: new Date().getTime() + '', [rbConst(app.name)]: 'resources'