From dab8038d75c8cdee862f3f881930d26fa59cb7e1 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:27:13 +0700 Subject: [PATCH] chore: exclude dist files from coverage --- .c8rc.json | 2 +- packages/parse5/lib/parser/index.test.ts | 45 ++++++++++++------------ 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.c8rc.json b/.c8rc.json index c04ec035a..3aed2acbf 100644 --- a/.c8rc.json +++ b/.c8rc.json @@ -1,5 +1,5 @@ { "reporter": ["lcov"], "include": ["packages/**/*.ts"], - "exclude": ["**/*.test.ts"] + "exclude": ["**/*.test.ts", "packages/*/dist"] } diff --git a/packages/parse5/lib/parser/index.test.ts b/packages/parse5/lib/parser/index.test.ts index f86e97fb2..ddb69b985 100644 --- a/packages/parse5/lib/parser/index.test.ts +++ b/packages/parse5/lib/parser/index.test.ts @@ -116,35 +116,36 @@ describe('parser', () => { }); describe('rawtext parsing', () => { - it.each([ - ['iframe'], - ['noembed'], - ['noframes'], - ['noscript'], - ['script'], - ['style'], - ['textarea'], - ['title'], - ['xmp'], - ])('<%s>', (tagName) => { + const tagNames = [ + 'iframe', + 'noembed', + 'noframes', + 'noscript', + 'script', + 'style', + 'textarea', + 'title', + 'xmp', + ]; + for (const tagName of tagNames) { const html = `<${tagName}>`; const fragment = parseFragment(html); - expect(fragment.childNodes.length).toBe(1); + assert.equal(fragment.childNodes.length, 1); const r = fragment.childNodes[0] as Element; - expect(r.nodeName).toBe('r'); - expect(r.childNodes).toHaveLength(3); - expect(r.childNodes.map((_) => _.nodeName)).toEqual([tagName, 'b', '#text']); + assert.equal(r.nodeName, 'r'); + assert.equal(r.childNodes.length, 3); + assert.deepEqual(r.childNodes.map((_) => _.nodeName), [tagName, 'b', '#text']); const target = r.childNodes[0] as Element; - expect(target.childNodes).toHaveLength(1); - expect(target.childNodes[0].nodeName).toBe('#text'); - expect((target.childNodes[0] as TextNode).value).toBe('