Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/UsingMatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,20 @@ If you want to test whether a particular function throws an error when it's call

```js
function compileAndroidCode() {
throw new Error('you are using the wrong JDK');
throw new Error('you are using the wrong JDK!');
}

test('compiling android goes as expected', () => {
expect(() => compileAndroidCode()).toThrow();
expect(() => compileAndroidCode()).toThrow(Error);

// You can also use the exact error message or a regexp
// You can also use a string that must be contained in the error message or a regexp
expect(() => compileAndroidCode()).toThrow('you are using the wrong JDK');
expect(() => compileAndroidCode()).toThrow(/JDK/);

// Or you can match an exact error mesage using a regexp like below
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK$/); // Test fails
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK!$/); // Test pass
});
```

Expand Down
8 changes: 6 additions & 2 deletions website/versioned_docs/version-25.x/UsingMatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,20 @@ If you want to test whether a particular function throws an error when it's call

```js
function compileAndroidCode() {
throw new Error('you are using the wrong JDK');
throw new Error('you are using the wrong JDK!');
}

test('compiling android goes as expected', () => {
expect(() => compileAndroidCode()).toThrow();
expect(() => compileAndroidCode()).toThrow(Error);

// You can also use the exact error message or a regexp
// You can also use a string that must be contained in the error message or a regexp
expect(() => compileAndroidCode()).toThrow('you are using the wrong JDK');
expect(() => compileAndroidCode()).toThrow(/JDK/);

// Or you can match an exact error mesage using a regexp like below
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK$/); // Test fails
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK!$/); // Test pass
});
```

Expand Down
8 changes: 6 additions & 2 deletions website/versioned_docs/version-26.x/UsingMatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,20 @@ If you want to test whether a particular function throws an error when it's call

```js
function compileAndroidCode() {
throw new Error('you are using the wrong JDK');
throw new Error('you are using the wrong JDK!');
}

test('compiling android goes as expected', () => {
expect(() => compileAndroidCode()).toThrow();
expect(() => compileAndroidCode()).toThrow(Error);

// You can also use the exact error message or a regexp
// You can also use a string that must be contained in the error message or a regexp
expect(() => compileAndroidCode()).toThrow('you are using the wrong JDK');
expect(() => compileAndroidCode()).toThrow(/JDK/);

// Or you can match an exact error mesage using a regexp like below
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK$/); // Test fails
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK!$/); // Test pass
});
```

Expand Down
8 changes: 6 additions & 2 deletions website/versioned_docs/version-27.x/UsingMatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,20 @@ If you want to test whether a particular function throws an error when it's call

```js
function compileAndroidCode() {
throw new Error('you are using the wrong JDK');
throw new Error('you are using the wrong JDK!');
}

test('compiling android goes as expected', () => {
expect(() => compileAndroidCode()).toThrow();
expect(() => compileAndroidCode()).toThrow(Error);

// You can also use the exact error message or a regexp
// You can also use a string that must be contained in the error message or a regexp
expect(() => compileAndroidCode()).toThrow('you are using the wrong JDK');
expect(() => compileAndroidCode()).toThrow(/JDK/);

// Or you can match an exact error mesage using a regexp like below
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK$/); // Test fails
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK!$/); // Test pass
});
```

Expand Down
8 changes: 6 additions & 2 deletions website/versioned_docs/version-28.x/UsingMatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,20 @@ If you want to test whether a particular function throws an error when it's call

```js
function compileAndroidCode() {
throw new Error('you are using the wrong JDK');
throw new Error('you are using the wrong JDK!');
}

test('compiling android goes as expected', () => {
expect(() => compileAndroidCode()).toThrow();
expect(() => compileAndroidCode()).toThrow(Error);

// You can also use the exact error message or a regexp
// You can also use a string that must be contained in the error message or a regexp
expect(() => compileAndroidCode()).toThrow('you are using the wrong JDK');
expect(() => compileAndroidCode()).toThrow(/JDK/);

// Or you can match an exact error mesage using a regexp like below
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK$/); // Test fails
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK!$/); // Test pass
});
```

Expand Down
8 changes: 6 additions & 2 deletions website/versioned_docs/version-29.0/UsingMatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,20 @@ If you want to test whether a particular function throws an error when it's call

```js
function compileAndroidCode() {
throw new Error('you are using the wrong JDK');
throw new Error('you are using the wrong JDK!');
}

test('compiling android goes as expected', () => {
expect(() => compileAndroidCode()).toThrow();
expect(() => compileAndroidCode()).toThrow(Error);

// You can also use the exact error message or a regexp
// You can also use a string that must be contained in the error message or a regexp
expect(() => compileAndroidCode()).toThrow('you are using the wrong JDK');
expect(() => compileAndroidCode()).toThrow(/JDK/);

// Or you can match an exact error mesage using a regexp like below
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK$/); // Test fails
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK!$/); // Test pass
});
```

Expand Down
8 changes: 6 additions & 2 deletions website/versioned_docs/version-29.1/UsingMatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,20 @@ If you want to test whether a particular function throws an error when it's call

```js
function compileAndroidCode() {
throw new Error('you are using the wrong JDK');
throw new Error('you are using the wrong JDK!');
}

test('compiling android goes as expected', () => {
expect(() => compileAndroidCode()).toThrow();
expect(() => compileAndroidCode()).toThrow(Error);

// You can also use the exact error message or a regexp
// You can also use a string that must be contained in the error message or a regexp
expect(() => compileAndroidCode()).toThrow('you are using the wrong JDK');
expect(() => compileAndroidCode()).toThrow(/JDK/);

// Or you can match an exact error mesage using a regexp like below
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK$/); // Test fails
expect(() => compileAndroidCode()).toThrow(/^you are using the wrong JDK!$/); // Test pass
});
```

Expand Down