X Tutup
Skip to content

Remove AbortController test mock#3506

Merged
mfazekas merged 1 commit intornmapbox:mainfrom
EvanHahn:remove-abortcontroller-mock
Jun 5, 2024
Merged

Remove AbortController test mock#3506
mfazekas merged 1 commit intornmapbox:mainfrom
EvanHahn:remove-abortcontroller-mock

Conversation

@EvanHahn
Copy link
Contributor

@EvanHahn EvanHahn commented Jun 4, 2024

Description

This library includes an AbortController test mock, which doesn't work in places that expect a real one. For example, I was writing an unrelated test that tried to cancel a fetch() which failed because the AbortController's signal property was invalid.

Because AbortController is in all supported Node versions, we can safely remove this mock and rely on the real thing.

This should only affect tests.

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
  • I added/updated a sample - if a new feature was implemented (/example)

Reproduction

This test fails before this change:

test("AbortController has an AbortSignal", () => {
  const abortController = new AbortController();
  expect(abortController.signal).toBeInstanceOf(AbortSignal);
});

This library includes an `AbortController` test mock, which doesn't work
in places that expect a real one. For example, I was writing an
unrelated test that tried to cancel a `fetch()` which failed because
the `AbortController`'s `signal` property was invalid.

Because [`AbortController` is in all supported Node versions][0], we can
safely remove this mock and rely on the real thing.

This should only affect tests.

[0]: https://developer.mozilla.org/en-US/docs/Web/API/AbortController#browser_compatibility
@EvanHahn EvanHahn temporarily deployed to CI with Mapbox Tokens June 4, 2024 17:48 — with GitHub Actions Inactive
@EvanHahn EvanHahn temporarily deployed to CI with Mapbox Tokens June 4, 2024 17:48 — with GitHub Actions Inactive
@EvanHahn EvanHahn temporarily deployed to CI with Mapbox Tokens June 4, 2024 17:48 — with GitHub Actions Inactive
@EvanHahn EvanHahn temporarily deployed to CI with Mapbox Tokens June 4, 2024 17:48 — with GitHub Actions Inactive
@EvanHahn EvanHahn temporarily deployed to CI with Mapbox Tokens June 4, 2024 17:48 — with GitHub Actions Inactive
@EvanHahn EvanHahn temporarily deployed to CI with Mapbox Tokens June 4, 2024 17:48 — with GitHub Actions Inactive
EvanHahn added a commit to digidem/comapeo-mobile that referenced this pull request Jun 4, 2024
Once a day, a metrics report will be generated and sent to our metrics
server. These are governed by two new environment variables, documented
in the README.

Most of the magic happens in the `useSendMetrics` hook.

There were a few parts of this work that were kinda unrelated:

- I added several small helper functions (`assert`, `sleep`, and
  `throwIfAborted`).
- `@rnmapbox/maps` has a bug where its Jest helper breaks
  `AbortController`, which we use here. I had to patch the module, and I
  [submitted the patch upstream][0].

Closes [#332].

[0]: rnmapbox/maps#3506
[#332]: #332
@mfazekas mfazekas merged commit 5b6489e into rnmapbox:main Jun 5, 2024
@EvanHahn EvanHahn deleted the remove-abortcontroller-mock branch June 5, 2024 13:46
@EvanHahn
Copy link
Contributor Author

EvanHahn commented Jun 5, 2024

Thanks! Any estimate on when this will be released? No rush, just curious.

EvanHahn added a commit to digidem/comapeo-mobile that referenced this pull request Jun 11, 2024
Once a day, a metrics report will be generated and sent to our metrics
server. These are governed by two new environment variables, documented
in the README.

Most of the magic happens in the `useSendMetrics` hook.

There were a few parts of this work that were kinda unrelated:

- I added several small helper functions (`assert`, `sleep`, and
  `throwIfAborted`).
- `@rnmapbox/maps` has a bug where its Jest helper breaks
  `AbortController`, which we use here. I had to patch the module, and I
  [submitted the patch upstream][0].

Closes [#332].

[0]: rnmapbox/maps#3506
[#332]: #332
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

X Tutup