File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
apps/astro-docs/src/content/docs/core/testing Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : toGraph
3+ description : Details about the Angular Three Testing `toGraph` function
4+ ---
5+
6+ ` toGraph ` is a function that allows you to convert a THREE.js object into a simple ` NgtTestGraphObject ` .
7+
8+ This is useful for snapshot testing as it _ at least_ provides the scene graph structure.
9+
10+ :::caution
11+
12+ In many cases, we can use ` toJSON ` on the THREE.js object to better structure. However, this is not always possible
13+
14+ - The ` uuid ` property will always be different for each test run making it difficult to do snapshot testing
15+ - Some THREE.objects do not have ` toJSON ` method and will throw an error when we try to call ` scene.toJSON() ` from the root
16+
17+ :::
18+
19+ ``` ts
20+ const { fixture, toGraph } = NgtTestBed .create (SceneGraph );
21+ fixture .detectChanges ();
22+
23+ expect (toGraph ()).toMatchSnapshot ();
24+
25+ /**
26+ * For a scene with a single mesh
27+ *
28+ * [
29+ * {
30+ * "type": "Mesh",
31+ * "name": "",
32+ * "children": []
33+ * }
34+ * ]
35+ */
36+ ```
37+
38+
You can’t perform that action at this time.
0 commit comments