Repository navigation
gazelle/javascript,typescript: resolve test config setup files as deps - #4649
Merged
Merged
Conversation
Literal setupFiles, setupFilesAfterEnv, globalSetup, globalTeardown, and snapshotSerializers entries in jest, vitest, and vite configs now add the named modules to the config's rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011u9TXHDZrfmzFQ2WT8QAKK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #4644 for the other languages: modules that a test tool loads by a string declaration instead of an import.
Implemented
JavaScript and TypeScript:
jest.config.*,vitest.config.*, andvite.config.*(any JS/TS module extension) add deps for literal entries ofsetupFiles,setupFilesAfterEnv,globalSetup,globalTeardown, andsnapshotSerializers.test: { setupFiles })<rootDir>/is read as the config's directory# gazelle:resolve, and# gazelle:dx_ignore_importCode:
gazelle/common/jstestconfig.go, used throughcommon.ParseSourceImportRefsfrom both extensions. Tests:gazelle/common/jstestconfig_test.goand new generation fixturesgazelle/{javascript,typescript}/testdata/test_config.bazel test //gazelle/common:common_test //gazelle/javascript/... //gazelle/typescript/...passes.Considered, not implemented
testEnvironment,reporters,transform,preset,runner: names map to packages by prefix rules (jsdomtojest-environment-jsdom) or include built-ins, so not a static literal mapping..mocharc.*require, Karma,package.jsonjestkey: config is JSON/YAML or not a source the extension parses..rspec--require spec_helper: a non-source file that would need to add a dep to every spec under it;requireinspec_helper.rbis already an import.Code.require_file(..., __DIR__)intest_helper.exs: a file-path load that needssrcs/data, not a module dep.@ExtendWith/@RunWith/@Suiteare class references and already resolve;META-INF/servicesandjunit-platform.propertiesare resources, not sources.go test;//go:embedis data.#[path]changes module layout within the crate, not deps.phpunit.xmlbootstrap, Lua busted.bustedhelper: XML/Lua config files the extensions do not parse.include("x.jl"): same-package file inclusion, not a dependency.pytest.ini/pyproject.tomladdopts = -p pluginandpytest11entry points: config and packaging metadata, not sources.🤖 Generated with Claude Code