Skip to content

feat: introduce --since-last-run flag - #11516

Merged
sheremet-va merged 8 commits into
mainfrom
feat/mtime-provider
Oct 19, 2026
Merged

sheremet-va merged 8 commits into
mainfrom
feat/mtime-provider

Conversation

@sheremet-va

@sheremet-va sheremet-va commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Closes #9917

This PR adds a new --since-last-run flag to run tests whose dependencies were changed since the last run. Unlike --changed, it doesn't require git and reuses a cached dependency tree instead of parsing every file on each invocation.

Additionally, this exposes a resolver object (that can return all dependencies) to custom vcs providers which is used by a new mtime provider. It is used by --since-last-run under the hood.

@AriPerkkio AriPerkkio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Stacks on #11515, in case you are also wondering what is recordDependencies)

hi-ogawa
hi-ogawa previously approved these changes Oct 8, 2026

@hi-ogawa hi-ogawa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!
While reviewing two PRs, I've put together some notes with visuals, so let me share in case it helps others: https://gist.github.com/hi-ogawa/381742c454891f31c772b4a4baf5f830#file-note-md

Comment on lines +37 to +39
if (!recordedAt.has(file) || (previous !== undefined && record.at < previous)) {
recordedAt.set(file, record.at)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one scenario where this record.at minimum pick can lead to non optimal re-run. This isn't realistically relevant as it combines --stale (or --recordDependencies) and file level filter, so it can be ignored, but just surfacing it here since this limitation may be coming from the abstraction choice of vcs vs resolver pattern and it just looked interesting for me.

The example looks like this:

a.test.js -> shared.js
b.test.js -> shared.js
# 1. runs both a and b
vitest --stale

# 2. modify shared.js

# 3. rerun stale with b filter -> run only b
vitest --stale b.test.js

# 4. rerun both a and b
# but dependency metadata has enough information b rerun isn't needed
vitest --stale

As test case, it would look like this:

test('a test that already ran after the edit does not run again', async () => {
  const files = {
    'src/shared.js': 'export {}',
    'a.test.js': testFile('a', `import './src/shared.js'`),
    'b.test.js': testFile('b', `import './src/shared.js'`),
  }
  const { fs, stderr } = await runInlineTests(files, { cache: true, stale: true })
  expect(stderr).toBe('')

  fs.editFile('src/shared.js', () => 'export const shared = 1')
  const onlyB = await runVitest({ root: fs.root, cache: true, stale: true, $cliFilters: ['b.test'] })
  expect(Object.keys(onlyB.testTree())).toEqual(['b.test.js'])

  const stale = await runVitest({ root: fs.root, cache: true, stale: true })
  expect(Object.keys(stale.testTree())).toEqual(['a.test.js'])
  // received ['a.test.js', 'b.test.js']
})

Base automatically changed from feat/changed-check-stored to main October 8, 2026 10:46
@sheremet-va
sheremet-va dismissed hi-ogawa’s stale review October 8, 2026 10:46

The base branch was changed.

@netlify

netlify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 8961164
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6ad5db03c46d918def7302a6
😎 Deploy Preview https://deploy-preview-11516--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@sheremet-va sheremet-va added this to the 5.1.0 milestone Oct 8, 2026
hi-ogawa
hi-ogawa previously approved these changes Oct 9, 2026
AriPerkkio
AriPerkkio previously approved these changes Oct 10, 2026
@sheremet-va
sheremet-va dismissed stale reviews from AriPerkkio and hi-ogawa via 89304df October 12, 2026 09:26
@sheremet-va sheremet-va changed the title feat: introduce --stale flag feat: introduce --since-last-run flag Oct 12, 2026
hi-ogawa
hi-ogawa previously approved these changes Oct 14, 2026
# Conflicts:
#	docs/guide/cli.md
#	packages/vitest/src/node/cli/cli-config.ts
#	packages/vitest/src/node/core.ts
#	packages/vitest/src/node/specifications.ts
@sheremet-va
sheremet-va merged commit 08bd93b into main Oct 19, 2026
9 of 24 checks passed
@sheremet-va
sheremet-va deleted the feat/mtime-provider branch October 19, 2026 09:03
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add --stale CLI option for agentic coding systems

3 participants