chore: add readme components tests#1434
Conversation
There was a problem hiding this comment.
Quick chore to actually pass in components to Xish
maximilianfalco
left a comment
There was a problem hiding this comment.
lgtm! can we also do a coverage test just so we dont miss anything
| import { mdxish, renderMdxish } from '../../lib'; | ||
| import { execute } from '../helpers'; | ||
|
|
||
| export const renderingEngines = [ |
| expect(container.textContent).toContain('console.log()'); | ||
| }); | ||
| }); | ||
| }); No newline at end of file |
There was a problem hiding this comment.
| }); | |
| }); | |
| expect(container).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
| }); No newline at end of file |
There was a problem hiding this comment.
| }); | |
| }); | |
kevinports
left a comment
There was a problem hiding this comment.
Saw a few minor things. But nice improvement!
| @@ -1,34 +1,41 @@ | |||
| import type { Element } from 'hast'; | |||
|
|
|||
| import '@testing-library/jest-dom/vitest'; | |||
There was a problem hiding this comment.
Do we need this import here?
| }); | ||
|
|
||
| describe('mdxish-specific behaviours', () => { | ||
| it('should correctly parse content when', () => { |
There was a problem hiding this comment.
Did the description here get cut short? "should correctly parse content when"
When what?
There was a problem hiding this comment.
Ah sorry silly mistake from me, updated this!
| import { render, screen } from '@testing-library/react'; | ||
| import React from 'react'; | ||
|
|
||
| import { expect } from 'vitest'; |
There was a problem hiding this comment.
I think expect is available globally with vitest and we don't need to actually import it here.
There was a problem hiding this comment.
Sorry I should have explained earlier. I think typescript checks the global expect from jest and not vitest's and I was getting type errors in some expect methods. Even though it's actually fine to run, because as you said vitest is available, it only injects its expect at runtime, so it runs but typescript doesn't see it. There's a bit of difference in the expect of jest & vitest, some methods we use here are not available in jest. Hence, I explicitly imported the vitest types with the import '@testing-library/jest-dom/vitest'; and the expect to fix the errors
## Version 14.1.0 ### ⚠ BREAKING CHANGES * **mdxish:** AST nodes - We can't just use safeMode because we still need the inline expressions to be parsed as expression nodes, so there still needs to be an expression parsing ## 🎯 What does this PR do? ### ✨ New & Improved * **mdxish:** remove jsx attribute expression preprocessing ([#1429](#1429)) ([9545472](9545472)), closes [#1426](#1426) ### 🛠 Fixes & Updates * add readme components tests ([#1434](#1434)) ([72ea080](72ea080)), closes [#1354](#1354) * **deps:** bump actions/upload-artifact from 5 to 7 ([#1417](#1417)) ([3ca6d32](3ca6d32)) * **mdxish:** legacy glossary syntax in callout title crashing ([#1441](#1441)) ([9d1b18b](9d1b18b)) <!--SKIP CI-->
This PR was released!🚀 Changes included in v14.1.0 |

🎯 What does this PR do?
Increased test coverage for the readme components & added testing for both the mdx & mdxish rendering engine. This is to better catch potential regressions from changes, and also ensure mdx & mdxish outputs are consistent with each other. This copies some tests from Falco's old PR in #1354
🧪 QA tips
Every new test should pass