Repository navigation
feat: introduce --since-last-run flag - #11516
Conversation
AriPerkkio
left a comment
There was a problem hiding this comment.
(Stacks on #11515, in case you are also wondering what is recordDependencies)
hi-ogawa
left a comment
There was a problem hiding this comment.
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
| if (!recordedAt.has(file) || (previous !== undefined && record.at < previous)) { | ||
| recordedAt.set(file, record.at) | ||
| } |
There was a problem hiding this comment.
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 --staleAs 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']
})da8bcb8 to
4f77fbf
Compare
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
--stale flag--since-last-run flag
# 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
Closes #9917
This PR adds a new
--since-last-runflag to run tests whose dependencies were changed since the last run. Unlike--changed, it doesn't requiregitand reuses a cached dependency tree instead of parsing every file on each invocation.Additionally, this exposes a
resolverobject (that can return all dependencies) to custom vcs providers which is used by a newmtimeprovider. It is used by--since-last-rununder the hood.