You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems the paragraph about NodeArgsTransformer was inserted in the wrong place.
After “Here are a few more patterns that AroundNode enables.”, the following two subparagraphs should describe AroundNode-related content, same as before.
The advanced features of NodeArgsTransformer should not interrupt that section.
I’ve moved it accordingly, though please double-check that this new position makes sense.
Copy file name to clipboardExpand all lines: docs/index.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1808,20 +1808,6 @@ Lastly, you can pass `AroundNode` to the call to `RunSpecs` that launches the Gi
1808
1808
1809
1809
Here are a few more patterns that `AroundNode` enables.
1810
1810
1811
-
### Advanced: Transforming Node Arguments during Tree Construction
1812
-
1813
-
Ginkgo suites maintained by large communities (👋 Kubernetes) tend to adopt conventions to organize specs with labels and specific decorators. Enforcing these conventions is challenging but can be automated to some degree by inferring developer intent and transforming node arguments, during the Tree Construction phase, to add the relevant Ginkgo decorators.
1814
-
1815
-
This is done by registering a `NodeArgsTransformer` via `AddTreeConstructionNodeArgsTransformer`. The `NodeArgsTransformer` has signature `func(nodeType types.NodeType, offset Offset, text string, args []any) (string, []any, []error)` and is called before every node during Tree Construction.
1816
-
1817
-
If the `NodeArgsTransformer` returns any error, the test suite prints those errors and exits. The text and arguments can be modified, which includes directly changing the args slice that is passed in. Arguments have been flattened already, i.e. none of the entries in args is another []any.
1818
-
1819
-
The offset is valid for calling NewLocation directly in the implementation of TransformNodeArgs to find the location where the Ginkgo DSL function is called. An additional offset supplied by the caller via args is already included.
1820
-
1821
-
Additional information about the current node can be obtained by calling `CurrentTreeConstructionNodeReport()` from within the `NodeArgsTransformer`.
1822
-
1823
-
`AddTreeConstructionNodeArgsTransformer` can be called multiple times - tf there is more than one registered transformer, then the most recently added ones get called first.
1824
-
1825
1811
#### A global label-driven Configuration
1826
1812
1827
1813
By attaching `AroundNode` to `RunSpecs` and then using `CurrentSpecReport()` to obtain information about the currently running spec you can control which specs to apply configuration to:
`WithField` will receive a `nil` logger as it is invoked during the tree construction phase, not during the run phase when the `BeforeEach` actually runs.
1939
1925
1926
+
### Advanced: Transforming Node Arguments during Tree Construction
1927
+
1928
+
Ginkgo suites maintained by large communities (👋 Kubernetes) tend to adopt conventions to organize specs with labels and specific decorators. Enforcing these conventions is challenging but can be automated to some degree by inferring developer intent and transforming node arguments, during the Tree Construction phase, to add the relevant Ginkgo decorators.
1929
+
1930
+
This is done by registering a `NodeArgsTransformer` via `AddTreeConstructionNodeArgsTransformer`. The `NodeArgsTransformer` has signature `func(nodeType types.NodeType, offset Offset, text string, args []any) (string, []any, []error)` and is called before every node during Tree Construction.
1931
+
1932
+
If the `NodeArgsTransformer` returns any error, the test suite prints those errors and exits. The text and arguments can be modified, which includes directly changing the args slice that is passed in. Arguments have been flattened already, i.e. none of the entries in args is another []any.
1933
+
1934
+
The offset is valid for calling NewLocation directly in the implementation of TransformNodeArgs to find the location where the Ginkgo DSL function is called. An additional offset supplied by the caller via args is already included.
1935
+
1936
+
Additional information about the current node can be obtained by calling `CurrentTreeConstructionNodeReport()` from within the `NodeArgsTransformer`.
1937
+
1938
+
`AddTreeConstructionNodeArgsTransformer` can be called multiple times - tf there is more than one registered transformer, then the most recently added ones get called first.
1939
+
1940
1940
### Alternatives to Dot-Importing Ginkgo
1941
1941
1942
1942
As shown throughout this documentation, Ginkgo users are encouraged to dot-import the Ginkgo DSL into their test suites to effectively extend the Go language with Ginkgo's expressive building blocks:
0 commit comments