Skip to content

Commit

Permalink
refactor: mark internal isCached* methods (#7164)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Jan 3, 2025
1 parent 6a09cc3 commit c31472d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export default (parentServer: ParentBrowserProject, base = '/'): Plugin[] => {
name: 'vitest:browser:in-source-tests',
transform(code, id) {
const project = parentServer.vitest.getProjectByName(parentServer.config.name)
if (!project.isCachedTestFile(id) || !code.includes('import.meta.vitest')) {
if (!project._isCachedTestFile(id) || !code.includes('import.meta.vitest')) {
return
}
const s = new MagicString(code, { filename: cleanUrl(id) })
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/node/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,15 @@ export class TestProject {
* Returns if the file is a test file. Requires `.globTestFiles()` to be called first.
* @internal
*/
isCachedTestFile(testPath: string): boolean {
_isCachedTestFile(testPath: string): boolean {
return !!this.testFilesList && this.testFilesList.includes(testPath)
}

/**
* Returns if the file is a typecheck test file. Requires `.globTestFiles()` to be called first.
* @internal
*/
isCachedTypecheckFile(testPath: string): boolean {
_isCachedTypecheckFile(testPath: string): boolean {
return !!this.typecheckFilesList && this.typecheckFilesList.includes(testPath)
}

Expand Down Expand Up @@ -430,7 +430,7 @@ export class TestProject {
* Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
*/
public matchesTestGlob(moduleId: string, source?: () => string): boolean {
if (this.isCachedTestFile(moduleId)) {
if (this._isCachedTestFile(moduleId)) {
return true
}
const relativeId = relative(this.config.dir || this.config.root, moduleId)
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/node/specifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export class VitestSpecifications {

const specs: TestSpecification[] = []
for (const project of this.vitest.projects) {
if (project.isCachedTestFile(moduleId)) {
if (project._isCachedTestFile(moduleId)) {
specs.push(project.createSpecification(moduleId))
}
if (project.isCachedTypecheckFile(moduleId)) {
if (project._isCachedTypecheckFile(moduleId)) {
specs.push(project.createSpecification(moduleId, [], 'typescript'))
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/node/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class VitestWatcher {
if (!projects.length) {
// if there are no modules it's possible that server was restarted
// we don't have information about importers anymore, so let's check if the file is a test file at least
if (this.vitest.state.filesMap.has(filepath) || this.vitest.projects.some(project => project.isCachedTestFile(filepath))) {
if (this.vitest.state.filesMap.has(filepath) || this.vitest.projects.some(project => project._isCachedTestFile(filepath))) {
this.changedTests.add(filepath)
return true
}
Expand All @@ -142,7 +142,7 @@ export class VitestWatcher {
this.invalidates.add(filepath)

// one of test files that we already run, or one of test files that we can run
if (this.vitest.state.filesMap.has(filepath) || project.isCachedTestFile(filepath)) {
if (this.vitest.state.filesMap.has(filepath) || project._isCachedTestFile(filepath)) {
this.changedTests.add(filepath)
files.push(filepath)
continue
Expand Down

0 comments on commit c31472d

Please sign in to comment.