@smoothbricks/nx-plugin 0.4.26 → 0.4.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +994 -117
- package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-bound-failures.js +31 -0
- package/dist/bin/smoo-nx-cargo-hash.js +28 -3
- package/dist/bin/smoo-nx-exec.js +15 -73
- package/dist/bin/smoo-nx-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-failures.js +3 -0
- package/dist/bin/smoo-nx-nextest-extract.js +3 -2
- package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-walks.js +34 -0
- package/dist/bounded-test-policy.d.ts +7 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +101 -40
- package/dist/build-state-output-policy.d.ts +25 -0
- package/dist/build-state-output-policy.d.ts.map +1 -0
- package/dist/build-state-output-policy.js +64 -0
- package/dist/cargo-closure-input.d.ts +3 -2
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +16 -15
- package/dist/cargo-dev-profile.d.ts +37 -0
- package/dist/cargo-dev-profile.d.ts.map +1 -0
- package/dist/cargo-dev-profile.js +108 -0
- package/dist/cargo-source-hash.d.ts +43 -6
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +309 -73
- package/dist/cargo-toolchain-policy.d.ts +4 -0
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +5 -0
- package/dist/cargo-workspace.d.ts +101 -5
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +291 -10
- package/dist/cross-check-policy.d.ts +21 -3
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +24 -6
- package/dist/disk-command-policy.d.ts +7 -0
- package/dist/disk-command-policy.d.ts.map +1 -0
- package/dist/disk-command-policy.js +98 -0
- package/dist/ensure-built-receipt.d.ts +25 -0
- package/dist/ensure-built-receipt.d.ts.map +1 -0
- package/dist/ensure-built-receipt.js +261 -0
- package/dist/ensure-built-witness.d.ts +57 -0
- package/dist/ensure-built-witness.d.ts.map +1 -0
- package/dist/ensure-built-witness.js +412 -0
- package/dist/ensure-built.d.ts +207 -12
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +576 -202
- package/dist/eslint-file-set.d.ts +7 -0
- package/dist/eslint-file-set.d.ts.map +1 -0
- package/dist/eslint-file-set.js +12 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-pool.js +379 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/disk-lease.js +91 -0
- package/dist/executors/bounded-exec/executor.d.ts +45 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +447 -52
- package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/gateway-lease.js +143 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
- package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
- package/dist/executors/bounded-exec/progress.d.ts +35 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress.js +79 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp.js +1528 -0
- package/dist/executors/bounded-exec/schema.d.ts +29 -11
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +162 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
- package/dist/executors/bounded-exec/verdict.js +318 -0
- package/dist/executors/shard-timings/executor.d.ts +14 -0
- package/dist/executors/shard-timings/executor.d.ts.map +1 -0
- package/dist/executors/shard-timings/executor.js +25 -0
- package/dist/executors/shard-timings/schema.d.ts +4 -0
- package/dist/executors/shard-timings/schema.d.ts.map +1 -0
- package/dist/executors/shard-timings/schema.js +1 -0
- package/dist/failure-summary.d.ts +5 -0
- package/dist/failure-summary.d.ts.map +1 -0
- package/dist/failure-summary.js +118 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +6 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +370 -138
- package/dist/managed-files/ci-workflow.d.ts +13 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +44 -13
- package/dist/managed-files/files.d.ts +7 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +62 -8
- package/dist/managed-files/json-edit.d.ts +21 -0
- package/dist/managed-files/json-edit.d.ts.map +1 -0
- package/dist/managed-files/json-edit.js +295 -0
- package/dist/managed-files/managed-format.d.ts +33 -1
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +82 -2
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
- package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/managed-files/publish-workflow.js +231 -48
- package/dist/managed-files/tree.d.ts +5 -0
- package/dist/managed-files/tree.d.ts.map +1 -1
- package/dist/managed-files/tree.js +5 -3
- package/dist/manifest-hash.d.ts.map +1 -1
- package/dist/manifest-hash.js +2 -5
- package/dist/nextest-code-bound.d.ts +62 -0
- package/dist/nextest-code-bound.d.ts.map +1 -0
- package/dist/nextest-code-bound.js +154 -0
- package/dist/nextest-extraction.d.ts +24 -8
- package/dist/nextest-extraction.d.ts.map +1 -1
- package/dist/nextest-extraction.js +42 -7
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +3 -5
- package/dist/release-config-policy.d.ts.map +1 -1
- package/dist/release-config-policy.js +3 -5
- package/dist/runtime-input.d.ts +14 -0
- package/dist/runtime-input.d.ts.map +1 -0
- package/dist/runtime-input.js +15 -0
- package/dist/rust-tokens.d.ts +11 -0
- package/dist/rust-tokens.d.ts.map +1 -0
- package/dist/rust-tokens.js +81 -0
- package/dist/task-results.d.ts +6 -0
- package/dist/task-results.d.ts.map +1 -0
- package/dist/task-results.js +61 -0
- package/dist/test-program.d.ts +54 -0
- package/dist/test-program.d.ts.map +1 -0
- package/dist/test-program.js +292 -0
- package/dist/test-timings.d.ts +71 -0
- package/dist/test-timings.d.ts.map +1 -0
- package/dist/test-timings.js +393 -0
- package/dist/test-walk-policy.d.ts +103 -0
- package/dist/test-walk-policy.d.ts.map +1 -0
- package/dist/test-walk-policy.js +657 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +824 -0
- package/dist/type-guards.d.ts +3 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/type-guards.js +4 -0
- package/dist/typecheck-test-policy.d.ts +8 -5
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +113 -100
- package/dist/workspace-config-policy.d.ts +8 -0
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +175 -63
- package/dist/workspace-index.d.ts +12 -0
- package/dist/workspace-index.d.ts.map +1 -0
- package/dist/workspace-index.js +17 -0
- package/dist/workspace-manifest.d.ts +37 -0
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/executors.json +5 -0
- package/loader.js +13 -11
- package/managed/raw/envrc +33 -67
- package/managed/raw/git-format-staged.yml +30 -35
- package/managed/raw/patches/nx@23.2.1.patch +3484 -0
- package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
- package/managed/raw/tooling/direnv/developer-links.ts +569 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
- package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
- package/managed/raw/tooling/direnv/repo-path +14 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +1146 -159
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
- package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
- package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
- package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
- package/managed/templates/github/actions/cache-nx/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
- package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
- package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
- package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
- package/managed/templates/github/workflows/managed-files.yml +1 -2
- package/nextest.toml +8 -41
- package/package.json +74 -12
- package/runtime-input.sh +81 -0
- package/src/__tests__/counted-cargo.ts +33 -14
- package/src/__tests__/fixture-nx-env.ts +111 -46
- package/src/__tests__/progress-clock.ts +43 -0
- package/src/__tests__/runtime-input.ts +23 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
- package/src/bin/smoo-nx-bound-failures.ts +33 -0
- package/src/bin/smoo-nx-cargo-hash.ts +28 -3
- package/src/bin/smoo-nx-exec.ts +16 -74
- package/src/bin/smoo-nx-failures.ts +4 -0
- package/src/bin/smoo-nx-nextest-extract.ts +3 -2
- package/src/bin/smoo-nx-test-walks.ts +42 -0
- package/src/bounded-test-policy.test.ts +268 -21
- package/src/bounded-test-policy.ts +114 -42
- package/src/build-state-output-policy.test.ts +115 -0
- package/src/build-state-output-policy.ts +90 -0
- package/src/bun-bootstrap.test.ts +57 -3
- package/src/bun-file-packages.test.ts +47 -0
- package/src/cargo-closure-input.test.ts +138 -66
- package/src/cargo-closure-input.ts +17 -15
- package/src/cargo-dev-profile.ts +137 -0
- package/src/cargo-resolve-cache.test.ts +70 -1
- package/src/cargo-source-hash.test.ts +193 -97
- package/src/cargo-source-hash.ts +345 -68
- package/src/cargo-toolchain-policy.ts +6 -0
- package/src/cargo-workspace.test.ts +320 -0
- package/src/cargo-workspace.ts +336 -10
- package/src/cross-check-policy.test.ts +59 -1
- package/src/cross-check-policy.ts +25 -6
- package/src/disk-command-policy.test.ts +61 -0
- package/src/disk-command-policy.ts +107 -0
- package/src/ensure-built-receipt.test.ts +184 -0
- package/src/ensure-built-receipt.ts +263 -0
- package/src/ensure-built-witness.test.ts +344 -0
- package/src/ensure-built-witness.ts +252 -0
- package/src/ensure-built.test.ts +1036 -578
- package/src/ensure-built.ts +820 -224
- package/src/eslint-file-set.ts +9 -0
- package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
- package/src/executors/bounded-exec/cpu-pool.ts +417 -0
- package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
- package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
- package/src/executors/bounded-exec/disk-lease.ts +139 -0
- package/src/executors/bounded-exec/executor-host.test.ts +778 -0
- package/src/executors/bounded-exec/executor.test.ts +1116 -63
- package/src/executors/bounded-exec/executor.ts +565 -67
- package/src/executors/bounded-exec/gateway-lease.ts +176 -0
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
- package/src/executors/bounded-exec/progress.test.ts +79 -0
- package/src/executors/bounded-exec/progress.ts +118 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
- package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
- package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
- package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
- package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
- package/src/executors/bounded-exec/ram-temp.ts +1918 -0
- package/src/executors/bounded-exec/schema.json +11 -5
- package/src/executors/bounded-exec/schema.ts +27 -11
- package/src/executors/bounded-exec/verdict.test.ts +440 -0
- package/src/executors/bounded-exec/verdict.ts +433 -0
- package/src/executors/shard-timings/executor.ts +36 -0
- package/src/executors/shard-timings/schema.json +21 -0
- package/src/executors/shard-timings/schema.ts +4 -0
- package/src/failure-summary.ts +119 -0
- package/src/generators/bounded-test-targets/generator.test.ts +4 -4
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/create-package/generator.test.ts +6 -0
- package/src/generators/create-package/generator.ts +6 -2
- package/src/host-controller-wiring.test.ts +31 -0
- package/src/index.test.ts +909 -295
- package/src/index.ts +441 -143
- package/src/linked-snapshots.nx.test.ts +172 -0
- package/src/managed-files/ci-workflow.ts +54 -13
- package/src/managed-files/files.ts +65 -9
- package/src/managed-files/forgejo-artifact.test.ts +395 -0
- package/src/managed-files/generator.test.ts +60 -1
- package/src/managed-files/json-edit.test.ts +216 -0
- package/src/managed-files/json-edit.ts +290 -0
- package/src/managed-files/managed-format-json.test.ts +308 -0
- package/src/managed-files/managed-format.ts +90 -2
- package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
- package/src/managed-files/publish-workflow.ts +285 -67
- package/src/managed-files/repo-path.test.ts +129 -0
- package/src/managed-files/trace-db-artifact.test.ts +7 -0
- package/src/managed-files/tree.ts +11 -3
- package/src/manifest-hash.ts +2 -6
- package/src/nextest-code-bound.test.ts +155 -0
- package/src/nextest-code-bound.ts +195 -0
- package/src/nextest-extraction.test.ts +37 -5
- package/src/nextest-extraction.ts +51 -9
- package/src/nextest-partitions.test.ts +427 -82
- package/src/nx-cache-bound.test.ts +5 -10
- package/src/nx-cache-restore-mtime.test.ts +170 -0
- package/src/nx-daemon-claim.test.ts +277 -0
- package/src/nx-daemon-idle-cpu.test.ts +81 -0
- package/src/nx-daemon-idle-policy.test.ts +51 -0
- package/src/nx-daemon-ignore-files.test.ts +210 -0
- package/src/nx-daemon-root-normalization.test.ts +105 -0
- package/src/nx-daemon-validity.test.ts +925 -0
- package/src/nx-dot-input-policy.test.ts +353 -0
- package/src/nx-failure-life-cycles.test.ts +207 -0
- package/src/nx-files-archive-racy.test.ts +97 -0
- package/src/nx-foreign-workspace-env.test.ts +329 -0
- package/src/nx-incomplete-run-summary.test.ts +70 -0
- package/src/nx-plugin-load-errors.test.ts +120 -0
- package/src/nx-project-resolution-cache.test.ts +176 -0
- package/src/nx-raw-inputs.test.ts +166 -0
- package/src/nx-resident-graph-workers.test.ts +7 -16
- package/src/nx-run-information.test.ts +118 -0
- package/src/nx-skipped-task-exit.test.ts +180 -0
- package/src/nx-state-location.test.ts +63 -0
- package/src/nx-store-resolution.test.ts +26 -25
- package/src/nx-task-graph-cycles.test.ts +148 -0
- package/src/nx-task-output-lease.test.ts +414 -0
- package/src/nx-use-local.test.ts +103 -0
- package/src/package-target-policy.ts +3 -6
- package/src/release-config-policy.ts +3 -6
- package/src/runtime-input.test.ts +215 -0
- package/src/runtime-input.ts +17 -0
- package/src/rust-tokens.ts +78 -0
- package/src/serial-group-wiring.test.ts +326 -0
- package/src/task-history-namespace.test.ts +87 -89
- package/src/task-results.test.ts +226 -0
- package/src/task-results.ts +75 -0
- package/src/test-program.test.ts +303 -0
- package/src/test-program.ts +341 -0
- package/src/test-timings.test.ts +240 -0
- package/src/test-timings.ts +311 -0
- package/src/test-walk-policy.test.ts +585 -0
- package/src/test-walk-policy.ts +731 -0
- package/src/testing.test.ts +509 -0
- package/src/testing.ts +922 -0
- package/src/type-guards.ts +4 -0
- package/src/typecheck-test-policy.test.ts +496 -11
- package/src/typecheck-test-policy.ts +137 -103
- package/src/workspace-config-policy.test.ts +212 -13
- package/src/workspace-config-policy.ts +101 -73
- package/src/workspace-index.ts +18 -0
- package/src/workspace-manifest.ts +41 -0
- package/test-timings.json +85 -30
- package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
- package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
|
|
6
|
-
import { addProjectConfiguration, readJson, type Tree, writeJson } from 'nx/src/devkit-exports.js';
|
|
6
|
+
import { addProjectConfiguration, parseJson, readJson, type Tree, writeJson } from 'nx/src/devkit-exports.js';
|
|
7
7
|
import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports.js';
|
|
8
8
|
import { FsTree, flushChanges } from 'nx/src/generators/tree.js';
|
|
9
9
|
import { inspectManagedPaths } from './managed-files/paths.js';
|
|
10
10
|
import { assertNoManagedConflicts, stageManagedFiles } from './managed-files/tree.js';
|
|
11
|
+
import type { TestProgram } from './test-program.js';
|
|
11
12
|
|
|
12
13
|
import {
|
|
13
14
|
applyTypecheckTestDefaults,
|
|
@@ -199,11 +200,15 @@ describe('checkTsconfigTestReference', () => {
|
|
|
199
200
|
});
|
|
200
201
|
|
|
201
202
|
describe('applyTypecheckTestDefaults', () => {
|
|
203
|
+
const program: TestProgram = { projectRoot: 'packages/app', files: ['src/app.test.ts'], readConfig: () => null };
|
|
204
|
+
|
|
202
205
|
it('applies all defaults to empty object', () => {
|
|
203
206
|
const tsconfigTest: Record<string, unknown> = {};
|
|
204
207
|
const changed = applyTypecheckTestDefaults(tsconfigTest, {
|
|
205
208
|
testRunners: new Set(['bun'] as const),
|
|
209
|
+
testExtends: '../../tsconfig.base.json',
|
|
206
210
|
referencePaths: ['./tsconfig.lib.json'],
|
|
211
|
+
program,
|
|
207
212
|
isNew: true,
|
|
208
213
|
});
|
|
209
214
|
expect(changed).toBe(true);
|
|
@@ -231,13 +236,24 @@ describe('applyTypecheckTestDefaults', () => {
|
|
|
231
236
|
// that with a program of zero files, which passed the gate by compiling
|
|
232
237
|
// nothing (the false green the policy exists to prevent).
|
|
233
238
|
const declared: Record<string, unknown> = { extends: './tsconfig.json', compilerOptions: { noEmit: true } };
|
|
234
|
-
applyTypecheckTestDefaults(declared, {
|
|
239
|
+
applyTypecheckTestDefaults(declared, {
|
|
240
|
+
testRunners: new Set(['bun'] as const),
|
|
241
|
+
testExtends: '../../tsconfig.base.json',
|
|
242
|
+
referencePaths: [],
|
|
243
|
+
program,
|
|
244
|
+
});
|
|
245
|
+
expect(declared.extends).toBe('./tsconfig.json');
|
|
235
246
|
expect(Object.hasOwn(declared, 'include')).toBe(false);
|
|
236
247
|
// Same for `types`: declaring it would drop the workers types the program inherits.
|
|
237
248
|
expect(Object.hasOwn(expectRecord(declared.compilerOptions), 'types')).toBe(false);
|
|
238
249
|
|
|
239
250
|
const explicit: Record<string, unknown> = { extends: './tsconfig.json', include: ['test/**/*.ts'] };
|
|
240
|
-
applyTypecheckTestDefaults(explicit, {
|
|
251
|
+
applyTypecheckTestDefaults(explicit, {
|
|
252
|
+
testRunners: new Set(['bun'] as const),
|
|
253
|
+
testExtends: '../../tsconfig.base.json',
|
|
254
|
+
referencePaths: [],
|
|
255
|
+
program,
|
|
256
|
+
});
|
|
241
257
|
expect(expectStringArray(explicit.include)).toEqual(expect.arrayContaining(['test/**/*.ts', 'src/**/*.test.ts']));
|
|
242
258
|
});
|
|
243
259
|
|
|
@@ -251,7 +267,9 @@ describe('applyTypecheckTestDefaults', () => {
|
|
|
251
267
|
};
|
|
252
268
|
applyTypecheckTestDefaults(declared, {
|
|
253
269
|
testRunners: new Set(['bun'] as const),
|
|
270
|
+
testExtends: '../../tsconfig.base.json',
|
|
254
271
|
referencePaths: [],
|
|
272
|
+
program,
|
|
255
273
|
libCompilerOptions: { lib: ['es2022'], module: 'preserve' },
|
|
256
274
|
});
|
|
257
275
|
|
|
@@ -262,18 +280,21 @@ describe('applyTypecheckTestDefaults', () => {
|
|
|
262
280
|
const silent: Record<string, unknown> = { compilerOptions: {} };
|
|
263
281
|
applyTypecheckTestDefaults(silent, {
|
|
264
282
|
testRunners: new Set(['bun'] as const),
|
|
283
|
+
testExtends: '../../tsconfig.base.json',
|
|
265
284
|
referencePaths: [],
|
|
285
|
+
program,
|
|
266
286
|
libCompilerOptions: { lib: ['es2022'] },
|
|
267
287
|
});
|
|
268
288
|
expect(expectRecord(silent.compilerOptions).lib).toEqual(['es2022']);
|
|
269
289
|
});
|
|
270
290
|
|
|
271
|
-
it('
|
|
291
|
+
it('extends what it is given when the file names nothing', () => {
|
|
272
292
|
const tsconfigTest: Record<string, unknown> = {};
|
|
273
293
|
applyTypecheckTestDefaults(tsconfigTest, {
|
|
274
294
|
testRunners: new Set(['bun'] as const),
|
|
275
|
-
|
|
295
|
+
testExtends: '../tsconfig.custom.json',
|
|
276
296
|
referencePaths: [],
|
|
297
|
+
program,
|
|
277
298
|
});
|
|
278
299
|
expect(tsconfigTest.extends).toBe('../tsconfig.custom.json');
|
|
279
300
|
});
|
|
@@ -282,8 +303,10 @@ describe('applyTypecheckTestDefaults', () => {
|
|
|
282
303
|
const tsconfigTest: Record<string, unknown> = {};
|
|
283
304
|
applyTypecheckTestDefaults(tsconfigTest, {
|
|
284
305
|
testRunners: new Set(['bun'] as const),
|
|
306
|
+
testExtends: '../../tsconfig.base.json',
|
|
285
307
|
libCompilerOptions: { baseUrl: '.', module: 'esnext', jsx: 'react-jsx' },
|
|
286
308
|
referencePaths: [],
|
|
309
|
+
program,
|
|
287
310
|
});
|
|
288
311
|
const compilerOptions = expectRecord(tsconfigTest.compilerOptions);
|
|
289
312
|
expect(compilerOptions.baseUrl).toBe('.');
|
|
@@ -295,7 +318,9 @@ describe('applyTypecheckTestDefaults', () => {
|
|
|
295
318
|
const tsconfigTest: Record<string, unknown> = {};
|
|
296
319
|
applyTypecheckTestDefaults(tsconfigTest, {
|
|
297
320
|
testRunners: new Set(['vitest'] as const),
|
|
321
|
+
testExtends: '../../tsconfig.base.json',
|
|
298
322
|
referencePaths: [],
|
|
323
|
+
program,
|
|
299
324
|
});
|
|
300
325
|
const compilerOptions = expectRecord(tsconfigTest.compilerOptions);
|
|
301
326
|
expect(compilerOptions.types).toBeUndefined();
|
|
@@ -307,7 +332,9 @@ describe('applyTypecheckTestDefaults', () => {
|
|
|
307
332
|
};
|
|
308
333
|
const changed = applyTypecheckTestDefaults(tsconfigTest, {
|
|
309
334
|
testRunners: new Set(['bun'] as const),
|
|
335
|
+
testExtends: '../../tsconfig.base.json',
|
|
310
336
|
referencePaths: [],
|
|
337
|
+
program,
|
|
311
338
|
});
|
|
312
339
|
expect(changed).toBe(true);
|
|
313
340
|
const compilerOptions = expectRecord(tsconfigTest.compilerOptions);
|
|
@@ -319,8 +346,10 @@ describe('applyTypecheckTestDefaults', () => {
|
|
|
319
346
|
const tsconfigTest: Record<string, unknown> = {};
|
|
320
347
|
const opts = {
|
|
321
348
|
testRunners: new Set(['bun'] as const),
|
|
349
|
+
testExtends: '../../tsconfig.base.json',
|
|
322
350
|
libCompilerOptions: { lib: ['es2024', 'webworker'] },
|
|
323
351
|
referencePaths: ['./tsconfig.lib.json'],
|
|
352
|
+
program,
|
|
324
353
|
};
|
|
325
354
|
applyTypecheckTestDefaults(tsconfigTest, opts);
|
|
326
355
|
const secondChanged = applyTypecheckTestDefaults(tsconfigTest, opts);
|
|
@@ -333,20 +362,22 @@ describe('removeTsconfigTestReference', () => {
|
|
|
333
362
|
const tsconfig: Record<string, unknown> = {
|
|
334
363
|
references: [{ path: './tsconfig.lib.json' }, { path: './tsconfig.test.json' }],
|
|
335
364
|
};
|
|
336
|
-
|
|
365
|
+
removeTsconfigTestReference(tsconfig);
|
|
337
366
|
expect(tsconfig.references).toEqual([{ path: './tsconfig.lib.json' }]);
|
|
338
367
|
});
|
|
339
368
|
|
|
340
|
-
it('
|
|
369
|
+
it('leaves a document with no test reference as it was', () => {
|
|
341
370
|
const tsconfig: Record<string, unknown> = {
|
|
342
371
|
references: [{ path: './tsconfig.lib.json' }],
|
|
343
372
|
};
|
|
344
|
-
|
|
373
|
+
removeTsconfigTestReference(tsconfig);
|
|
374
|
+
expect(tsconfig).toEqual({ references: [{ path: './tsconfig.lib.json' }] });
|
|
345
375
|
});
|
|
346
376
|
|
|
347
|
-
it('
|
|
377
|
+
it('does not invent a references list', () => {
|
|
348
378
|
const tsconfig: Record<string, unknown> = {};
|
|
349
|
-
|
|
379
|
+
removeTsconfigTestReference(tsconfig);
|
|
380
|
+
expect(tsconfig).toEqual({});
|
|
350
381
|
});
|
|
351
382
|
});
|
|
352
383
|
|
|
@@ -370,6 +401,7 @@ describe('typecheck test policy (Tree)', () => {
|
|
|
370
401
|
compilerOptions: { composite: true, baseUrl: '.', rootDir: 'src', outDir: 'dist' },
|
|
371
402
|
});
|
|
372
403
|
|
|
404
|
+
tree.write('packages/app/src/app.test.ts', 'export {};\n');
|
|
373
405
|
const changed = applyTypecheckTestPolicyTree(tree);
|
|
374
406
|
expect(changed).toBe(true);
|
|
375
407
|
|
|
@@ -389,6 +421,28 @@ describe('typecheck test policy (Tree)', () => {
|
|
|
389
421
|
expect(references).toContainEqual({ path: './tsconfig.lib.json' });
|
|
390
422
|
});
|
|
391
423
|
|
|
424
|
+
it('extends the workspace base from the project root when there is no lib program', () => {
|
|
425
|
+
// `tooling` sits one level below the workspace root. A fixed
|
|
426
|
+
// '../../tsconfig.base.json' named a file above the repository.
|
|
427
|
+
const tree = createTreeWithEmptyWorkspace();
|
|
428
|
+
for (const [name, root] of [
|
|
429
|
+
['tooling', 'tooling'],
|
|
430
|
+
['app', 'packages/app'],
|
|
431
|
+
] as const) {
|
|
432
|
+
addProjectConfiguration(tree, name, { root, targets: {} });
|
|
433
|
+
if (tree.exists(`${root}/project.json`)) tree.delete(`${root}/project.json`);
|
|
434
|
+
writeJson(tree, `${root}/package.json`, { name: `@scope/${name}`, scripts: { test: 'bun test' }, nx: { name } });
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
tree.write('tooling/src/tooling.test.ts', 'export {};\n');
|
|
438
|
+
tree.write('packages/app/src/app.test.ts', 'export {};\n');
|
|
439
|
+
applyTypecheckTestPolicyTree(tree);
|
|
440
|
+
expect(readJson<Record<string, unknown>>(tree, 'tooling/tsconfig.test.json').extends).toBe('../tsconfig.base.json');
|
|
441
|
+
expect(readJson<Record<string, unknown>>(tree, 'packages/app/tsconfig.test.json').extends).toBe(
|
|
442
|
+
'../../tsconfig.base.json',
|
|
443
|
+
);
|
|
444
|
+
});
|
|
445
|
+
|
|
392
446
|
it('references only composite lib programs (TS6306 otherwise), resolving composite through extends', () => {
|
|
393
447
|
const tree = createTreeWithEmptyWorkspace();
|
|
394
448
|
writeJson(tree, 'tsconfig.composite.json', { compilerOptions: { composite: true } });
|
|
@@ -412,6 +466,9 @@ describe('typecheck test policy (Tree)', () => {
|
|
|
412
466
|
});
|
|
413
467
|
}
|
|
414
468
|
|
|
469
|
+
for (const name of ['app', 'lib', 'inherits']) {
|
|
470
|
+
tree.write(`packages/${name}/src/${name}.test.ts`, 'export {};\n');
|
|
471
|
+
}
|
|
415
472
|
applyTypecheckTestPolicyTree(tree);
|
|
416
473
|
const references = expectReferences(
|
|
417
474
|
readJson<Record<string, unknown>>(tree, 'packages/app/tsconfig.test.json').references,
|
|
@@ -521,6 +578,7 @@ describe('typecheck test policy (Tree)', () => {
|
|
|
521
578
|
references: [{ path: './tsconfig.lib.json' }, { path: './tsconfig.test.json' }],
|
|
522
579
|
});
|
|
523
580
|
|
|
581
|
+
tree.write('packages/app/src/app.test.ts', 'export {};\n');
|
|
524
582
|
const changed = applyTypecheckTestPolicyTree(tree);
|
|
525
583
|
expect(changed).toBe(true);
|
|
526
584
|
|
|
@@ -579,6 +637,7 @@ describe('typecheck test policy (Tree)', () => {
|
|
|
579
637
|
compilerOptions: { composite: true },
|
|
580
638
|
});
|
|
581
639
|
|
|
640
|
+
tree.write('packages/app/src/app.test.ts', 'export {};\n');
|
|
582
641
|
expect(applyTypecheckTestPolicyTree(tree)).toBe(true);
|
|
583
642
|
|
|
584
643
|
const tsconfig = readJson<Record<string, unknown>>(tree, 'packages/app/tsconfig.test.json');
|
|
@@ -629,6 +688,110 @@ describe('typecheck test policy', () => {
|
|
|
629
688
|
}
|
|
630
689
|
});
|
|
631
690
|
|
|
691
|
+
describe('a documented config that drifts from the policy', () => {
|
|
692
|
+
const BIOME_SPACES = '{"formatter":{"indentStyle":"space","indentWidth":2,"lineWidth":120}}\n';
|
|
693
|
+
|
|
694
|
+
/** An app that depends on a composite lib, so the policy wants a reference its tsconfig.test.json lacks. */
|
|
695
|
+
async function appWithCompositeDependency(root: string): Promise<void> {
|
|
696
|
+
await writeFile(join(root, 'biome.json'), BIOME_SPACES);
|
|
697
|
+
await writeJsonFs(join(root, 'package.json'), { workspaces: ['packages/*'] });
|
|
698
|
+
await writeJsonFs(join(root, 'tsconfig.base.json'), { compilerOptions: { composite: true } });
|
|
699
|
+
await writeJsonFs(join(root, 'packages/lib/package.json'), { name: '@scope/lib' });
|
|
700
|
+
await writeJsonFs(join(root, 'packages/lib/tsconfig.lib.json'), { extends: '../../tsconfig.base.json' });
|
|
701
|
+
await writeJsonFs(join(root, 'packages/app/package.json'), {
|
|
702
|
+
name: '@scope/app',
|
|
703
|
+
scripts: { test: 'bun test' },
|
|
704
|
+
dependencies: { '@scope/lib': 'workspace:*' },
|
|
705
|
+
});
|
|
706
|
+
// The program extends it, so the policy can read what the program selects through it.
|
|
707
|
+
await writeJsonFs(join(root, 'packages/app/tsconfig.json'), { extends: '../../tsconfig.base.json' });
|
|
708
|
+
await writeSource(join(root, 'packages/app/scripts/app.test.ts'));
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
const documented = [
|
|
712
|
+
'{',
|
|
713
|
+
" // WHY the program extends the package's own config: these are Bun programs.",
|
|
714
|
+
' "extends": "./tsconfig.json",',
|
|
715
|
+
' "compilerOptions": {',
|
|
716
|
+
' "composite": false,',
|
|
717
|
+
' "declaration": false,',
|
|
718
|
+
' "declarationMap": false,',
|
|
719
|
+
' "emitDeclarationOnly": false,',
|
|
720
|
+
' "noEmit": true, // kept as the policy requires',
|
|
721
|
+
' "types": ["bun"]',
|
|
722
|
+
' },',
|
|
723
|
+
' /* the suites live beside the scripts they exercise */',
|
|
724
|
+
' "include": ["scripts/**/*.test.ts"],',
|
|
725
|
+
'}',
|
|
726
|
+
'',
|
|
727
|
+
].join('\n');
|
|
728
|
+
|
|
729
|
+
it('is repaired in place: the policy edits what it owns and every comment survives', async () => {
|
|
730
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-documented-'));
|
|
731
|
+
try {
|
|
732
|
+
await appWithCompositeDependency(root);
|
|
733
|
+
const path = join(root, 'packages/app/tsconfig.test.json');
|
|
734
|
+
await writeFile(path, documented);
|
|
735
|
+
|
|
736
|
+
expect(checkTypecheckTestPolicy(root).map((issue) => issue.message)).toEqual([
|
|
737
|
+
'must match the canonical no-emit test typecheck configuration',
|
|
738
|
+
]);
|
|
739
|
+
expect(applyTypecheckTestPolicy(root)).toBe(true);
|
|
740
|
+
|
|
741
|
+
const written = await readFile(path, 'utf8');
|
|
742
|
+
expect(written).toContain("// WHY the program extends the package's own config: these are Bun programs.");
|
|
743
|
+
expect(written).toContain('// kept as the policy requires');
|
|
744
|
+
expect(written).toContain('/* the suites live beside the scripts they exercise */');
|
|
745
|
+
expect(parseJson(written)).toEqual({
|
|
746
|
+
extends: './tsconfig.json',
|
|
747
|
+
compilerOptions: {
|
|
748
|
+
composite: false,
|
|
749
|
+
declaration: false,
|
|
750
|
+
declarationMap: false,
|
|
751
|
+
emitDeclarationOnly: false,
|
|
752
|
+
noEmit: true,
|
|
753
|
+
types: ['bun'],
|
|
754
|
+
},
|
|
755
|
+
include: ['scripts/**/*.test.ts'],
|
|
756
|
+
references: [{ path: '../lib/tsconfig.lib.json' }],
|
|
757
|
+
});
|
|
758
|
+
expect(checkTypecheckTestPolicy(root)).toEqual([]);
|
|
759
|
+
// The policy is at its own fixed point: a second run changes nothing.
|
|
760
|
+
expect(applyTypecheckTestPolicy(root)).toBe(false);
|
|
761
|
+
expect(await readFile(path, 'utf8')).toBe(written);
|
|
762
|
+
} finally {
|
|
763
|
+
await rm(root, { recursive: true, force: true });
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
it('has its test reference removed from tsconfig.json without losing the comments around it', async () => {
|
|
768
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-documented-'));
|
|
769
|
+
try {
|
|
770
|
+
await appWithCompositeDependency(root);
|
|
771
|
+
await writeFile(join(root, 'packages/app/tsconfig.test.json'), documented);
|
|
772
|
+
const path = join(root, 'packages/app/tsconfig.json');
|
|
773
|
+
await writeFile(
|
|
774
|
+
path,
|
|
775
|
+
[
|
|
776
|
+
'{',
|
|
777
|
+
' // The project is its lib program; the tests are typechecked on their own.',
|
|
778
|
+
' "references": [{ "path": "./tsconfig.lib.json" }, { "path": "./tsconfig.test.json" }]',
|
|
779
|
+
'}',
|
|
780
|
+
'',
|
|
781
|
+
].join('\n'),
|
|
782
|
+
);
|
|
783
|
+
|
|
784
|
+
applyTypecheckTestPolicy(root);
|
|
785
|
+
|
|
786
|
+
const written = await readFile(path, 'utf8');
|
|
787
|
+
expect(written).toContain('// The project is its lib program; the tests are typechecked on their own.');
|
|
788
|
+
expect(parseJson(written)).toEqual({ references: [{ path: './tsconfig.lib.json' }] });
|
|
789
|
+
} finally {
|
|
790
|
+
await rm(root, { recursive: true, force: true });
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
});
|
|
794
|
+
|
|
632
795
|
it('creates tsconfig.test.json for bun test package', async () => {
|
|
633
796
|
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
634
797
|
try {
|
|
@@ -734,6 +897,7 @@ describe('typecheck test policy', () => {
|
|
|
734
897
|
name: '@scope/bad',
|
|
735
898
|
scripts: { test: 'bun test' },
|
|
736
899
|
});
|
|
900
|
+
await writeSource(join(root, 'packages/bad/src/bad.test.ts'));
|
|
737
901
|
await writeJsonFs(join(root, 'packages/bad/tsconfig.test.json'), {
|
|
738
902
|
compilerOptions: {
|
|
739
903
|
composite: true,
|
|
@@ -936,6 +1100,327 @@ describe('typecheck test policy', () => {
|
|
|
936
1100
|
});
|
|
937
1101
|
});
|
|
938
1102
|
|
|
1103
|
+
// ---------------------------------------------------------------------------
|
|
1104
|
+
// The test program's include comes from where the tests live, and a program
|
|
1105
|
+
// that selects no file is refused
|
|
1106
|
+
// ---------------------------------------------------------------------------
|
|
1107
|
+
|
|
1108
|
+
const SRC_GLOBS = [
|
|
1109
|
+
'src/**/*.test.ts',
|
|
1110
|
+
'src/**/*.spec.ts',
|
|
1111
|
+
'src/**/__tests__/**/*.ts',
|
|
1112
|
+
'src/**/__tests__/**/*.tsx',
|
|
1113
|
+
'src/test-suite-tracer.ts',
|
|
1114
|
+
];
|
|
1115
|
+
|
|
1116
|
+
function globsFor(directory: string): string[] {
|
|
1117
|
+
return [
|
|
1118
|
+
`${directory}/**/*.test.ts`,
|
|
1119
|
+
`${directory}/**/*.spec.ts`,
|
|
1120
|
+
`${directory}/**/__tests__/**/*.ts`,
|
|
1121
|
+
`${directory}/**/__tests__/**/*.tsx`,
|
|
1122
|
+
];
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
async function writeSource(path: string, text = 'export {};\n'): Promise<void> {
|
|
1126
|
+
await mkdir(dirname(path), { recursive: true });
|
|
1127
|
+
await writeFile(path, text);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/** The shape of this repository's `tooling` project: tests beside the shell scripts, no src/. */
|
|
1131
|
+
async function toolingShapedWorkspace(root: string): Promise<void> {
|
|
1132
|
+
await writeJsonFs(join(root, 'package.json'), { workspaces: ['packages/*', 'tooling'] });
|
|
1133
|
+
await writeJsonFs(join(root, 'tsconfig.base.json'), { compilerOptions: {} });
|
|
1134
|
+
await writeJsonFs(join(root, 'tooling/package.json'), {
|
|
1135
|
+
name: '@scope/tooling',
|
|
1136
|
+
private: true,
|
|
1137
|
+
nx: {
|
|
1138
|
+
name: 'tooling',
|
|
1139
|
+
targets: {
|
|
1140
|
+
test: {
|
|
1141
|
+
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
1142
|
+
options: { command: 'bun test --timeout=30000 direnv', cwd: '{projectRoot}' },
|
|
1143
|
+
},
|
|
1144
|
+
},
|
|
1145
|
+
},
|
|
1146
|
+
});
|
|
1147
|
+
await writeSource(join(root, 'tooling/direnv/enter-shell.test.ts'));
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
describe('where the test program looks for tests', () => {
|
|
1151
|
+
it('includes the directory a src-less project keeps its tests in, not src', async () => {
|
|
1152
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1153
|
+
try {
|
|
1154
|
+
await toolingShapedWorkspace(root);
|
|
1155
|
+
|
|
1156
|
+
expect(applyTypecheckTestPolicy(root)).toBe(true);
|
|
1157
|
+
|
|
1158
|
+
const tsconfig = expectRecord(await readJsonFs(join(root, 'tooling/tsconfig.test.json')));
|
|
1159
|
+
expect(tsconfig.include).toEqual(globsFor('direnv'));
|
|
1160
|
+
expect(applyTypecheckTestPolicy(root)).toBe(false);
|
|
1161
|
+
expect(checkTypecheckTestPolicy(root)).toEqual([]);
|
|
1162
|
+
} finally {
|
|
1163
|
+
await rm(root, { recursive: true, force: true });
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
it('keeps the src convention for a package whose tests live in src', async () => {
|
|
1168
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1169
|
+
try {
|
|
1170
|
+
await writeJsonFs(join(root, 'package.json'), { workspaces: ['packages/*'] });
|
|
1171
|
+
await writeJsonFs(join(root, 'packages/app/package.json'), { name: '@scope/app', scripts: { test: 'bun test' } });
|
|
1172
|
+
await writeSource(join(root, 'packages/app/src/app.test.ts'));
|
|
1173
|
+
// A stray outside src stays the stray-test policy's to report; it must not widen the program.
|
|
1174
|
+
await writeSource(join(root, 'packages/app/scripts/helper.test.ts'));
|
|
1175
|
+
|
|
1176
|
+
applyTypecheckTestPolicy(root);
|
|
1177
|
+
|
|
1178
|
+
const tsconfig = expectRecord(await readJsonFs(join(root, 'packages/app/tsconfig.test.json')));
|
|
1179
|
+
expect(tsconfig.include).toEqual(SRC_GLOBS);
|
|
1180
|
+
} finally {
|
|
1181
|
+
await rm(root, { recursive: true, force: true });
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
|
|
1185
|
+
it('does not add a glob for tests an include the project wrote already selects', async () => {
|
|
1186
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1187
|
+
try {
|
|
1188
|
+
await toolingShapedWorkspace(root);
|
|
1189
|
+
await writeJsonFs(join(root, 'tooling/tsconfig.test.json'), {
|
|
1190
|
+
extends: '../tsconfig.base.json',
|
|
1191
|
+
compilerOptions: {
|
|
1192
|
+
composite: false,
|
|
1193
|
+
declaration: false,
|
|
1194
|
+
declarationMap: false,
|
|
1195
|
+
emitDeclarationOnly: false,
|
|
1196
|
+
noEmit: true,
|
|
1197
|
+
types: ['bun'],
|
|
1198
|
+
},
|
|
1199
|
+
include: ['direnv/**/*'],
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
expect(applyTypecheckTestPolicy(root)).toBe(false);
|
|
1203
|
+
|
|
1204
|
+
const tsconfig = expectRecord(await readJsonFs(join(root, 'tooling/tsconfig.test.json')));
|
|
1205
|
+
expect(tsconfig.include).toEqual(['direnv/**/*']);
|
|
1206
|
+
} finally {
|
|
1207
|
+
await rm(root, { recursive: true, force: true });
|
|
1208
|
+
}
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
it('adds the directory to an include the project wrote that selects none of its tests', async () => {
|
|
1212
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1213
|
+
try {
|
|
1214
|
+
await toolingShapedWorkspace(root);
|
|
1215
|
+
await writeJsonFs(join(root, 'tooling/tsconfig.test.json'), {
|
|
1216
|
+
extends: '../tsconfig.base.json',
|
|
1217
|
+
compilerOptions: {
|
|
1218
|
+
composite: false,
|
|
1219
|
+
declaration: false,
|
|
1220
|
+
declarationMap: false,
|
|
1221
|
+
emitDeclarationOnly: false,
|
|
1222
|
+
noEmit: true,
|
|
1223
|
+
types: ['bun'],
|
|
1224
|
+
},
|
|
1225
|
+
include: ['src/**/*.test.ts'],
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
expect(applyTypecheckTestPolicy(root)).toBe(true);
|
|
1229
|
+
|
|
1230
|
+
const tsconfig = expectRecord(await readJsonFs(join(root, 'tooling/tsconfig.test.json')));
|
|
1231
|
+
expect(tsconfig.include).toEqual(['src/**/*.test.ts', ...globsFor('direnv')]);
|
|
1232
|
+
} finally {
|
|
1233
|
+
await rm(root, { recursive: true, force: true });
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1237
|
+
|
|
1238
|
+
describe('a test program that selects none of its tests', () => {
|
|
1239
|
+
async function packageWithoutTests(root: string): Promise<void> {
|
|
1240
|
+
await writeJsonFs(join(root, 'package.json'), { workspaces: ['packages/*'] });
|
|
1241
|
+
await writeJsonFs(join(root, 'tsconfig.base.json'), { compilerOptions: {} });
|
|
1242
|
+
await writeJsonFs(join(root, 'packages/app/package.json'), { name: '@scope/app', scripts: { test: 'bun test' } });
|
|
1243
|
+
await writeSource(join(root, 'packages/app/src/index.ts'));
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
it('is reported by the generator without writing the file, naming the project and why', async () => {
|
|
1247
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1248
|
+
try {
|
|
1249
|
+
await packageWithoutTests(root);
|
|
1250
|
+
const tree = new FsTree(root, false);
|
|
1251
|
+
|
|
1252
|
+
const results = stageManagedFiles(tree, renderTypecheckTestFiles(tree));
|
|
1253
|
+
const skipped = results.find((result) => result.target === 'packages/app/tsconfig.test.json');
|
|
1254
|
+
|
|
1255
|
+
expect(skipped?.action).toBe('skipped');
|
|
1256
|
+
expect(skipped?.reason).toContain('matches no file');
|
|
1257
|
+
expect(skipped?.reason).toContain('packages/app');
|
|
1258
|
+
expect(tree.exists('packages/app/tsconfig.test.json')).toBe(false);
|
|
1259
|
+
expect(() => assertNoManagedConflicts(results)).not.toThrow();
|
|
1260
|
+
} finally {
|
|
1261
|
+
await rm(root, { recursive: true, force: true });
|
|
1262
|
+
}
|
|
1263
|
+
});
|
|
1264
|
+
|
|
1265
|
+
it('is reported by the policy check', async () => {
|
|
1266
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1267
|
+
try {
|
|
1268
|
+
await packageWithoutTests(root);
|
|
1269
|
+
await writeJsonFs(join(root, 'packages/app/tsconfig.test.json'), {
|
|
1270
|
+
extends: '../../tsconfig.base.json',
|
|
1271
|
+
compilerOptions: {
|
|
1272
|
+
composite: false,
|
|
1273
|
+
declaration: false,
|
|
1274
|
+
declarationMap: false,
|
|
1275
|
+
emitDeclarationOnly: false,
|
|
1276
|
+
noEmit: true,
|
|
1277
|
+
types: ['bun'],
|
|
1278
|
+
},
|
|
1279
|
+
include: SRC_GLOBS,
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1282
|
+
const issues = checkTypecheckTestPolicy(root);
|
|
1283
|
+
|
|
1284
|
+
expect(issues.map((issue) => issue.path)).toEqual([join(root, 'packages/app/tsconfig.test.json')]);
|
|
1285
|
+
expect(issues[0]?.message).toContain('matches no file');
|
|
1286
|
+
} finally {
|
|
1287
|
+
await rm(root, { recursive: true, force: true });
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
|
|
1291
|
+
it('is refused when its exclude removes every test', async () => {
|
|
1292
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1293
|
+
try {
|
|
1294
|
+
await packageWithoutTests(root);
|
|
1295
|
+
await writeSource(join(root, 'packages/app/src/app.test.ts'));
|
|
1296
|
+
await writeJsonFs(join(root, 'packages/app/tsconfig.test.json'), {
|
|
1297
|
+
extends: '../../tsconfig.base.json',
|
|
1298
|
+
compilerOptions: {
|
|
1299
|
+
composite: false,
|
|
1300
|
+
declaration: false,
|
|
1301
|
+
declarationMap: false,
|
|
1302
|
+
emitDeclarationOnly: false,
|
|
1303
|
+
noEmit: true,
|
|
1304
|
+
types: ['bun'],
|
|
1305
|
+
},
|
|
1306
|
+
include: SRC_GLOBS,
|
|
1307
|
+
exclude: ['src'],
|
|
1308
|
+
});
|
|
1309
|
+
|
|
1310
|
+
const issues = checkTypecheckTestPolicy(root);
|
|
1311
|
+
|
|
1312
|
+
expect(issues.map((issue) => issue.message).join('\n')).toContain('matches no file');
|
|
1313
|
+
} finally {
|
|
1314
|
+
await rm(root, { recursive: true, force: true });
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1318
|
+
it('is not refused while an inherited include the plugin cannot read may select files', async () => {
|
|
1319
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1320
|
+
try {
|
|
1321
|
+
await packageWithoutTests(root);
|
|
1322
|
+
await writeJsonFs(join(root, 'packages/app/tsconfig.test.json'), {
|
|
1323
|
+
extends: '@acme/tsconfig/bun.json',
|
|
1324
|
+
compilerOptions: {
|
|
1325
|
+
composite: false,
|
|
1326
|
+
declaration: false,
|
|
1327
|
+
declarationMap: false,
|
|
1328
|
+
emitDeclarationOnly: false,
|
|
1329
|
+
noEmit: true,
|
|
1330
|
+
types: ['bun'],
|
|
1331
|
+
},
|
|
1332
|
+
});
|
|
1333
|
+
|
|
1334
|
+
expect(checkTypecheckTestPolicy(root).some((issue) => issue.message.includes('matches no file'))).toBe(false);
|
|
1335
|
+
} finally {
|
|
1336
|
+
await rm(root, { recursive: true, force: true });
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
|
|
1340
|
+
it('is reported for a workspace member named by path, which the packages/* listing never walked', async () => {
|
|
1341
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1342
|
+
try {
|
|
1343
|
+
await toolingShapedWorkspace(root);
|
|
1344
|
+
await writeJsonFs(join(root, 'tooling/tsconfig.test.json'), {
|
|
1345
|
+
extends: '../tsconfig.base.json',
|
|
1346
|
+
compilerOptions: {
|
|
1347
|
+
composite: false,
|
|
1348
|
+
declaration: false,
|
|
1349
|
+
declarationMap: false,
|
|
1350
|
+
emitDeclarationOnly: false,
|
|
1351
|
+
noEmit: true,
|
|
1352
|
+
types: ['bun'],
|
|
1353
|
+
},
|
|
1354
|
+
include: ['src/**/*.test.ts'],
|
|
1355
|
+
});
|
|
1356
|
+
|
|
1357
|
+
const issues = checkTypecheckTestPolicy(root);
|
|
1358
|
+
|
|
1359
|
+
expect(issues.map((issue) => issue.path)).toEqual([
|
|
1360
|
+
join(root, 'tooling/tsconfig.test.json'),
|
|
1361
|
+
join(root, 'tooling/tsconfig.test.json'),
|
|
1362
|
+
]);
|
|
1363
|
+
expect(issues[0]?.message).toContain('matches no file of its tests');
|
|
1364
|
+
expect(issues[1]?.message).toContain('canonical');
|
|
1365
|
+
} finally {
|
|
1366
|
+
await rm(root, { recursive: true, force: true });
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
|
|
1370
|
+
it('is reported by the Tree check too', () => {
|
|
1371
|
+
const tree = createTreeWithEmptyWorkspace();
|
|
1372
|
+
addProjectConfiguration(tree, 'app', { root: 'packages/app', targets: {} });
|
|
1373
|
+
writeJson(tree, 'packages/app/package.json', {
|
|
1374
|
+
name: '@scope/app',
|
|
1375
|
+
scripts: { test: 'bun test' },
|
|
1376
|
+
nx: { name: 'app' },
|
|
1377
|
+
});
|
|
1378
|
+
writeJson(tree, 'tsconfig.base.json', { compilerOptions: {} });
|
|
1379
|
+
tree.write('packages/app/src/index.ts', 'export {};\n');
|
|
1380
|
+
writeJson(tree, 'packages/app/tsconfig.test.json', {
|
|
1381
|
+
extends: '../../tsconfig.base.json',
|
|
1382
|
+
compilerOptions: { noEmit: true, composite: false, declaration: false, declarationMap: false, types: ['bun'] },
|
|
1383
|
+
include: SRC_GLOBS,
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1386
|
+
expect(checkTypecheckTestPolicyTree(tree).map((issue) => issue.message)).toEqual([
|
|
1387
|
+
expect.stringContaining('matches no file (the project has no test file)'),
|
|
1388
|
+
]);
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1391
|
+
it('leaves an existing config it cannot honor as it was, and still repairs the project tsconfig.json', async () => {
|
|
1392
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1393
|
+
try {
|
|
1394
|
+
await packageWithoutTests(root);
|
|
1395
|
+
await writeJsonFs(join(root, 'packages/app/tsconfig.json'), {
|
|
1396
|
+
references: [{ path: './tsconfig.lib.json' }, { path: './tsconfig.test.json' }],
|
|
1397
|
+
});
|
|
1398
|
+
|
|
1399
|
+
const tree = new FsTree(root, false);
|
|
1400
|
+
const results = stageManagedFiles(tree, renderTypecheckTestFiles(tree));
|
|
1401
|
+
|
|
1402
|
+
expect(results.find((result) => result.target === 'packages/app/tsconfig.json')?.action).toBe('updated');
|
|
1403
|
+
expect(results.find((result) => result.target === 'packages/app/tsconfig.test.json')?.action).toBe('skipped');
|
|
1404
|
+
} finally {
|
|
1405
|
+
await rm(root, { recursive: true, force: true });
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
|
|
1409
|
+
it('does not stumble on a dangling link beside the sources', async () => {
|
|
1410
|
+
const root = await mkdtemp(join(tmpdir(), 'smoo-typecheck-test-policy-'));
|
|
1411
|
+
try {
|
|
1412
|
+
await packageWithoutTests(root);
|
|
1413
|
+
await writeSource(join(root, 'packages/app/src/app.test.ts'));
|
|
1414
|
+
await symlink(join(root, 'nowhere'), join(root, 'packages/app/result'));
|
|
1415
|
+
|
|
1416
|
+
expect(applyTypecheckTestPolicy(root)).toBe(true);
|
|
1417
|
+
expect(checkTypecheckTestPolicy(root)).toEqual([]);
|
|
1418
|
+
} finally {
|
|
1419
|
+
await rm(root, { recursive: true, force: true });
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
});
|
|
1423
|
+
|
|
939
1424
|
interface TypeScriptReference {
|
|
940
1425
|
path: string;
|
|
941
1426
|
}
|