-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(browser): resolved failure to find arbitrarily-named snapshot fil…
…es when using `expect(...).toMatchFileSnapshot()` matcher. (#4839) Co-authored-by: Zac Mullett <zac@Zacs-Air.modem> Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
- Loading branch information
1 parent
345a25d
commit b8140fc
Showing
10 changed files
with
61 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Serialization support utils. | ||
|
||
function cloneByOwnProperties(value: any) { | ||
// Clones the value's properties into a new Object. The simpler approach of | ||
// Object.assign() won't work in the case that properties are not enumerable. | ||
return Object.getOwnPropertyNames(value) | ||
.reduce((clone, prop) => ({ | ||
...clone, | ||
[prop]: value[prop], | ||
}), {}) | ||
} | ||
|
||
/** | ||
* Replacer function for serialization methods such as JS.stringify() or | ||
* flatted.stringify(). | ||
*/ | ||
export function stringifyReplace(key: string, value: any) { | ||
if (value instanceof Error) | ||
return cloneByOwnProperties(value) | ||
else | ||
return value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
my snapshot content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`file snapshot 1`] = `1`; | ||
exports[`snapshot 1`] = `1`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
test('file snapshot', async () => { | ||
await expect('inaccessible snapshot content') | ||
.toMatchFileSnapshot('/inaccesible/path') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters