-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Making methods async and/or arrow functions in v3.2.0 is a breaking change #1208
Comments
There is also a react-native-ble-plx/src/BleManager.js Lines 313 to 314 in 2c8c138
|
Furthermore, making all the instance methods of BleManager arrow functions breaks tests that automock the BleManager class. See the note here: https://jestjs.io/docs/es6-class-mocks#automatic-mock If I manually edit the BleManager.js in my node_modules and change the methods back to regular non-arrow methods, my tests work fine. The following MRE breaks with v3.2.0: import { bleManager } from "./ble";
jest.mock("react-native-ble-plx");
describe("bleManager", () => {
it("stopDeviceScan", async () => {
// Fails on the following line with:
// Error: Property `stopDeviceScan` does not exist in the provided object
const spy = jest.spyOn(bleManager, "stopDeviceScan").mockResolvedValue();
await bleManager.stopDeviceScan();
expect(spy).toHaveBeenCalled();
});
}); Works fine with |
I would please request that you change the arrow functions back to methods so that they are on the BleManager prototype, and bump the version to v4. For now I will be downgrading to 3.1.0. Cheers |
@josmithua thanks for letting us know. Looking into it |
Prerequisites
Expected Behavior
v3.2.0 should have been v4.0.0 (assuming the project is following semantic versioning).
Current Behavior
Updating to v3.2.0 breaks typescript checking, return values, tests, etc.
Library version
v3.2.0
Device
any
Environment info
Steps to reproduce
Update to v3.2.0
Run tsc on project codebase using this library.
Formatted code sample or link to a repository
Relevant log output
Additional information
No response
The text was updated successfully, but these errors were encountered: