Skip to content

Conversation

@iamrahulroy
Copy link
Contributor

Summary

The code snippet using on 'Using Matchers' docs under Exceptions section is broken.

The code snippet is using, ConfigError inside compileAndroidCode function. Running the test, throws following error ReferenceError: ConfigError is not defined.

Fix

I have changed, ConfigError to generic Error.

So the original snippet of code now looks like this:

function compileAndroidCode() {
  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
  expect(compileAndroidCode).toThrow('you are using the wrong JDK');
  expect(compileAndroidCode).toThrow(/JDK/);
});

Alternatively, a TypeError can be thrown, but that'll significantly change the example code. I have refrained myself from doing that, but here's snippet I would have used:

function compileAndCheckForType() {
  throw new TypeError('you are using the wrong type.');
}

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

  // You can also use the exact error message or a regexp
  expect(compileAndCheckForType).toThrow('you are using the wrong type.');
  expect(compileAndCheckForType).toThrow(/type/);
});

Let me know if the changelog is required to be update for this PR.

Test plan

Not Applicable?

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@codecov-io
Copy link

codecov-io commented Sep 13, 2019

Codecov Report

Merging #8953 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #8953   +/-   ##
=======================================
  Coverage   64.25%   64.25%           
=======================================
  Files         276      276           
  Lines       11706    11706           
  Branches     2865     2866    +1     
=======================================
  Hits         7522     7522           
  Misses       3552     3552           
  Partials      632      632

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa10c19...7970f51. Read the comment docs.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamrahulroy
Copy link
Contributor Author

@SimenB Thanks for quick response. Submitted the additional request change.

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@SimenB SimenB merged commit 5a45171 into jestjs:master Sep 13, 2019
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants