Skip to content

Commit 0b80a09

Browse files
authored
Support array of macros in test trait. (#37)
1 parent 415964c commit 0b80a09

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Sources/MacroTesting/MacrosTestTrait.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@
2828
record: record
2929
)
3030
}
31+
32+
/// Configure snapshot testing in a suite or test.
33+
///
34+
/// - Parameters:
35+
/// - indentationWidth: The `Trivia` for setting indentation during macro expansion (e.g., `.spaces(2)`).
36+
/// Defaults to the original source's indentation if unspecified.
37+
/// - record: The recording strategy to use for macro expansions. This can be set to `.all`, `.missing`,
38+
/// `.never`, or `.failed`. If not provided, it uses the current configuration, which can also be set via
39+
/// the `SNAPSHOT_TESTING_RECORD` environment variable.
40+
/// - macros: An array of macros. This specifies which macros should be expanded during testing.
41+
public static func macros(
42+
indentationWidth: Trivia? = nil,
43+
record: SnapshotTestingConfiguration.Record? = nil,
44+
macros: [Macro.Type]? = nil
45+
) -> Self {
46+
_MacrosTestTrait(
47+
configuration: MacroTestingConfiguration(
48+
indentationWidth: indentationWidth,
49+
macros: macros.map { Dictionary(macros: $0) }
50+
),
51+
record: record
52+
)
53+
}
3154
}
3255

3356
/// A type representing the configuration of snapshot testing.

0 commit comments

Comments
 (0)