Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Feb 20, 2024
1 parent 46031c1 commit 37401b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 4 additions & 3 deletions docs/JestObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,9 @@ test('plays video', () => {
});
```

#### spied methods and the `using` keyword
#### Spied methods and the `using` keyword

If your codebase is set up to transpile the ["explicit resource management"](https://github.com/tc39/proposal-explicit-resource-management) (e.g. if you are using TypeScript >= 5.2 or the `'@babel/plugin-proposal-explicit-resource-management'` plugin), you can use `spyOn` in combination with the `using` keyword:
If your codebase is set up to transpile the ["explicit resource management"](https://github.com/tc39/proposal-explicit-resource-management) (e.g. if you are using TypeScript >= 5.2 or the `@babel/plugin-proposal-explicit-resource-management` plugin), you can use `spyOn` in combination with the `using` keyword:

```js
test('logs a warning', () => {
Expand All @@ -726,8 +726,9 @@ That code is semantically equal to

```js
test('logs a warning', () => {
let spy;
try {
using spy = jest.spyOn(console.warn);
spy = jest.spyOn(console.warn);
doSomeThingWarnWorthy();
expect(spy).toHaveBeenCalled();
} finally {
Expand Down
1 change: 0 additions & 1 deletion e2e/explicit-resource-management/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
('use strict');

if (!Symbol.dispose) {
Object.defineProperty(Symbol, 'dispose', {
Expand Down

0 comments on commit 37401b9

Please sign in to comment.