diff --git a/test/dictionary-data.write.js b/test/dictionary-data.write.js index 5599bfb986..0f6bbfcbcb 100644 --- a/test/dictionary-data.write.js +++ b/test/dictionary-data.write.js @@ -62,7 +62,7 @@ test('Write dictionary data expected data', async ({translator, ankiNoteDataCrea /** @type {import('translation').FindTermsOptions} */ const options = createFindOptions(dictionaryName, optionsPresets, data.options); const {dictionaryEntries, originalTextLength} = await translator.findTerms(mode, text, options); - const renderResults = mode !== 'simple' ? await getTemplateRenderResults(dictionaryEntries, 'terms', mode, template, expect) : null; + const renderResults = mode !== 'simple' ? await getTemplateRenderResults(dictionaryEntries, 'terms', mode, template, null) : null; const noteDataList = mode !== 'simple' ? dictionaryEntries.map((dictionaryEntry) => createTestAnkiNoteData(ankiNoteDataCreator, dictionaryEntry, mode)) : null; actualResults1.push({name, originalTextLength, dictionaryEntries}); actualResults2.push({name, noteDataList}); @@ -75,7 +75,7 @@ test('Write dictionary data expected data', async ({translator, ankiNoteDataCrea /** @type {import('translation').FindKanjiOptions} */ const options = createFindOptions(dictionaryName, optionsPresets, data.options); const dictionaryEntries = await translator.findKanji(text, options); - const renderResults = await getTemplateRenderResults(dictionaryEntries, 'kanji', 'split', template, expect); + const renderResults = await getTemplateRenderResults(dictionaryEntries, 'kanji', 'split', template, null); const noteDataList = dictionaryEntries.map((dictionaryEntry) => createTestAnkiNoteData(ankiNoteDataCreator, dictionaryEntry, 'split')); actualResults1.push({name, dictionaryEntries}); actualResults2.push({name, noteDataList}); diff --git a/test/utilities/anki.js b/test/utilities/anki.js index 1c57043504..4b73f6b90a 100644 --- a/test/utilities/anki.js +++ b/test/utilities/anki.js @@ -116,7 +116,7 @@ function getFieldMarkers(type) { * @param {'terms'|'kanji'} type * @param {import('settings').ResultOutputMode} mode * @param {string} template - * @param {import('vitest').ExpectStatic} expect + * @param {?import('vitest').ExpectStatic} expect * @returns {Promise} */ export async function getTemplateRenderResults(dictionaryEntries, type, mode, template, expect) { @@ -179,7 +179,9 @@ export async function getTemplateRenderResults(dictionaryEntries, type, mode, te for (const error of errors) { console.error(error); } - expect(errors.length).toStrictEqual(0); + if (expect !== null) { + expect(errors.length).toStrictEqual(0); + } results.push(noteFields); }