Skip to content

[FIX] correctly detect codeflash import#1201

Merged
mohammedahmed18 merged 1 commit intomainfrom
fix/codeflash-import-regex
Jan 30, 2026
Merged

[FIX] correctly detect codeflash import#1201
mohammedahmed18 merged 1 commit intomainfrom
fix/codeflash-import-regex

Conversation

@mohammedahmed18
Copy link
Contributor

@mohammedahmed18 mohammedahmed18 commented Jan 30, 2026

this fixes the issue where codeflash import is not added because the generated test has the word codeflash

    ReferenceError: codeflash is not defined

      302 |       }
      303 |
    > 304 |       const result = await codeflash.capture('PlainTextStagingStrategy.save', '8', PlainTextStagingStrategy.save.bind(PlainTextStagingStrategy), context)
          |                      ^
      305 |
      306 |       expect(result).toEqual({ success: true, storageType: 'plain_text' })
      307 |       expect(mockedFindFirst).toHaveBeenCalledTimes(1)

has_trailing_semicolon: bool


codeflash_import_pattern = re.compile(
Copy link
Contributor

Choose a reason for hiding this comment

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

There could be nested import in cjs files too like conditional imports etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this regex for capturing our own instrumentation which is a basic import
so we are good

@mohammedahmed18 mohammedahmed18 merged commit b54e27e into main Jan 30, 2026
28 of 31 checks passed
@mohammedahmed18 mohammedahmed18 deleted the fix/codeflash-import-regex branch January 30, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants