Repository navigation
fix(ai): keep cassettes of filtered tests when recording - #58890
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Looks good. I reproduced it on the base: recording only the OpenAI decision test with -t and fake TYPESAFE_API_KEY/OPENAI_API_KEY deleted the filtered-out TypeSafe cassette. With this change only the cassette of the test that runs is replaced. testEffect provides the layer per test at run time, and building the recorder layers doesn't touch the cassette, so deleting it inside Layer.unwrap still happens before recording. The replay tests pass and tsc --noEmit for packages/ai is clean.
Public API is unchanged (test helper only).
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.
Problem
Recording one test with
RECORD=true bun test file -t "name"deleted the cassettes of the other tests in the same file. For example, recording only the OpenAI case intest/provider/decision.recorded.test.tswiped the TypeSafe, OpenCode and OpenRouter cassettes whenever their keys were set.recordedTestsremoved the cassette while building the layer, and the layer is built when bun registers the test, before-tdecides what runs:Change
I moved the removal into a
Layer.unwrap, so it happens when the test's layer is built at run time. Only tests that actually run get their cassette replaced. There's no pruning of stale cassettes anywhere, so nothing else changes.RECORDED_PREFIXalready skipped before the layer was built, so it was only-tthat hit this.Out of scope
packages/core/test/session-runner-recorded.test.tsremoves its cassette at module load too, but that file has only one recorded cassette, so filtering can't delete another test's recording.