Skip to content

chore(tests): lint Jest tests with eslint-plugin-jest - #577

Open
X-Guardian wants to merge 2 commits into
open-constructs:mainfrom
X-Guardian:chore/eslint-plugin-jest
Open

X-Guardian wants to merge 2 commits into
open-constructs:mainfrom
X-Guardian:chore/eslint-plugin-jest

Conversation

@X-Guardian

@X-Guardian X-Guardian commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

Description

This PR adds eslint-plugin-jest as a root dev dependency and applies its flat/recommended config to **/*.test.ts in the shared eslint.config.mjs.

Package configs register their own test wrappers with the plugin:

  • cdktn: the testIf* aliases from test/helper/capabilities.ts count as test blocks for no-standalone-expect.
  • provider-generator: onTf1_6AndNewer in module-generator.test.ts becomes a cond ? test : test.skip alias, and counts as a test block. The gated test's title states the Terraform >= 1.6.0 requirement.
  • cli-core: waitFor counts as an assertion for expect-expect.
  • commons: the Linux-only exec() timeout table in util.test.ts runs through an itOnLinux alias, and itOnLinux.each counts as a test block.

Test changes:

  • cli-core/src/test/models/deploy-machine.test.ts: the done-callback tests await xstate's waitFor instead.
  • dependency-manager.test.ts and prebuilt-providers.test.ts check for unused registry mocks in afterEach with undici's assertNoPendingInterceptors().
  • Conditional expect calls become unconditional:
    • watch.test.ts splits its failure and abort cases into two tests.
    • telemetry.test.ts splits its attribute table into forwarded and omitted cases, and its gating test asserts the exact list of emitted metric names.
    • error-reporting.test.ts and init.test.ts assert on computed values.
  • cdktn/test/terraform-hcl-module.test.ts asserts the duplicate-alias error with toThrow.
  • cdktn/test/app.test.ts:
    • The cross-stack complex-list test matches the remote state reference and the output name in one stringMatching.
    • An exact duplicate of the remote-backend test is removed.
    • The second CDKTF_CONTEXT test is renamed for what it checks: CDKTF_CONTEXT takes precedence over app context.
  • cdktn/test/provider-functions.test.ts drops a test that duplicated the preceding one with a weaker assertion.
  • empty-provider-resources.test.ts asserts on the generated files.
  • Test files no longer export helpers; commons/src/config.test.ts drops an unused one.
  • Five titles lose stray spaces.
  • hcl2cdk/test/convertProject.test.ts keeps its describe.skip with a disable comment pointing at test(hcl2cdk): convertProject fixture uses a module with a removed Terraform language experiment #461.

Checklist

  • I have updated the PR title to match CDKTN's style guide
  • I have run the linter on my code locally
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works if applicable
  • New and existing unit tests pass locally with my changes

@X-Guardian
X-Guardian force-pushed the chore/eslint-plugin-jest branch from 3ed58d9 to ca1398c Compare November 11, 2026 10:06
@X-Guardian
X-Guardian marked this pull request as ready for review November 11, 2026 10:57
@X-Guardian
X-Guardian requested a review from a team as a code owner November 11, 2026 10:57
@X-Guardian
X-Guardian force-pushed the chore/eslint-plugin-jest branch from ca1398c to 879c7a3 Compare November 13, 2026 09:10
@jsteinich

Copy link
Copy Markdown
Contributor

Could you drop packages/@cdktn/cli-core/.prettierignore2 from the PR? It came in with 879c7a3 and looks like a stray local file:

  • Prettier only reads .prettierignore (plus .gitignore, or whatever --ignore-path names), and nothing in the repo points it at .prettierignore2, so the file has no effect. With Prettier 3.9.6, a pattern in .prettierignore2 doesn't ignore a matching file; the same pattern in .prettierignore does.
  • It's an older copy of the root .prettierignore. It still has entries main has since dropped (packages/cdktf-cli/templates/*/cdktf.json and the three !tools/... negations), and it's missing tools/generate-function-bindings/function-availability/.

@X-Guardian
X-Guardian force-pushed the chore/eslint-plugin-jest branch from 879c7a3 to 0b6a026 Compare November 13, 2026 15:05
@X-Guardian

Copy link
Copy Markdown
Contributor Author

Oops, done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: lint Jest tests with eslint-plugin-jest

2 participants