Skip to content

Commit 5dfba26

Browse files
authored
chore(docs): make throwing matcher example explicit (#10385)
1 parent a471551 commit 5dfba26

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

docs/UsingMatchers.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ function compileAndroidCode() {
146146
}
147147

148148
test('compiling android goes as expected', () => {
149-
expect(compileAndroidCode).toThrow();
150-
expect(compileAndroidCode).toThrow(Error);
149+
expect(() => compileAndroidCode()).toThrow();
150+
expect(() => compileAndroidCode()).toThrow(Error);
151151

152152
// You can also use the exact error message or a regexp
153-
expect(compileAndroidCode).toThrow('you are using the wrong JDK');
154-
expect(compileAndroidCode).toThrow(/JDK/);
153+
expect(() => compileAndroidCode()).toThrow('you are using the wrong JDK');
154+
expect(() => compileAndroidCode()).toThrow(/JDK/);
155155
});
156156
```
157157

website/versioned_docs/version-22.x/UsingMatchers.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ function compileAndroidCode() {
147147
}
148148

149149
test('compiling android goes as expected', () => {
150-
expect(compileAndroidCode).toThrow();
151-
expect(compileAndroidCode).toThrow(Error);
150+
expect(() => compileAndroidCode()).toThrow();
151+
expect(() => compileAndroidCode()).toThrow(Error);
152152

153153
// You can also use the exact error message or a regexp
154-
expect(compileAndroidCode).toThrow('you are using the wrong JDK');
155-
expect(compileAndroidCode).toThrow(/JDK/);
154+
expect(() => compileAndroidCode()).toThrow('you are using the wrong JDK');
155+
expect(() => compileAndroidCode()).toThrow(/JDK/);
156156
});
157157
```
158158

0 commit comments

Comments
 (0)