Skip to content

Commit

Permalink
Merge pull request #175 from iambumblehead/show-full-path-at-error-me…
Browse files Browse the repository at this point in the history
…ssage

show full path at error message
  • Loading branch information
iambumblehead authored Oct 14, 2022
2 parents 996a798 + 6689680 commit 5dfe486
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 4 additions & 9 deletions src/esmockErr.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 5dfe486

Please sign in to comment.