(code: string)
| 13 | } |
| 14 | |
| 15 | function getJSXElementPath(code: string): NodePath<t.JSXElement> { |
| 16 | const ast = parseJSX(code); |
| 17 | let elementPath: NodePath<t.JSXElement> | null = null; |
| 18 | |
| 19 | traverse(ast, { |
| 20 | JSXElement(path) { |
| 21 | elementPath = path; |
| 22 | path.stop(); |
| 23 | }, |
| 24 | }); |
| 25 | |
| 26 | if (!elementPath) { |
| 27 | throw new Error("No JSX element found in the code"); |
| 28 | } |
| 29 | |
| 30 | return elementPath; |
| 31 | } |
| 32 | |
| 33 | describe("extractJsxContent", () => { |
| 34 | describe("plain", () => { |
no test coverage detected