Skip to content

Commit 3a881f3

Browse files
committed
test(coverage): improve coverage and generate badge
1 parent 549c635 commit 3a881f3

357 files changed

Lines changed: 25601 additions & 4580 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.config/vitest.config.mts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { fileURLToPath } from 'node:url'
22

3-
import type { UserConfig } from 'vitest/config'
4-
53
import { resolveSnapshotPath } from './snapshot-path.mts'
64

5+
import type { UserConfig } from 'vitest/config'
6+
77
export default {
88
root: fileURLToPath(new URL('../', import.meta.url)),
99
resolve: {
@@ -14,7 +14,7 @@ export default {
1414
// Keep the package unit lane scoped to this CLI. The checkout also contains
1515
// ignored upstream repositories and fleet tooling with independent deps and
1616
// Vitest configs; those are exercised by their own workflows.
17-
include: ['src/**/*.test.mts', 'test/**/*.test.mts'],
17+
include: ['test/unit/**/*.test.mts'],
1818
exclude: [
1919
'**/node_modules/**',
2020
'**/dist/**',
@@ -27,14 +27,10 @@ export default {
2727
'test/e2e/**',
2828
// Process-level CLI tests run in the serialized integration lane.
2929
'**/*.integration.test.mts',
30-
'src/commands/cli.test.mts',
31-
'src/commands/json/cmd-json.test.mts',
32-
'src/commands/manifest/cmd-manifest-auto.test.mts',
3330
// Native process tests require the explicitly built SEA artifact.
3431
'**/*.native.test.mts',
3532
// Termless requires Node 23.6+; these focused UI captures run in the Node 26 lane.
3633
'test/unit/lib/termless/animation.test.mts',
37-
'test/termless/**',
3834
'test/unit/lib/termless/svgo.test.mts',
3935
'test/unit/lib/native/cli-harness.test.mts',
4036
// Exclude test fixtures — directories like test/fixtures/commands/optimize/pnpm{8,9}/
@@ -45,6 +41,9 @@ export default {
4541
'upstream/**',
4642
],
4743
coverage: {
44+
reportsDirectory: 'coverage-unit',
45+
reporter: ['text', 'json', 'json-summary'],
46+
reportOnFailure: true,
4847
exclude: [
4948
'**/{eslint,vitest}.config.*',
5049
'**/node_modules/**',

‎.config/vitest.e2e.config.mts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { fileURLToPath } from 'node:url'
22

3-
import type { UserConfig } from 'vitest/config'
4-
53
import { resolveSnapshotPath } from './snapshot-path.mts'
64

5+
import type { UserConfig } from 'vitest/config'
6+
77
export default {
88
root: fileURLToPath(new URL('../', import.meta.url)),
99
resolve: {
@@ -14,7 +14,7 @@ export default {
1414
// Serialize test files to prevent concurrent npx --force invocations
1515
// from racing on the npm _npx cache directory.
1616
fileParallelism: false,
17-
include: ['**/*.e2e.test.mts'],
17+
include: ['test/e2e/**/*.e2e.test.mts'],
1818
exclude: [
1919
'**/node_modules/**',
2020
'**/dist/**',
@@ -23,6 +23,8 @@ export default {
2323
'**/.{idea,git,cache,output,temp}/**',
2424
],
2525
coverage: {
26+
reportsDirectory: 'coverage-e2e',
27+
include: ['src/**/*.mts'],
2628
exclude: [
2729
'**/{eslint,vitest}.config.*',
2830
'**/node_modules/**',
@@ -34,6 +36,7 @@ export default {
3436
'scripts/**',
3537
'src/**/types.mts',
3638
'test/**',
39+
'**/*.test.mts',
3740
],
3841
},
3942
},

‎.config/vitest.integration.config.mts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { fileURLToPath } from 'node:url'
22

3-
import type { UserConfig } from 'vitest/config'
4-
53
import { resolveSnapshotPath } from './snapshot-path.mts'
64

5+
import type { UserConfig } from 'vitest/config'
6+
77
export default {
88
root: fileURLToPath(new URL('../', import.meta.url)),
99
resolve: {
@@ -15,10 +15,11 @@ export default {
1515
// serial so they never mutate the same package-manager cache concurrently.
1616
fileParallelism: false,
1717
include: [
18-
'**/*.integration.test.mts',
19-
'src/commands/cli.test.mts',
20-
'src/commands/json/cmd-json.test.mts',
21-
'src/commands/manifest/cmd-manifest-auto.test.mts',
18+
'test/integration/**/*.integration.test.mts',
19+
'test/integration/**/*.constructed.test.mts',
20+
'test/integration/src/commands/cli.test.mts',
21+
'test/integration/src/commands/json/cmd-json.test.mts',
22+
'test/integration/src/commands/manifest/cmd-manifest-auto.test.mts',
2223
],
2324
exclude: [
2425
'**/node_modules/**',

‎.config/vitest.native.config.mts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { fileURLToPath } from 'node:url'
22

3-
import type { UserConfig } from 'vitest/config'
4-
53
import { resolveSnapshotPath } from './snapshot-path.mts'
64

5+
import type { UserConfig } from 'vitest/config'
6+
77
export default {
88
root: fileURLToPath(new URL('../', import.meta.url)),
99
resolve: {
@@ -17,11 +17,11 @@ export default {
1717
// The integration files already execute complete CLI processes through
1818
// spawnSocketCli, which switches to the SEA binary in this lane.
1919
include: [
20-
'**/*.native.test.mts',
21-
'**/*.integration.test.mts',
22-
'src/commands/cli.test.mts',
23-
'src/commands/json/cmd-json.test.mts',
24-
'src/commands/manifest/cmd-manifest-auto.test.mts',
20+
'test/integration/**/*.native.test.mts',
21+
'test/integration/**/*.integration.test.mts',
22+
'test/integration/src/commands/cli.test.mts',
23+
'test/integration/src/commands/json/cmd-json.test.mts',
24+
'test/integration/src/commands/manifest/cmd-manifest-auto.test.mts',
2525
],
2626
exclude: [
2727
'**/node_modules/**',

‎.config/vitest.terminal.config.mts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { fileURLToPath } from 'node:url'
22

3-
import type { UserConfig } from 'vitest/config'
4-
53
import { resolveSnapshotPath } from './snapshot-path.mts'
64

5+
import type { UserConfig } from 'vitest/config'
6+
77
export default {
88
root: fileURLToPath(new URL('../', import.meta.url)),
99
resolve: { preserveSymlinks: false },
@@ -15,7 +15,7 @@ export default {
1515
: {},
1616
include: [
1717
'test/e2e/termless.test.mts',
18-
'test/termless/**/*.test.mts',
18+
'test/e2e/src/utils/self-update.e2e.test.mts',
1919
'test/unit/lib/native/cli-harness.test.mts',
2020
'test/unit/lib/terminal/output.test.mts',
2121
'test/unit/lib/termless/animation.test.mts',

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
lint:
2727
name: 🧹 Lint Check
2828
runs-on: ubuntu-latest
29-
timeout-minutes: 10
29+
timeout-minutes: 20
3030
permissions:
3131
actions: write
3232
contents: read
@@ -285,7 +285,7 @@ jobs:
285285
286286
- name: Build for E2E tests
287287
if: matrix.suite == 'e2e'
288-
run: pnpm run build
288+
run: pnpm run build:dist:src
289289

290290
- name: Run E2E tests
291291
if: matrix.suite == 'e2e'
@@ -373,7 +373,7 @@ jobs:
373373
SFW_CUSTOM_REGISTRIES: 'bypass:bcr.bazel.build,bypass:release-assets.githubusercontent.com,bypass:repo.maven.apache.org,bypass:repo1.maven.org'
374374
run: |
375375
$PSNativeCommandUseErrorActionPreference = $true
376-
pnpm exec vitest run --config .config/vitest.e2e.config.mts src/commands/manifest/bazel/bazel-native.e2e.test.mts
376+
pnpm exec vitest run --config .config/vitest.e2e.config.mts test/e2e/src/commands/manifest/bazel/bazel-native.e2e.test.mts
377377
378378
- *cancel_workflow_on_failure
379379

@@ -492,7 +492,7 @@ jobs:
492492
export SOCKET_CLI_NATIVE_TEST_ARTIFACTS
493493
rm -rf "$SOCKET_CLI_NATIVE_TEST_ARTIFACTS"
494494
mkdir -p "$SOCKET_CLI_NATIVE_TEST_ARTIFACTS"
495-
pnpm run test:sea test/native/commands/cli.native.test.mts test/native/commands/cli-behavior.native.test.mts test/native/commands/tui.native.test.mts
495+
pnpm run test:sea test/integration/src/commands/cli.native.test.mts test/integration/src/commands/cli-behavior.native.test.mts test/integration/src/commands/tui.native.test.mts
496496
497497
- *cancel_workflow_on_failure
498498

‎.github/workflows/e2e-tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
run: pnpm install --loglevel error
6666

6767
- name: Build
68-
run: pnpm run build
68+
run: pnpm run build:dist:src
6969

7070
- name: Run e2e tests
7171
env:

‎.gitignore‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
!/patches/
3838
!/scripts/
3939
!/scripts/build-package-matrix.mts
40+
!/scripts/coverage-focused.mts
41+
!/scripts/estimate-coverage.mts
4042
!/scripts/babel/
4143
!/scripts/ci/
4244
!/scripts/lib/
@@ -369,7 +371,6 @@
369371
!/src/commands/ci/fetch-default-org-slug.test.mts
370372
!/src/commands/ci/handle-ci.mts
371373
!/src/commands/ci/handle-ci.test.mts
372-
!/src/commands/ci/handle-ci-skip.test.mts
373374
!/src/commands/ci/detect-ci-pull-request-context.test.mts
374375
!/src/commands/ci/select-baseline-scan.mts
375376
!/src/commands/ci/select-baseline-scan.test.mts
@@ -715,7 +716,6 @@
715716
!/src/commands/scan/output-delete-scan.mts
716717
!/src/commands/scan/output-diff-scan.mts
717718
!/src/commands/scan/python-diff-json.mts
718-
!/src/commands/scan/python-diff-json.test.mts
719719
!/src/commands/scan/output-diff-scan.test.mts
720720
!/src/commands/scan/output-list-scans.mts
721721
!/src/commands/scan/output-scan-config-result.mts
@@ -862,6 +862,7 @@
862862
!/src/utils/config.test.mts
863863
!/src/utils/cve-to-ghsa.mts
864864
!/src/utils/debug.mts
865+
!/src/utils/debug.test.mts
865866
!/src/utils/determine-org-slug.mts
866867
!/src/utils/dlx-detection.mts
867868
!/src/utils/dlx.mts
@@ -886,17 +887,12 @@
886887
!/src/utils/github.mts
887888
!/src/utils/gitlab.mts
888889
!/src/commands/ci/gitlab-commit-status-context.mts
889-
!/src/commands/ci/gitlab-commit-status-context.test.mts
890890
!/src/commands/ci/publish-gitlab-commit-status.mts
891-
!/src/commands/ci/publish-gitlab-commit-status.test.mts
892891
!/src/commands/scan/diff-scan-verdict.mts
893-
!/src/commands/scan/diff-scan-verdict.test.mts
894892
!/src/commands/ci/publish-gitlab-mr-notes.mts
895-
!/src/commands/ci/publish-gitlab-mr-notes.test.mts
896893
!/src/commands/ci/publish-pr-comments.mts
897894
!/src/commands/ci/publish-pr-comments.test.mts
898895
!/src/commands/ci/skip-unchanged-manifests.mts
899-
!/src/commands/ci/skip-unchanged-manifests.test.mts
900896
!/src/utils/glob-content-dedup.test.mts
901897
!/src/utils/glob.mts
902898
!/src/utils/glob.test.mts
@@ -983,6 +979,7 @@
983979
/coverage/
984980
/coverage-e2e/
985981
/coverage-unit/
982+
/coverage-granular/
986983
/external/
987984
**/.cache/
988985
**/dist/

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Socket CLI
22

33
[![Socket Badge](https://socket.dev/api/badge/npm/package/socket)](https://socket.dev/npm/package/socket)
4+
<!-- coverage-badge:start -->
5+
[![Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen)](https://github.com/SocketDev/socket-cli/actions)
6+
<!-- coverage-badge:end -->
47
[![Follow @SocketSecurity](assets/fleet/badge-follow-x.svg)](https://twitter.com/SocketSecurity)
58
[![Follow @socket.dev on Bluesky](assets/fleet/badge-follow-bluesky.svg)](https://bsky.app/profile/socket.dev)
69

‎eslint.config.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ module.exports = [
227227
'src/*/*/*.test.mts',
228228
// Allow paths like src/commands/manifest/bazel/*.test.mts.
229229
'src/*/*/*/*.test.mts',
230+
// Allow scenario tests mirrored across test/unit, test/e2e, and
231+
// test/integration, including deeper source and script paths.
232+
'test/*/*.test.mts',
233+
'test/*/*/*.test.mts',
234+
'test/*/*/*/*.test.mts',
235+
'test/*/*/*/*/*.test.mts',
236+
'test/*/*/*/*/*/*.test.mts',
237+
'test/*/*/*/*/*/*/*.test.mts',
238+
'test/*/*/*/*/*/*/*/*.test.mts',
230239
'test/patches/*.test.mts',
231240
'test/unit/*.test.mts',
232241
'test/*.mts',

0 commit comments

Comments
 (0)