Skip to content

Conversation

@9aoy
Copy link
Contributor

@9aoy 9aoy commented Oct 23, 2025

Summary

fix: spyOn can be worked with imported properties.

update rspack define_property_getters template, sets the object configurable so that imported properties can be spied,

img_v3_02rb_bddb4ef9-9b23-49e6-b6bf-af1f690d0f7g

Related Links

fix: #578

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@Copilot Copilot AI review requested due to automatic review settings October 23, 2025 09:57
@netlify
Copy link

netlify bot commented Oct 23, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit abb80df
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68fa05c03367a00008b828d0
😎 Deploy Preview https://deploy-preview-644--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where spyOn could not work with imported properties by making them configurable. The fix modifies the Rspack runtime template to add the configurable: true property to imported module properties, enabling test frameworks to spy on and mock imported functions.

Key Changes:

  • Modified the define_property_getters runtime module to make imported properties configurable
  • Added comprehensive test coverage for spying on both static and dynamic imports

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/core/plugins/mockRuntime.ts Added string replacement logic to inject configurable: true into the define_property_getters runtime template
e2e/spy/spyOn.test.ts Added two new test cases covering static import spying and dynamic import spying scenarios
e2e/spy/fixtures/util.ts Created new test fixture file with a simple exported function for testing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@9aoy 9aoy requested a review from fi3ework October 23, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: mock the imported function from another module (wildcard import)

1 participant