Skip to content

Commit 297b9dc

Browse files
committed
fix: broken core snapshot tests
Updated snapshot path handling so that both snapshot assertion functions work correctly when tests are run using absolute paths. The directory path is now derived without a prefixed “./”
1 parent bc2390e commit 297b9dc

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Fix broken core snapshot tests
6+
37
## [0.22.1](https://github.com/TypedDevs/bashunit/compare/0.22.0...0.22.1) - 2025-07-23
48

59
- Fix prevents writing in src dir during tests

src/assert_snapshot.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function assert_match_snapshot() {
4141
local snapshot_file="${2-}"
4242

4343
if [[ -z "$snapshot_file" ]]; then
44-
local directory="./$(dirname "${BASH_SOURCE[1]}")/snapshots"
44+
local directory="$(dirname "${BASH_SOURCE[1]}")/snapshots"
4545
local test_file="$(helper::normalize_variable_name "$(basename "${BASH_SOURCE[1]}")")"
4646
local snapshot_name="$(helper::normalize_variable_name "${FUNCNAME[1]}").snapshot"
4747
snapshot_file="${directory}/${test_file}.${snapshot_name}"
@@ -78,7 +78,7 @@ function assert_match_snapshot_ignore_colors() {
7878

7979
local snapshot_file="${2-}"
8080
if [[ -z "$snapshot_file" ]]; then
81-
local directory="./$(dirname "${BASH_SOURCE[1]}")/snapshots"
81+
local directory="$(dirname "${BASH_SOURCE[1]}")/snapshots"
8282
local test_file="$(helper::normalize_variable_name "$(basename "${BASH_SOURCE[1]}")")"
8383
local snapshot_name="$(helper::normalize_variable_name "${FUNCNAME[1]}").snapshot"
8484
snapshot_file="${directory}/${test_file}.${snapshot_name}"

0 commit comments

Comments
 (0)