Skip to content

Commit bea6d28

Browse files
committed
test: filter out comment lines in JSX test assertions
1 parent b0fcd0a commit bea6d28

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

exercises/03.using-jsx/01.solution.compiler/index.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,25 @@ await testStep('babel is loaded', () => {
2929
})
3030

3131
await testStep('JSX is in use', async () => {
32+
// Filter out comment lines before checking
33+
const scriptContent = inlineScript!.textContent || ''
34+
const lines = scriptContent.split('\n')
35+
const nonCommentLines = lines
36+
.filter((line) => {
37+
const trimmed = line.trim()
38+
return (
39+
!trimmed.startsWith('//') &&
40+
!trimmed.startsWith('/*') &&
41+
!trimmed.startsWith('*')
42+
)
43+
})
44+
.join('\n')
45+
3246
expect(
33-
inlineScript!.textContent,
34-
'createElement( should not appear in your source',
47+
nonCommentLines,
48+
'createElement( should not appear in your source (excluding comments)',
3549
).not.to.include('createElement(')
36-
expect(inlineScript!.textContent, 'JSX is not in use').to.include('</div>')
50+
expect(nonCommentLines, 'JSX is not in use (excluding comments)').to.include(
51+
'</div>',
52+
)
3753
})

0 commit comments

Comments
 (0)