From 66896804d180394b6ea7461b939ea7a81ba9a876 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 13 Oct 2022 19:40:08 -0700 Subject: [PATCH] show full path at error message --- CHANGELOG.md | 2 ++ package.json | 2 +- src/esmockErr.js | 13 ++++--------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07295458..5738a11f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # changelog + * 2.0.6 _Oct.14.2022_ + * [show full path at error message,](https://github.com/iambumblehead/esmock/pull/170) making it easier to identify an invalid path * 2.0.5 _Oct.05.2022_ * [add support for esmock.strictest,](https://github.com/iambumblehead/esmock/pull/172) a more-strict variant of esmock, per @gmahomarf * [use more-descriptive internal-variable "treeId",](https://github.com/iambumblehead/esmock/pull/170) rather than "esmockKey" diff --git a/package.json b/package.json index 90703680..ff9f86b7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "esmock", "type": "module", - "version": "2.0.5", + "version": "2.0.6", "license": "ISC", "readmeFilename": "README.md", "description": "provides native ESM import mocking for unit tests", diff --git a/src/esmockErr.js b/src/esmockErr.js index 3232a2b9..35905f9b 100644 --- a/src/esmockErr.js +++ b/src/esmockErr.js @@ -1,13 +1,8 @@ -const narrow = p => p - .replace('file://', '') - .replace(process.cwd(), '.') - .replace(process.env.HOME, '~') +const errModuleIdNotFound = (moduleId, parent) => + new Error(`invalid moduleId: "${moduleId}" (used by ${parent})`) -const errModuleIdNotFound = (moduleId, parent) => new Error( - `invalid moduleId: "${narrow(moduleId)}" (used by ${narrow(parent)})`) - -const errModuleIdNotMocked = (moduleId, parent) => new Error( - `un-mocked moduleId: "${narrow(moduleId)}" (used by ${narrow(parent)})`) +const errModuleIdNotMocked = (moduleId, parent) => + new Error(`un-mocked moduleId: "${moduleId}" (used by ${parent})`) export default { errModuleIdNotFound,