From 799f9a17885e20a70f34bf03cf260512e58f23a9 Mon Sep 17 00:00:00 2001 From: yoho Date: Tue, 13 Dec 2022 16:14:26 +0800 Subject: [PATCH] feat: add mts, cts files to coverage (#2492) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: mts coverage * test: fix * fix: snapslot * docs: coverage * fix: snapslot * chore: update Co-authored-by: Ari Perkkiƶ * chore: reset Co-authored-by: Ari Perkkiƶ --- docs/config/index.md | 2 +- packages/vitest/src/defaults.ts | 2 +- .../__snapshots__/c8.report.test.ts.snap | 4 ++-- .../__snapshots__/istanbul.report.test.ts.snap | 4 ++-- .../coverage-report-tests/generic.report.test.ts | 2 +- test/coverage-test/src/{index.ts => index.mts} | 0 test/coverage-test/test/coverage.test.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) rename test/coverage-test/src/{index.ts => index.mts} (100%) diff --git a/docs/config/index.md b/docs/config/index.md index bb45d30e206a..a8d089e50792 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -534,7 +534,7 @@ List of files included in coverage as glob patterns #### extension - **Type:** `string | string[]` -- **Default:** `['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue', '.svelte']` +- **Default:** `['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts', '.tsx', '.jsx', '.vue', '.svelte']` - **Available for providers:** `'c8' | 'istanbul'` #### exclude diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index 2f2144c1f540..fa7be64ed08a 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -36,7 +36,7 @@ const coverageConfigDefaults = { allowExternal: false, // default extensions used by c8, plus '.vue' and '.svelte' // see https://github.com/istanbuljs/schema/blob/master/default-extension.js - extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue', '.svelte'], + extension: ['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts', '.tsx', '.jsx', '.vue', '.svelte'], } as ResolvedCoverageOptions export const fakeTimersDefaults = { diff --git a/test/coverage-test/coverage-report-tests/__snapshots__/c8.report.test.ts.snap b/test/coverage-test/coverage-report-tests/__snapshots__/c8.report.test.ts.snap index f176dbf905c3..2542914a37ee 100644 --- a/test/coverage-test/coverage-report-tests/__snapshots__/c8.report.test.ts.snap +++ b/test/coverage-test/coverage-report-tests/__snapshots__/c8.report.test.ts.snap @@ -1426,7 +1426,7 @@ exports[`c8 json report 1`] = ` }, }, }, - "/src/index.ts": { + "/src/index.mts": { "all": false, "b": { "0": [ @@ -1544,7 +1544,7 @@ exports[`c8 json report 1`] = ` "name": "get", }, }, - "path": "/src/index.ts", + "path": "/src/index.mts", "s": { "0": 1, "1": 1, diff --git a/test/coverage-test/coverage-report-tests/__snapshots__/istanbul.report.test.ts.snap b/test/coverage-test/coverage-report-tests/__snapshots__/istanbul.report.test.ts.snap index 772f7c45f5c1..721462d2ba83 100644 --- a/test/coverage-test/coverage-report-tests/__snapshots__/istanbul.report.test.ts.snap +++ b/test/coverage-test/coverage-report-tests/__snapshots__/istanbul.report.test.ts.snap @@ -580,7 +580,7 @@ exports[`istanbul json report 1`] = ` }, }, }, - "/src/index.ts": { + "/src/index.mts": { "b": {}, "branchMap": {}, "f": { @@ -611,7 +611,7 @@ exports[`istanbul json report 1`] = ` "name": "pythagoras", }, }, - "path": "/src/index.ts", + "path": "/src/index.mts", "s": { "0": 1, }, diff --git a/test/coverage-test/coverage-report-tests/generic.report.test.ts b/test/coverage-test/coverage-report-tests/generic.report.test.ts index eae5c9352dd5..1acae42d3464 100644 --- a/test/coverage-test/coverage-report-tests/generic.report.test.ts +++ b/test/coverage-test/coverage-report-tests/generic.report.test.ts @@ -11,7 +11,7 @@ test('html report', async () => { const files = fs.readdirSync(coveragePath) expect(files).toContain('index.html') - expect(files).toContain('index.ts.html') + expect(files).toContain('index.mts.html') expect(files).toContain('Hello.vue.html') }) diff --git a/test/coverage-test/src/index.ts b/test/coverage-test/src/index.mts similarity index 100% rename from test/coverage-test/src/index.ts rename to test/coverage-test/src/index.mts diff --git a/test/coverage-test/test/coverage.test.ts b/test/coverage-test/test/coverage.test.ts index 945b0b99167a..218547bf77ef 100644 --- a/test/coverage-test/test/coverage.test.ts +++ b/test/coverage-test/test/coverage.test.ts @@ -1,5 +1,5 @@ import { expect, test } from 'vitest' -import { pythagoras } from '../src' +import { pythagoras } from '../src/index.mjs' import { implicitElse } from '../src/implicitElse' import { useImportEnv } from '../src/importEnv'