@@ -19,6 +19,9 @@ test('simple', async ({ annotate }) => {
1919 await annotate('3', { path: './test-3.js' })
2020 await annotate('4', 'warning', { path: './test-4.js' })
2121 await externalAnnotate(annotate)
22+ await annotate('with base64 body', { body: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' })
23+ await annotate('with Uint8Array body', { body: new Uint8Array(Array.from({ length: 256 }).map((_, i) => i)) })
24+ await annotate('with contentType', { body: '', contentType: 'text/plain' })
2225})
2326
2427describe('suite', () => {
@@ -61,7 +64,7 @@ describe('API', () => {
6164 {
6265 onTestCaseAnnotate ( testCase , annotation ) {
6366 const path = annotation . attachment ?. path ?. replace ( testCase . project . config . root , '<root>' ) . replace ( / \w + \. j s $ / , '<hash>.js' )
64- events . push ( `[annotate] ${ testCase . name } ${ annotation . message } ${ annotation . type } ${ path } ` )
67+ events . push ( `[annotate] ${ testCase . name } ${ annotation . message } ${ annotation . type } path= ${ path } contentType= ${ annotation . attachment ?. contentType } body= ${ annotation . attachment ?. body } ` )
6568 } ,
6669 onTestCaseReady ( testCase ) {
6770 events . push ( `[ready] ${ testCase . name } ` )
@@ -97,15 +100,18 @@ describe('API', () => {
97100 expect ( events ) . toMatchInlineSnapshot ( `
98101 [
99102 "[ready] simple",
100- "[annotate] simple 1 notice undefined",
101- "[annotate] simple 2 warning undefined",
102- "[annotate] simple 3 notice <root>/.vitest-attachments/3-<hash>.js",
103- "[annotate] simple 4 warning <root>/.vitest-attachments/4-<hash>.js",
104- "[annotate] simple external notice undefined",
103+ "[annotate] simple 1 notice path=undefined contentType=undefined body=undefined",
104+ "[annotate] simple 2 warning path=undefined contentType=undefined body=undefined",
105+ "[annotate] simple 3 notice path=<root>/.vitest-attachments/3-<hash>.js contentType=text/javascript body=undefined",
106+ "[annotate] simple 4 warning path=<root>/.vitest-attachments/4-<hash>.js contentType=text/javascript body=undefined",
107+ "[annotate] simple external notice path=undefined contentType=undefined body=undefined",
108+ "[annotate] simple with base64 body notice path=undefined contentType=undefined body=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
109+ "[annotate] simple with Uint8Array body notice path=undefined contentType=undefined body=AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==",
110+ "[annotate] simple with contentType notice path=undefined contentType=text/plain body=",
105111 "[result] simple",
106112 "[ready] second",
107- "[annotate] second 5 notice undefined",
108- "[annotate] second 6 notice https://absolute-path.com",
113+ "[annotate] second 5 notice path=undefined contentType=undefined body= undefined",
114+ "[annotate] second 6 notice path= https://absolute-path.com contentType=undefined body=undefined ",
109115 "[result] second",
110116 ]
111117 ` )
@@ -117,7 +123,7 @@ describe('API', () => {
117123 "location": {
118124 "column": 11,
119125 "file": "<root>/basic.test.ts",
120- "line": 15 ,
126+ "line": 18 ,
121127 },
122128 "message": "5",
123129 "type": "notice",
@@ -129,7 +135,7 @@ describe('API', () => {
129135 "location": {
130136 "column": 11,
131137 "file": "<root>/basic.test.ts",
132- "line": 16 ,
138+ "line": 19 ,
133139 },
134140 "message": "6",
135141 "type": "notice",
@@ -189,6 +195,43 @@ describe('API', () => {
189195 "message": "external",
190196 "type": "notice",
191197 },
198+ {
199+ "attachment": {
200+ "body": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
201+ },
202+ "location": {
203+ "column": 9,
204+ "file": "<root>/basic.test.ts",
205+ "line": 11,
206+ },
207+ "message": "with base64 body",
208+ "type": "notice",
209+ },
210+ {
211+ "attachment": {
212+ "body": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==",
213+ },
214+ "location": {
215+ "column": 9,
216+ "file": "<root>/basic.test.ts",
217+ "line": 12,
218+ },
219+ "message": "with Uint8Array body",
220+ "type": "notice",
221+ },
222+ {
223+ "attachment": {
224+ "body": "",
225+ "contentType": "text/plain",
226+ },
227+ "location": {
228+ "column": 9,
229+ "file": "<root>/basic.test.ts",
230+ "line": 13,
231+ },
232+ "message": "with contentType",
233+ "type": "notice",
234+ },
192235 ],
193236 }
194237 ` )
@@ -234,6 +277,9 @@ describe('reporters', () => {
234277 # notice: 3
235278 # warning: 4
236279 # notice: external
280+ # notice: with base64 body
281+ # notice: with Uint8Array body
282+ # notice: with contentType
237283 ok 2 - suite # time=<time> {
238284 1..1
239285 ok 1 - second # time=<time>
@@ -264,6 +310,9 @@ describe('reporters', () => {
264310 # notice: 3
265311 # warning: 4
266312 # notice: external
313+ # notice: with base64 body
314+ # notice: with Uint8Array body
315+ # notice: with contentType
267316 ok 2 - basic.test.ts > suite > second # time=<time>
268317 # notice: 5
269318 # notice: 6
@@ -302,6 +351,12 @@ describe('reporters', () => {
302351 </property>
303352 <property name="notice" value="external">
304353 </property>
354+ <property name="notice" value="with base64 body">
355+ </property>
356+ <property name="notice" value="with Uint8Array body">
357+ </property>
358+ <property name="notice" value="with contentType">
359+ </property>
305360 </properties>
306361 </testcase>
307362 <testcase classname="basic.test.ts" name="suite > second" time="0">
@@ -346,9 +401,15 @@ describe('reporters', () => {
346401
347402 ::notice file=<root>/basic.test.ts,line=10,column=9::external
348403
349- ::notice file=<root>/basic.test.ts,line=15,column=11::5
404+ ::notice file=<root>/basic.test.ts,line=11,column=9::with base64 body
405+
406+ ::notice file=<root>/basic.test.ts,line=12,column=9::with Uint8Array body
407+
408+ ::notice file=<root>/basic.test.ts,line=13,column=9::with contentType
409+
410+ ::notice file=<root>/basic.test.ts,line=18,column=11::5
350411
351- ::notice file=<root>/basic.test.ts,line=16 ,column=11::6
412+ ::notice file=<root>/basic.test.ts,line=19 ,column=11::6
352413 "
353414 ` )
354415 } )
@@ -383,12 +444,18 @@ describe('reporters', () => {
383444 ↳ 4
384445 ❯ basic.test.ts:10:9 notice
385446 ↳ external
447+ ❯ basic.test.ts:11:9 notice
448+ ↳ with base64 body
449+ ❯ basic.test.ts:12:9 notice
450+ ↳ with Uint8Array body
451+ ❯ basic.test.ts:13:9 notice
452+ ↳ with contentType
386453
387454 ✓ basic.test.ts > suite > second <time>
388455
389- ❯ basic.test.ts:15 :11 notice
456+ ❯ basic.test.ts:18 :11 notice
390457 ↳ 5
391- ❯ basic.test.ts:16 :11 notice
458+ ❯ basic.test.ts:19 :11 notice
392459 ↳ 6
393460
394461 "
0 commit comments